import{s as Sl,b as Ql,u as Nl,g as Ol,d as Dl,o as Kl}from"../chunks/scheduler.1f027d5a.js";import{S as El,i as zl,e as s,a as o,f as al,d as l,k as il,m as n,t as m,o as p,s as i,c as u,h as en,b as a,g as d,j as r,l as tn,n as f,p as h,r as ln,u as nn}from"../chunks/index.5cb6ce42.js";import{C as an}from"../chunks/CopyLLMTxtMenu.c64d5249.js";import{D as sn,C as v}from"../chunks/DocNotebookDropdown.adbd98a5.js";import{H as x,E as on}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.903c2670.js";function rn(M){let g,$,w;const T=M[2].default,c=Ql(T,M,M[1],null);return{c(){g=s("blockquote"),c&&c.c(),this.h()},l(b){g=o(b,"BLOCKQUOTE",{class:!0});var y=al(g);c&&c.l(y),y.forEach(l),this.h()},h(){il(g,"class",$=M[0]?"warning":"tip")},m(b,y){n(b,g,y),c&&c.m(g,null),w=!0},p(b,[y]){c&&c.p&&(!w||y&2)&&Nl(c,T,b,b[1],w?Dl(T,b[1],y,null):Ol(b[1]),null),(!w||y&1&&$!==($=b[0]?"warning":"tip"))&&il(g,"class",$)},i(b){w||(m(c,b),w=!0)},o(b){p(c,b),w=!1},d(b){b&&l(g),c&&c.d(b)}}}function mn(M,g,$){let{$$slots:w={},$$scope:T}=g,{warning:c=!1}=g;return M.$$set=b=>{"warning"in b&&$(0,c=b.warning),"$$scope"in b&&$(1,T=b.$$scope)},[c,T,w]}class pn extends El{constructor(g){super(),zl(this,g,mn,rn,Sl,{warning:0})}}function un(M){let g;return{c(){g=ln(`By default, LlamaIndex uses a chunk size of 1024 and a chunk overlap of
20. For more details, see the [LlamaIndex
documentation](https://docs.llamaindex.ai/en/stable/optimizing/basic_strategies/basic_strategies.html#chunk-sizes).`)},l($){g=nn($,`By default, LlamaIndex uses a chunk size of 1024 and a chunk overlap of
20. For more details, see the [LlamaIndex
documentation](https://docs.llamaindex.ai/en/stable/optimizing/basic_strategies/basic_strategies.html#chunk-sizes).`)},m($,w){n($,g,w)},d($){$&&l(g)}}}function dn(M){let g,$,w,T,c,b,y,Ae,k,qe,J,sl='<em>Authored by: <a href="https://huggingface.co/jinnovation" rel="nofollow">Jonathan Jin</a></em>',Pe,L,Ye,_,ol=`This notebook demonstrates how to quickly build a RAG-based “librarian” for your
local ebook library.`,Fe,U,rl=`Think about the last time you visited a library and took advantage of the
expertise of the knowledgeable staff there to help you find what you need out of
the troves of textbooks, novels, and other resources at the library. Our RAG
“librarian” will do the same for us, except for our own local collection of
ebooks.`,Se,G,Ee,I,ml=`We’d like our librarian to be <strong>lightweight</strong> and <strong>run locally as much as
possible</strong> with <strong>minimal dependencies</strong>. This means that we will leverage
open-source to the fullest extent possible, as well as bias towards models that
can be <strong>executed locally on typical hardware, e.g. M1 Macbooks</strong>.`,ze,j,Qe,Z,pl="Our solution will consist of the following components:",Ne,W,ul=`<li><a href="https://docs.llamaindex.ai/en/stable/index.html" rel="nofollow">LlamaIndex</a>, a data framework for LLM-based applications that’s, unlike
<a href="https://python.langchain.com/docs/get_started/introduction" rel="nofollow">LangChain</a>, designed specifically for RAG;</li> <li><a href="https://ollama.com/" rel="nofollow">Ollama</a>, a user-friendly solution for running LLMs such as Llama 2 locally;</li> <li>The <a href="https://huggingface.co/BAAI/bge-base-en-v1.5" rel="nofollow"><code>BAAI/bge-base-en-v1.5</code></a>
embedding model, which performs <a href="https://huggingface.co/spaces/mteb/leaderboard" rel="nofollow">reasonably well and is reasonably lightweight
in size</a>;</li> <li><a href="https://ollama.com/library/llama2" rel="nofollow">Llama 2</a>, which we’ll run via <a href="https://ollama.com/" rel="nofollow">Ollama</a>.</li>`,Oe,R,De,B,dl="First let’s install our dependencies.",Ke,H,et,X,tt,V,fl="These dependencies help properly detect the GPU.",lt,A,nt,q,hl="Install Ollama.",it,P,at,Y,gl="Run Ollama service in the background.",st,F,ot,S,bl="Pull Llama2 from the Ollama library.",rt,E,mt,z,pt,Q,cl="Next, let’s create our test “library.”",ut,N,$l="For simplicity’s sake, let’s say that our “library” is simply a <strong>nested directory of <code>.epub</code> files</strong>. We can easily see this solution generalizing to, say, a Calibre library with a <code>metadata.db</code> database file. We’ll leave that extension as an exercise for the reader. 😇",dt,O,wl='Let’s pull two <code>.epub</code> files from <a href="https://www.gutenberg.org/" rel="nofollow">Project Gutenberg</a> for our library.',ft,D,ht,K,gt,ee,yl="RAG with LlamaIndex, at its core, consists of the following broad phases:",bt,te,xl=`<li><strong>Loading</strong>, in which you tell LlamaIndex where your data lives and how to
load it;</li> <li><strong>Indexing</strong>, in which you augment your loaded data to facilitate querying, e.g. with vector embeddings;</li> <li><strong>Querying</strong>, in which you configure an LLM to act as the query interface for
your indexed data.</li>`,ct,le,Ml=`This explanation only scratches at the surface of what’s possible with
LlamaIndex. For more in-depth details, I highly recommend reading the
<a href="https://docs.llamaindex.ai/en/stable/getting_started/concepts.html" rel="nofollow">“High-Level Concepts” page of the LlamaIndex
documentation</a>.`,$t,ne,wt,ie,vl="Naturally, let’s start with the <strong>loading</strong> phase.",yt,ae,Tl=`I mentioned before that LlamaIndex is designed specifically for RAG. This
immediately becomes obvious from its
<a href="https://docs.llamaindex.ai/en/stable/module_guides/loading/simpledirectoryreader.html" rel="nofollow"><code>SimpleDirectoryReader</code></a>
construct, which ✨ <strong>magically</strong> ✨ supports a whole host of multi-model file
types for free. Conveniently for us, <code>.epub</code> is in the supported set.`,xt,se,Mt,oe,Cl='<code>SimpleDirectoryReader.load_data()</code> converts our ebooks into a set of <a href="https://docs.llamaindex.ai/en/stable/api/llama_index.core.schema.Document.html" rel="nofollow"><code>Document</code>s</a> for LlamaIndex to work with.',vt,re,kl="One important thing to note here is that the documents <strong>have not been chunked at this stage</strong> — that will happen during indexing. Read on…",Tt,me,Ct,pe,Jl="Next up after <strong>loading</strong> the data is to <strong>index</strong> it. This will allow our RAG pipeline to look up the relevant context for our query to pass to our LLM to <strong>augment</strong> their generated response. This is also where document chunking will take place.",kt,ue,Ll=`<a href="https://docs.llamaindex.ai/en/stable/module_guides/indexing/vector_store_index.html" rel="nofollow"><code>VectorStoreIndex</code></a>
is a “default” entrypoint for indexing in LlamaIndex. By default,
<code>VectorStoreIndex</code> uses a simple, in-memory dictionary to store the indices, but
LlamaIndex also supports <a href="https://docs.llamaindex.ai/en/stable/module_guides/storing/vector_stores.html" rel="nofollow">a wide variety of vector storage
solutions</a>
for you to graduate to as you scale.`,Jt,C,Lt,de,_l=`Like mentioned before, we’ll use the
<a href="https://huggingface.co/BAAI/bge-base-en-v1.5" rel="nofollow"><code>BAAI/bge-small-en-v1.5</code></a> to
generate our embeddings. By default, <a href="https://docs.llamaindex.ai/en/stable/getting_started/starter_example.html" rel="nofollow">LlamaIndex uses
OpenAI</a>
(specifically <code>gpt-3.5-turbo</code>), which we’d like to avoid given our desire for a lightweight, locally-runnable end-to-end solution.`,_t,fe,Ul="Thankfully, LlamaIndex supports retrieving embedding models from Hugging Face through the convenient <code>HuggingFaceEmbedding</code> class, so we’ll use that here.",Ut,he,Gt,ge,Gl="We’ll pass that in to <code>VectorStoreIndex</code> as our embedding model to circumvent the OpenAI default behavior.",It,be,jt,ce,Zt,$e,Il="Now for the final piece of the RAG puzzle — wiring up the query layer.",Wt,we,jl="We’ll use Llama 2 for the purposes of this recipe, but I encourage readers to play around with different models to see which produces the “best” responses here.",Rt,ye,Zl='First let’s start up the Ollama server. Unfortunately, there is no support in the <a href="https://github.com/ollama/ollama-python" rel="nofollow">Ollama Python client</a> for actually starting and stopping the server itself, so we’ll have to pop out of Python land for this.',Bt,xe,Wl="In a separate terminal, run: <code>ollama serve</code>. Remember to terminate this after we’re done here!",Ht,Me,Rl="Now let’s hook Llama 2 up to LlamaIndex and use it as the basis of our query engine.",Xt,ve,Vt,Te,At,Ce,Bl="With that, our basic RAG librarian is set up and we can start asking questions about our library. For example:",qt,ke,Pt,Je,Hl=`Based on the context provided, there are two books available:

1. "Pride and Prejudice" by Jane Austen
2. "Les Misérables" by Victor Hugo

The context used to derive this answer includes:

* The file path for each book, which provides information about the location of the book files on the computer.
* The titles of the books, which are mentioned in the context as being available for reading.
* A list of words associated with each book, such as "epub" and "notebooks", which provide additional information about the format and storage location of each book.
`,Yt,Le,Ft,_e,Xl=`The main character of 'Pride and Prejudice' is Elizabeth Bennet.
`,St,Ue,Et,Ge,Vl="We’ve demonstrated how to build a basic RAG-based “librarian” that runs entirely locally, even on Apple silicon Macs. In doing so, we’ve also carried out a “grand tour” of LlamaIndex and how it streamlines the process of setting up RAG-based applications.",zt,Ie,Al="That said, we’ve really only scratched the surface of what’s possible here. Here are some ideas of how to refine and build upon this foundation.",Qt,je,Nt,Ze,ql="To guard against the risk of our librarian hallucinating, how might we require that it provide citations for everything that it says?",Ot,We,Dt,Re,Pl='Ebook library management solutions like <a href="https://calibre-ebook.com/" rel="nofollow">Calibre</a> create additional metadata for ebooks in a library. This can provide information such as publisher or edition that might not be readily available in the text of the book itself. How could we extend our RAG pipeline to account for additional sources of information that aren’t <code>.epub</code> files?',Kt,Be,el,He,Yl="If we were to collect everything we built here into a script/executable, the resulting script would re-index our library on each invocation. For our tiny test library of two files, this is “fine,” but for any library of non-trivial size this will very quickly become annoying for users. How could we persist the embedding indices and only update them when the contents of the library have meaningfully changed, e.g. new books have been added?",tl,Xe,ll,Ve,nl;return c=new sn({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/main/notebooks/en/rag_llamaindex_librarian.ipynb"}]}}),y=new an({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),k=new x({props:{title:"Building A RAG Ebook “Librarian” Using LlamaIndex",local:"building-a-rag-ebook-librarian-using-llamaindex",headingTag:"h1"}}),L=new x({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),G=new x({props:{title:"Requirements",local:"requirements",headingTag:"h2"}}),j=new x({props:{title:"Components",local:"components",headingTag:"h2"}}),R=new x({props:{title:"Dependencies",local:"dependencies",headingTag:"h2"}}),H=new v({props:{code:"JTI1cGlwJTIwaW5zdGFsbCUyMC1xJTIwJTVDJTBBJTIwJTIwJTIwJTIwbGxhbWEtaW5kZXglMjAlNUMlMEElMjAlMjAlMjAlMjBFYm9va0xpYiUyMCU1QyUwQSUyMCUyMCUyMCUyMGh0bWwydGV4dCUyMCU1QyUwQSUyMCUyMCUyMCUyMGxsYW1hLWluZGV4LWVtYmVkZGluZ3MtaHVnZ2luZ2ZhY2UlMjAlNUMlMEElMjAlMjAlMjAlMjBsbGFtYS1pbmRleC1sbG1zLW9sbGFtYQ==",highlighted:`%pip install -q \\
    llama-index \\
    EbookLib \\
    html2text \\
    llama-index-embeddings-huggingface \\
    llama-index-llms-ollama`,wrap:!1}}),X=new x({props:{title:"Ollama installation",local:"ollama-installation",headingTag:"h2"}}),A=new v({props:{code:"IWFwdCUyMGluc3RhbGwlMjBwY2l1dGlscyUyMGxzaHc=",highlighted:"!apt install pciutils lshw",wrap:!1}}),P=new v({props:{code:"IWN1cmwlMjAtZnNTTCUyMGh0dHBzJTNBJTJGJTJGb2xsYW1hLmNvbSUyRmluc3RhbGwuc2glMjAlN0MlMjBzaA==",highlighted:"!curl -fsSL https://ollama.com/install.sh | sh",wrap:!1}}),F=new v({props:{code:"Z2V0X2lweXRob24oKS5zeXN0ZW1fcmF3KCdvbGxhbWElMjBzZXJ2ZSUyMCUyNicp",highlighted:'get_ipython().system_raw(<span class="hljs-string">&#x27;ollama serve &amp;&#x27;</span>)',wrap:!1}}),E=new v({props:{code:"IW9sbGFtYSUyMHB1bGwlMjBsbGFtYTI=",highlighted:"!ollama pull llama2",wrap:!1}}),z=new x({props:{title:"Test Library Setup",local:"test-library-setup",headingTag:"h2"}}),D=new v({props:{code:"IW1rZGlyJTIwLXAlMjAlMjIuJTJGdGVzdCUyRmxpYnJhcnklMkZqYW5lLWF1c3RlbiUyMiUwQSFta2RpciUyMC1wJTIwJTIyLiUyRnRlc3QlMkZsaWJyYXJ5JTJGdmljdG9yLWh1Z28lMjIlMEEhd2dldCUyMGh0dHBzJTNBJTJGJTJGd3d3Lmd1dGVuYmVyZy5vcmclMkZlYm9va3MlMkYxMzQyLmVwdWIubm9pbWFnZXMlMjAtTyUyMCUyMi4lMkZ0ZXN0JTJGbGlicmFyeSUyRmphbmUtYXVzdGVuJTJGcHJpZGUtYW5kLXByZWp1ZGljZS5lcHViJTIyJTBBIXdnZXQlMjBodHRwcyUzQSUyRiUyRnd3dy5ndXRlbmJlcmcub3JnJTJGZWJvb2tzJTJGMTM1LmVwdWIubm9pbWFnZXMlMjAtTyUyMCUyMi4lMkZ0ZXN0JTJGbGlicmFyeSUyRnZpY3Rvci1odWdvJTJGbGVzLW1pc2VyYWJsZXMuZXB1YiUyMg==",highlighted:`!mkdir -p <span class="hljs-string">&quot;./test/library/jane-austen&quot;</span>
!mkdir -p <span class="hljs-string">&quot;./test/library/victor-hugo&quot;</span>
!wget https://www.gutenberg.org/ebooks/<span class="hljs-number">1342.</span>epub.noimages -O <span class="hljs-string">&quot;./test/library/jane-austen/pride-and-prejudice.epub&quot;</span>
!wget https://www.gutenberg.org/ebooks/<span class="hljs-number">135.</span>epub.noimages -O <span class="hljs-string">&quot;./test/library/victor-hugo/les-miserables.epub&quot;</span>`,wrap:!1}}),K=new x({props:{title:"RAG with LlamaIndex",local:"rag-with-llamaindex",headingTag:"h2"}}),ne=new x({props:{title:"Loading",local:"loading",headingTag:"h3"}}),se=new v({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBTaW1wbGVEaXJlY3RvcnlSZWFkZXIlMEElMEFsb2FkZXIlMjAlM0QlMjBTaW1wbGVEaXJlY3RvcnlSZWFkZXIoJTBBJTIwJTIwJTIwJTIwaW5wdXRfZGlyJTNEJTIyLiUyRnRlc3QlMkYlMjIlMkMlMEElMjAlMjAlMjAlMjByZWN1cnNpdmUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmVxdWlyZWRfZXh0cyUzRCU1QiUyMi5lcHViJTIyJTVEJTJDJTBBKSUwQSUwQWRvY3VtZW50cyUyMCUzRCUyMGxvYWRlci5sb2FkX2RhdGEoKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> SimpleDirectoryReader

loader = SimpleDirectoryReader(
    input_dir=<span class="hljs-string">&quot;./test/&quot;</span>,
    recursive=<span class="hljs-literal">True</span>,
    required_exts=[<span class="hljs-string">&quot;.epub&quot;</span>],
)

documents = loader.load_data()`,wrap:!1}}),me=new x({props:{title:"Indexing",local:"indexing",headingTag:"h3"}}),C=new pn({props:{$$slots:{default:[un]},$$scope:{ctx:M}}}),he=new v({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmVtYmVkZGluZ3MuaHVnZ2luZ2ZhY2UlMjBpbXBvcnQlMjBIdWdnaW5nRmFjZUVtYmVkZGluZyUwQSUwQWVtYmVkZGluZ19tb2RlbCUyMCUzRCUyMEh1Z2dpbmdGYWNlRW1iZWRkaW5nKG1vZGVsX25hbWUlM0QlMjJCQUFJJTJGYmdlLXNtYWxsLWVuLXYxLjUlMjIp",highlighted:`<span class="hljs-keyword">from</span> llama_index.embeddings.huggingface <span class="hljs-keyword">import</span> HuggingFaceEmbedding

embedding_model = HuggingFaceEmbedding(model_name=<span class="hljs-string">&quot;BAAI/bge-small-en-v1.5&quot;</span>)`,wrap:!1}}),be=new v({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBWZWN0b3JTdG9yZUluZGV4JTBBJTBBaW5kZXglMjAlM0QlMjBWZWN0b3JTdG9yZUluZGV4LmZyb21fZG9jdW1lbnRzKCUwQSUyMCUyMCUyMCUyMGRvY3VtZW50cyUyQyUwQSUyMCUyMCUyMCUyMGVtYmVkX21vZGVsJTNEZW1iZWRkaW5nX21vZGVsJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> VectorStoreIndex

index = VectorStoreIndex.from_documents(
    documents,
    embed_model=embedding_model,
)`,wrap:!1}}),ce=new x({props:{title:"Querying",local:"querying",headingTag:"h3"}}),ve=new v({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMub2xsYW1hJTIwaW1wb3J0JTIwT2xsYW1hJTBBJTBBbGxhbWElMjAlM0QlMjBPbGxhbWEoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJsbGFtYTIlMjIlMkMlMEElMjAlMjAlMjAlMjByZXF1ZXN0X3RpbWVvdXQlM0Q0MC4wJTJDJTBBKSUwQSUwQXF1ZXJ5X2VuZ2luZSUyMCUzRCUyMGluZGV4LmFzX3F1ZXJ5X2VuZ2luZShsbG0lM0RsbGFtYSk=",highlighted:`<span class="hljs-keyword">from</span> llama_index.llms.ollama <span class="hljs-keyword">import</span> Ollama

llama = Ollama(
    model=<span class="hljs-string">&quot;llama2&quot;</span>,
    request_timeout=<span class="hljs-number">40.0</span>,
)

query_engine = index.as_query_engine(llm=llama)`,wrap:!1}}),Te=new x({props:{title:"Final Result",local:"final-result",headingTag:"h2"}}),ke=new v({props:{code:"cHJpbnQocXVlcnlfZW5naW5lLnF1ZXJ5KCUyMldoYXQlMjBhcmUlMjB0aGUlMjB0aXRsZXMlMjBvZiUyMGFsbCUyMHRoZSUyMGJvb2tzJTIwYXZhaWxhYmxlJTNGJTIwU2hvdyUyMG1lJTIwdGhlJTIwY29udGV4dCUyMHVzZWQlMjB0byUyMGRlcml2ZSUyMHlvdXIlMjBhbnN3ZXIuJTIyKSk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(query_engine.query(<span class="hljs-string">&quot;What are the titles of all the books available? Show me the context used to derive your answer.&quot;</span>))',wrap:!1}}),Le=new v({props:{code:"cHJpbnQocXVlcnlfZW5naW5lLnF1ZXJ5KCUyMldobyUyMGlzJTIwdGhlJTIwbWFpbiUyMGNoYXJhY3RlciUyMG9mJTIwJ1ByaWRlJTIwYW5kJTIwUHJlanVkaWNlJyUzRiUyMikp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(query_engine.query(<span class="hljs-string">&quot;Who is the main character of &#x27;Pride and Prejudice&#x27;?&quot;</span>))',wrap:!1}}),Ue=new x({props:{title:"Conclusion and Future Improvements",local:"conclusion-and-future-improvements",headingTag:"h2"}}),je=new x({props:{title:"Forcing Citations",local:"forcing-citations",headingTag:"h3"}}),We=new x({props:{title:"Using Extended Metadata",local:"using-extended-metadata",headingTag:"h3"}}),Be=new x({props:{title:"Efficient Indexing",local:"efficient-indexing",headingTag:"h3"}}),Xe=new on({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/en/rag_llamaindex_librarian.md"}}),{c(){g=s("meta"),$=i(),w=s("p"),T=i(),u(c.$$.fragment),b=i(),u(y.$$.fragment),Ae=i(),u(k.$$.fragment),qe=i(),J=s("p"),J.innerHTML=sl,Pe=i(),u(L.$$.fragment),Ye=i(),_=s("p"),_.textContent=ol,Fe=i(),U=s("p"),U.textContent=rl,Se=i(),u(G.$$.fragment),Ee=i(),I=s("p"),I.innerHTML=ml,ze=i(),u(j.$$.fragment),Qe=i(),Z=s("p"),Z.textContent=pl,Ne=i(),W=s("ul"),W.innerHTML=ul,Oe=i(),u(R.$$.fragment),De=i(),B=s("p"),B.textContent=dl,Ke=i(),u(H.$$.fragment),et=i(),u(X.$$.fragment),tt=i(),V=s("p"),V.textContent=fl,lt=i(),u(A.$$.fragment),nt=i(),q=s("p"),q.textContent=hl,it=i(),u(P.$$.fragment),at=i(),Y=s("p"),Y.textContent=gl,st=i(),u(F.$$.fragment),ot=i(),S=s("p"),S.textContent=bl,rt=i(),u(E.$$.fragment),mt=i(),u(z.$$.fragment),pt=i(),Q=s("p"),Q.textContent=cl,ut=i(),N=s("p"),N.innerHTML=$l,dt=i(),O=s("p"),O.innerHTML=wl,ft=i(),u(D.$$.fragment),ht=i(),u(K.$$.fragment),gt=i(),ee=s("p"),ee.textContent=yl,bt=i(),te=s("ol"),te.innerHTML=xl,ct=i(),le=s("p"),le.innerHTML=Ml,$t=i(),u(ne.$$.fragment),wt=i(),ie=s("p"),ie.innerHTML=vl,yt=i(),ae=s("p"),ae.innerHTML=Tl,xt=i(),u(se.$$.fragment),Mt=i(),oe=s("p"),oe.innerHTML=Cl,vt=i(),re=s("p"),re.innerHTML=kl,Tt=i(),u(me.$$.fragment),Ct=i(),pe=s("p"),pe.innerHTML=Jl,kt=i(),ue=s("p"),ue.innerHTML=Ll,Jt=i(),u(C.$$.fragment),Lt=i(),de=s("p"),de.innerHTML=_l,_t=i(),fe=s("p"),fe.innerHTML=Ul,Ut=i(),u(he.$$.fragment),Gt=i(),ge=s("p"),ge.innerHTML=Gl,It=i(),u(be.$$.fragment),jt=i(),u(ce.$$.fragment),Zt=i(),$e=s("p"),$e.textContent=Il,Wt=i(),we=s("p"),we.textContent=jl,Rt=i(),ye=s("p"),ye.innerHTML=Zl,Bt=i(),xe=s("p"),xe.innerHTML=Wl,Ht=i(),Me=s("p"),Me.textContent=Rl,Xt=i(),u(ve.$$.fragment),Vt=i(),u(Te.$$.fragment),At=i(),Ce=s("p"),Ce.textContent=Bl,qt=i(),u(ke.$$.fragment),Pt=i(),Je=s("pre"),Je.textContent=Hl,Yt=i(),u(Le.$$.fragment),Ft=i(),_e=s("pre"),_e.textContent=Xl,St=i(),u(Ue.$$.fragment),Et=i(),Ge=s("p"),Ge.textContent=Vl,zt=i(),Ie=s("p"),Ie.textContent=Al,Qt=i(),u(je.$$.fragment),Nt=i(),Ze=s("p"),Ze.textContent=ql,Ot=i(),u(We.$$.fragment),Dt=i(),Re=s("p"),Re.innerHTML=Pl,Kt=i(),u(Be.$$.fragment),el=i(),He=s("p"),He.textContent=Yl,tl=i(),u(Xe.$$.fragment),ll=i(),Ve=s("p"),this.h()},l(e){const t=en("svelte-u9bgzb",document.head);g=o(t,"META",{name:!0,content:!0}),t.forEach(l),$=a(e),w=o(e,"P",{}),al(w).forEach(l),T=a(e),d(c.$$.fragment,e),b=a(e),d(y.$$.fragment,e),Ae=a(e),d(k.$$.fragment,e),qe=a(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-15wt2km"&&(J.innerHTML=sl),Pe=a(e),d(L.$$.fragment,e),Ye=a(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-qfh19j"&&(_.textContent=ol),Fe=a(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-17t611x"&&(U.textContent=rl),Se=a(e),d(G.$$.fragment,e),Ee=a(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-1fw445c"&&(I.innerHTML=ml),ze=a(e),d(j.$$.fragment,e),Qe=a(e),Z=o(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-13bey4p"&&(Z.textContent=pl),Ne=a(e),W=o(e,"UL",{"data-svelte-h":!0}),r(W)!=="svelte-azwmvi"&&(W.innerHTML=ul),Oe=a(e),d(R.$$.fragment,e),De=a(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1yta0e7"&&(B.textContent=dl),Ke=a(e),d(H.$$.fragment,e),et=a(e),d(X.$$.fragment,e),tt=a(e),V=o(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-1ffiog4"&&(V.textContent=fl),lt=a(e),d(A.$$.fragment,e),nt=a(e),q=o(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-1qqxvb"&&(q.textContent=hl),it=a(e),d(P.$$.fragment,e),at=a(e),Y=o(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1ykyf08"&&(Y.textContent=gl),st=a(e),d(F.$$.fragment,e),ot=a(e),S=o(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-t4035a"&&(S.textContent=bl),rt=a(e),d(E.$$.fragment,e),mt=a(e),d(z.$$.fragment,e),pt=a(e),Q=o(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-u4a6ea"&&(Q.textContent=cl),ut=a(e),N=o(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-341xmi"&&(N.innerHTML=$l),dt=a(e),O=o(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1od3m7l"&&(O.innerHTML=wl),ft=a(e),d(D.$$.fragment,e),ht=a(e),d(K.$$.fragment,e),gt=a(e),ee=o(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-1dd5h8w"&&(ee.textContent=yl),bt=a(e),te=o(e,"OL",{"data-svelte-h":!0}),r(te)!=="svelte-vs2u02"&&(te.innerHTML=xl),ct=a(e),le=o(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-1arec5s"&&(le.innerHTML=Ml),$t=a(e),d(ne.$$.fragment,e),wt=a(e),ie=o(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-vs6beo"&&(ie.innerHTML=vl),yt=a(e),ae=o(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-atznhb"&&(ae.innerHTML=Tl),xt=a(e),d(se.$$.fragment,e),Mt=a(e),oe=o(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-17k0m2j"&&(oe.innerHTML=Cl),vt=a(e),re=o(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-10xvxlh"&&(re.innerHTML=kl),Tt=a(e),d(me.$$.fragment,e),Ct=a(e),pe=o(e,"P",{"data-svelte-h":!0}),r(pe)!=="svelte-73j9ky"&&(pe.innerHTML=Jl),kt=a(e),ue=o(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1axkw64"&&(ue.innerHTML=Ll),Jt=a(e),d(C.$$.fragment,e),Lt=a(e),de=o(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-dzonf1"&&(de.innerHTML=_l),_t=a(e),fe=o(e,"P",{"data-svelte-h":!0}),r(fe)!=="svelte-fkwvyv"&&(fe.innerHTML=Ul),Ut=a(e),d(he.$$.fragment,e),Gt=a(e),ge=o(e,"P",{"data-svelte-h":!0}),r(ge)!=="svelte-1181vy7"&&(ge.innerHTML=Gl),It=a(e),d(be.$$.fragment,e),jt=a(e),d(ce.$$.fragment,e),Zt=a(e),$e=o(e,"P",{"data-svelte-h":!0}),r($e)!=="svelte-1v49o0l"&&($e.textContent=Il),Wt=a(e),we=o(e,"P",{"data-svelte-h":!0}),r(we)!=="svelte-qxi4v1"&&(we.textContent=jl),Rt=a(e),ye=o(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-1esi2jc"&&(ye.innerHTML=Zl),Bt=a(e),xe=o(e,"P",{"data-svelte-h":!0}),r(xe)!=="svelte-z54bvc"&&(xe.innerHTML=Wl),Ht=a(e),Me=o(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-1xd6b55"&&(Me.textContent=Rl),Xt=a(e),d(ve.$$.fragment,e),Vt=a(e),d(Te.$$.fragment,e),At=a(e),Ce=o(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-1l7sm6m"&&(Ce.textContent=Bl),qt=a(e),d(ke.$$.fragment,e),Pt=a(e),Je=o(e,"PRE",{"data-svelte-h":!0}),r(Je)!=="svelte-czhhw9"&&(Je.textContent=Hl),Yt=a(e),d(Le.$$.fragment,e),Ft=a(e),_e=o(e,"PRE",{"data-svelte-h":!0}),r(_e)!=="svelte-13j10yu"&&(_e.textContent=Xl),St=a(e),d(Ue.$$.fragment,e),Et=a(e),Ge=o(e,"P",{"data-svelte-h":!0}),r(Ge)!=="svelte-hu2ihj"&&(Ge.textContent=Vl),zt=a(e),Ie=o(e,"P",{"data-svelte-h":!0}),r(Ie)!=="svelte-8meymn"&&(Ie.textContent=Al),Qt=a(e),d(je.$$.fragment,e),Nt=a(e),Ze=o(e,"P",{"data-svelte-h":!0}),r(Ze)!=="svelte-5ludxz"&&(Ze.textContent=ql),Ot=a(e),d(We.$$.fragment,e),Dt=a(e),Re=o(e,"P",{"data-svelte-h":!0}),r(Re)!=="svelte-1qo1u1t"&&(Re.innerHTML=Pl),Kt=a(e),d(Be.$$.fragment,e),el=a(e),He=o(e,"P",{"data-svelte-h":!0}),r(He)!=="svelte-aaxqx0"&&(He.textContent=Yl),tl=a(e),d(Xe.$$.fragment,e),ll=a(e),Ve=o(e,"P",{}),al(Ve).forEach(l),this.h()},h(){il(g,"name","hf:doc:metadata"),il(g,"content",fn)},m(e,t){tn(document.head,g),n(e,$,t),n(e,w,t),n(e,T,t),f(c,e,t),n(e,b,t),f(y,e,t),n(e,Ae,t),f(k,e,t),n(e,qe,t),n(e,J,t),n(e,Pe,t),f(L,e,t),n(e,Ye,t),n(e,_,t),n(e,Fe,t),n(e,U,t),n(e,Se,t),f(G,e,t),n(e,Ee,t),n(e,I,t),n(e,ze,t),f(j,e,t),n(e,Qe,t),n(e,Z,t),n(e,Ne,t),n(e,W,t),n(e,Oe,t),f(R,e,t),n(e,De,t),n(e,B,t),n(e,Ke,t),f(H,e,t),n(e,et,t),f(X,e,t),n(e,tt,t),n(e,V,t),n(e,lt,t),f(A,e,t),n(e,nt,t),n(e,q,t),n(e,it,t),f(P,e,t),n(e,at,t),n(e,Y,t),n(e,st,t),f(F,e,t),n(e,ot,t),n(e,S,t),n(e,rt,t),f(E,e,t),n(e,mt,t),f(z,e,t),n(e,pt,t),n(e,Q,t),n(e,ut,t),n(e,N,t),n(e,dt,t),n(e,O,t),n(e,ft,t),f(D,e,t),n(e,ht,t),f(K,e,t),n(e,gt,t),n(e,ee,t),n(e,bt,t),n(e,te,t),n(e,ct,t),n(e,le,t),n(e,$t,t),f(ne,e,t),n(e,wt,t),n(e,ie,t),n(e,yt,t),n(e,ae,t),n(e,xt,t),f(se,e,t),n(e,Mt,t),n(e,oe,t),n(e,vt,t),n(e,re,t),n(e,Tt,t),f(me,e,t),n(e,Ct,t),n(e,pe,t),n(e,kt,t),n(e,ue,t),n(e,Jt,t),f(C,e,t),n(e,Lt,t),n(e,de,t),n(e,_t,t),n(e,fe,t),n(e,Ut,t),f(he,e,t),n(e,Gt,t),n(e,ge,t),n(e,It,t),f(be,e,t),n(e,jt,t),f(ce,e,t),n(e,Zt,t),n(e,$e,t),n(e,Wt,t),n(e,we,t),n(e,Rt,t),n(e,ye,t),n(e,Bt,t),n(e,xe,t),n(e,Ht,t),n(e,Me,t),n(e,Xt,t),f(ve,e,t),n(e,Vt,t),f(Te,e,t),n(e,At,t),n(e,Ce,t),n(e,qt,t),f(ke,e,t),n(e,Pt,t),n(e,Je,t),n(e,Yt,t),f(Le,e,t),n(e,Ft,t),n(e,_e,t),n(e,St,t),f(Ue,e,t),n(e,Et,t),n(e,Ge,t),n(e,zt,t),n(e,Ie,t),n(e,Qt,t),f(je,e,t),n(e,Nt,t),n(e,Ze,t),n(e,Ot,t),f(We,e,t),n(e,Dt,t),n(e,Re,t),n(e,Kt,t),f(Be,e,t),n(e,el,t),n(e,He,t),n(e,tl,t),f(Xe,e,t),n(e,ll,t),n(e,Ve,t),nl=!0},p(e,[t]){const Fl={};t&2&&(Fl.$$scope={dirty:t,ctx:e}),C.$set(Fl)},i(e){nl||(m(c.$$.fragment,e),m(y.$$.fragment,e),m(k.$$.fragment,e),m(L.$$.fragment,e),m(G.$$.fragment,e),m(j.$$.fragment,e),m(R.$$.fragment,e),m(H.$$.fragment,e),m(X.$$.fragment,e),m(A.$$.fragment,e),m(P.$$.fragment,e),m(F.$$.fragment,e),m(E.$$.fragment,e),m(z.$$.fragment,e),m(D.$$.fragment,e),m(K.$$.fragment,e),m(ne.$$.fragment,e),m(se.$$.fragment,e),m(me.$$.fragment,e),m(C.$$.fragment,e),m(he.$$.fragment,e),m(be.$$.fragment,e),m(ce.$$.fragment,e),m(ve.$$.fragment,e),m(Te.$$.fragment,e),m(ke.$$.fragment,e),m(Le.$$.fragment,e),m(Ue.$$.fragment,e),m(je.$$.fragment,e),m(We.$$.fragment,e),m(Be.$$.fragment,e),m(Xe.$$.fragment,e),nl=!0)},o(e){p(c.$$.fragment,e),p(y.$$.fragment,e),p(k.$$.fragment,e),p(L.$$.fragment,e),p(G.$$.fragment,e),p(j.$$.fragment,e),p(R.$$.fragment,e),p(H.$$.fragment,e),p(X.$$.fragment,e),p(A.$$.fragment,e),p(P.$$.fragment,e),p(F.$$.fragment,e),p(E.$$.fragment,e),p(z.$$.fragment,e),p(D.$$.fragment,e),p(K.$$.fragment,e),p(ne.$$.fragment,e),p(se.$$.fragment,e),p(me.$$.fragment,e),p(C.$$.fragment,e),p(he.$$.fragment,e),p(be.$$.fragment,e),p(ce.$$.fragment,e),p(ve.$$.fragment,e),p(Te.$$.fragment,e),p(ke.$$.fragment,e),p(Le.$$.fragment,e),p(Ue.$$.fragment,e),p(je.$$.fragment,e),p(We.$$.fragment,e),p(Be.$$.fragment,e),p(Xe.$$.fragment,e),nl=!1},d(e){e&&(l($),l(w),l(T),l(b),l(Ae),l(qe),l(J),l(Pe),l(Ye),l(_),l(Fe),l(U),l(Se),l(Ee),l(I),l(ze),l(Qe),l(Z),l(Ne),l(W),l(Oe),l(De),l(B),l(Ke),l(et),l(tt),l(V),l(lt),l(nt),l(q),l(it),l(at),l(Y),l(st),l(ot),l(S),l(rt),l(mt),l(pt),l(Q),l(ut),l(N),l(dt),l(O),l(ft),l(ht),l(gt),l(ee),l(bt),l(te),l(ct),l(le),l($t),l(wt),l(ie),l(yt),l(ae),l(xt),l(Mt),l(oe),l(vt),l(re),l(Tt),l(Ct),l(pe),l(kt),l(ue),l(Jt),l(Lt),l(de),l(_t),l(fe),l(Ut),l(Gt),l(ge),l(It),l(jt),l(Zt),l($e),l(Wt),l(we),l(Rt),l(ye),l(Bt),l(xe),l(Ht),l(Me),l(Xt),l(Vt),l(At),l(Ce),l(qt),l(Pt),l(Je),l(Yt),l(Ft),l(_e),l(St),l(Et),l(Ge),l(zt),l(Ie),l(Qt),l(Nt),l(Ze),l(Ot),l(Dt),l(Re),l(Kt),l(el),l(He),l(tl),l(ll),l(Ve)),l(g),h(c,e),h(y,e),h(k,e),h(L,e),h(G,e),h(j,e),h(R,e),h(H,e),h(X,e),h(A,e),h(P,e),h(F,e),h(E,e),h(z,e),h(D,e),h(K,e),h(ne,e),h(se,e),h(me,e),h(C,e),h(he,e),h(be,e),h(ce,e),h(ve,e),h(Te,e),h(ke,e),h(Le,e),h(Ue,e),h(je,e),h(We,e),h(Be,e),h(Xe,e)}}}const fn='{"title":"Building A RAG Ebook “Librarian” Using LlamaIndex","local":"building-a-rag-ebook-librarian-using-llamaindex","sections":[{"title":"Introduction","local":"introduction","sections":[],"depth":2},{"title":"Requirements","local":"requirements","sections":[],"depth":2},{"title":"Components","local":"components","sections":[],"depth":2},{"title":"Dependencies","local":"dependencies","sections":[],"depth":2},{"title":"Ollama installation","local":"ollama-installation","sections":[],"depth":2},{"title":"Test Library Setup","local":"test-library-setup","sections":[],"depth":2},{"title":"RAG with LlamaIndex","local":"rag-with-llamaindex","sections":[{"title":"Loading","local":"loading","sections":[],"depth":3},{"title":"Indexing","local":"indexing","sections":[],"depth":3},{"title":"Querying","local":"querying","sections":[],"depth":3}],"depth":2},{"title":"Final Result","local":"final-result","sections":[],"depth":2},{"title":"Conclusion and Future Improvements","local":"conclusion-and-future-improvements","sections":[{"title":"Forcing Citations","local":"forcing-citations","sections":[],"depth":3},{"title":"Using Extended Metadata","local":"using-extended-metadata","sections":[],"depth":3},{"title":"Efficient Indexing","local":"efficient-indexing","sections":[],"depth":3}],"depth":2}],"depth":1}';function hn(M){return Kl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yn extends El{constructor(g){super(),zl(this,g,hn,dn,Sl,{})}}export{yn as component};
