{"version":"1.0","provider_name":"","provider_url":"https:\/\/vulab.com","author_name":"admin","author_url":"https:\/\/vulab.com\/index.php\/author\/vulab_admin\/","title":"Fine tuning LLM with Langchain -","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"wgYA0ZBejN\"><a href=\"https:\/\/vulab.com\/index.php\/2023\/05\/02\/fine-tuning-llm-with-langchain\/\">Fine tuning LLM with Langchain<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/vulab.com\/index.php\/2023\/05\/02\/fine-tuning-llm-with-langchain\/embed\/#?secret=wgYA0ZBejN\" width=\"600\" height=\"338\" title=\"&#8220;Fine tuning LLM with Langchain&#8221; &#8212; \" data-secret=\"wgYA0ZBejN\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script>\n\/*! This file is auto-generated *\/\n!function(d,l){\"use strict\";l.querySelector&&d.addEventListener&&\"undefined\"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!\/[^a-zA-Z0-9]\/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),o=l.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),c=new RegExp(\"^https?:$\",\"i\"),i=0;i<o.length;i++)o[i].style.display=\"none\";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute(\"style\"),\"height\"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):\"link\"===t.message&&(r=new URL(s.getAttribute(\"src\")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener(\"message\",d.wp.receiveEmbedMessage,!1),l.addEventListener(\"DOMContentLoaded\",function(){for(var e,t,s=l.querySelectorAll(\"iframe.wp-embedded-content\"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute(\"data-secret\"))||(t=Math.random().toString(36).substring(2,12),e.src+=\"#?secret=\"+t,e.setAttribute(\"data-secret\",t)),e.contentWindow.postMessage({message:\"ready\",secret:t},\"*\")},!1)))}(window,document);\n\/\/# sourceURL=https:\/\/vulab.com\/wp-includes\/js\/wp-embed.min.js\n<\/script>\n","description":"import osfrom pprint import pprintfrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.vectorstores import Chromafrom langchain.text_splitter import TokenTextSplitterfrom langchain.llms import OpenAIfrom langchain.chains import ChatVectorDBChainfrom langchain.document_loaders import UnstructuredURLLoader os.environ[&#8220;OPENAI_API_KEY&#8221;] = &#8216;your_open_api_key&#8217; h2o_ai_wave_urls = [&#8220;https:\/\/github.com\/h2oai\/wave\/releases&#8221;,&#8220;https:\/\/wave.h2o.ai\/docs\/installation&#8221;,&#8220;https:\/\/wave.h2o.ai\/docs\/getting-started&#8221;,&#8220;https:\/\/wave.h2o.ai\/docs\/examples&#8221;,&#8220;https:\/\/github.com\/h2oai\/wave\/issues\/693&#8221;,&#8220;https:\/\/github.com\/h2oai\/wave\/blob\/master\/.github\/CONTRIBUTING.md#development-setup&#8221;,&#8220;https:\/\/github.com\/h2oai\/wave\/discussions\/1897&#8221;,&#8220;https:\/\/github.com\/h2oai\/wave\/discussions\/1888&#8221;,&#8220;https:\/\/github.com\/h2oai\/wave\/discussions\/1885&#8221;,&#8220;https:\/\/github.com\/h2oai\/wave\/discussions\/1865&#8221;] collection_name = &#8220;h2o_wave_knowledgebase&#8221;local_directory = &#8220;kb-h2o-wave&#8221;persist_directory = os.path.join(os.getcwd(), local_directory) loader = UnstructuredURLLoader(urls=h2o_ai_wave_urls)kb_data = loader.load() text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=0)kb_doc = text_splitter.split_documents(kb_data) embeddings = OpenAIEmbeddings() kb_db = Chroma.from_documents(kb_doc,embeddings,collection_name=collection_name,persist_directory=persist_directory)kb_db.persist() kb_qa &hellip;  Read More &raquo;"}