import{s as Tl,c as kl,u as Ul,g as Il,d as Ll,o as _l}from"../chunks/scheduler.39a43cde.js";import{S as Jl,i as Cl,g as s,h as o,j as Xt,f as l,k as At,a as n,d as m,t as d,s as a,r as f,A as jl,c as i,u as h,x as r,y as Gl,v as g,w as b,m as Zl,n as Wl}from"../chunks/index.23ec2204.js";import{D as Bl,C as T}from"../chunks/DocNotebookDropdown.21a75b74.js";import{H as $,E as Rl}from"../chunks/EditOnGithub.f2d09226.js";function Hl(y){let p,w;const x=y[3].default,c=kl(x,y,y[2],null);return{c(){p=s("div"),c&&c.c(),this.h()},l(u){p=o(u,"DIV",{class:!0});var M=Xt(p);c&&c.l(M),M.forEach(l),this.h()},h(){At(p,"class","course-tip "+(y[0]==="orange"?"course-tip-orange":"")+" bg-gradient-to-br dark:bg-gradient-to-r before:border-"+y[0]+"-500 dark:before:border-"+y[0]+"-800 from-"+y[0]+"-50 dark:from-gray-900 to-white dark:to-gray-950 border border-"+y[0]+"-50 text-"+y[0]+"-700 dark:text-gray-400")},m(u,M){n(u,p,M),c&&c.m(p,null),w=!0},p(u,[M]){c&&c.p&&(!w||M&4)&&Ul(c,x,u,u[2],w?Ll(x,u[2],M,null):Il(u[2]),null)},i(u){w||(m(c,u),w=!0)},o(u){d(c,u),w=!1},d(u){u&&l(p),c&&c.d(u)}}}function Vl(y,p,w){let{$$slots:x={},$$scope:c}=p,{warning:u=!1}=p;const M=u?"orange":"green";return y.$$set=v=>{"warning"in v&&w(1,u=v.warning),"$$scope"in v&&w(2,c=v.$$scope)},[M,u,c,x]}class Xl extends Jl{constructor(p){super(),Cl(this,p,Vl,Hl,Tl,{warning:1})}}function Al(y){let p;return{c(){p=Zl(`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(w){p=Wl(w,`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,x){n(w,p,x)},d(w){w&&l(p)}}}function ql(y){let p,w,x,c,u,M,v,je,C,qt='<em>Authored by: <a href="https://huggingface.co/jinnovation" rel="nofollow">Jonathan Jin</a></em>',Ge,k,Ze,U,Yt=`This notebook demonstrates how to quickly build a RAG-based “librarian” for your
local ebook library.`,We,I,Pt=`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.`,Be,L,Re,_,Ft=`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>.`,He,j,Ve,G,Et="Our solution will consist of the following components:",Xe,Z,St=`<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>`,Ae,W,qe,B,Qt="First let’s install our dependencies.",Ye,R,Pe,H,Fe,V,Ee,X,zt="Next, let’s create our test “library.”",Se,A,Nt="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. 😇",Qe,q,Dt='Let’s pull two <code>.epub</code> files from <a href="https://www.gutenberg.org/" rel="nofollow">Project Gutenberg</a> for our library.',ze,Y,Ne,P,De,F,Ot="RAG with LlamaIndex, at its core, consists of the following broad phases:",Oe,E,Kt=`<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>`,Ke,S,el=`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>.`,et,Q,tt,z,tl="Naturally, let’s start with the <strong>loading</strong> phase.",lt,N,ll=`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.`,nt,D,at,O,nl='<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.',it,K,al="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…",st,ee,ot,te,il="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.",rt,le,sl=`<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.`,mt,J,dt,ne,ol=`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.`,pt,ae,rl="Thankfully, LlamaIndex supports retrieving embedding models from Hugging Face through the convenient <code>HuggingFaceEmbedding</code> class, so we’ll use that here.",ut,ie,ft,se,ml="We’ll pass that in to <code>VectorStoreIndex</code> as our embedding model to circumvent the OpenAI default behavior.",ht,oe,gt,re,bt,me,dl="Now for the final piece of the RAG puzzle — wiring up the query layer.",ct,de,pl="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.",wt,pe,ul='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.',yt,ue,fl="In a separate terminal, run: <code>ollama serve</code>. Remember to terminate this after we’re done here!",$t,fe,hl="Now let’s hook Llama 2 up to LlamaIndex and use it as the basis of our query engine.",Mt,he,xt,ge,vt,be,gl="With that, our basic RAG librarian is set up and we can start asking questions about our library. For example:",Tt,ce,Jt,we,bl=`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.
`,Ct,ye,kt,$e,cl=`The main character of 'Pride and Prejudice' is Elizabeth Bennet.
`,Ut,Me,It,xe,wl="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.",Lt,ve,yl="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.",_t,Te,jt,Je,$l="To guard against the risk of our librarian hallucinating, how might we require that it provide citations for everything that it says?",Gt,Ce,Zt,ke,Ml='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?',Wt,Ue,Bt,Ie,xl="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?",Rt,Le,Ht,_e,Vt;return u=new Bl({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"}]}}),v=new $({props:{title:"Building A RAG Ebook “Librarian” Using LlamaIndex",local:"building-a-rag-ebook-librarian-using-llamaindex",headingTag:"h1"}}),k=new $({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),L=new $({props:{title:"Requirements",local:"requirements",headingTag:"h2"}}),j=new $({props:{title:"Components",local:"components",headingTag:"h2"}}),W=new $({props:{title:"Dependencies",local:"dependencies",headingTag:"h2"}}),R=new T({props:{code:"JTI1cGlwJTIwaW5zdGFsbCUyMC1xJTIwJTVDJTBBJTIwJTIwJTIwJTIwbGxhbWEtaW5kZXglMjAlNUMlMEElMjAlMjAlMjAlMjBFYm9va0xpYiUyMCU1QyUwQSUyMCUyMCUyMCUyMGh0bWwydGV4dCUyMCU1QyUwQSUyMCUyMCUyMCUyMGxsYW1hLWluZGV4LWVtYmVkZGluZ3MtaHVnZ2luZ2ZhY2UlMjAlNUMlMEElMjAlMjAlMjAlMjBsbGFtYS1pbmRleC1sbG1zLW9sbGFtYQ==",highlighted:`%pip install -q \\
    llama-index \\
    EbookLib \\
    html2text \\
    llama-index-embeddings-huggingface \\
    llama-index-llms-ollama`,wrap:!1}}),H=new T({props:{code:"IWJyZXclMjBpbnN0YWxsJTIwb2xsYW1h",highlighted:"!brew install ollama",wrap:!1}}),V=new $({props:{title:"Test Library Setup",local:"test-library-setup",headingTag:"h2"}}),Y=new T({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}}),P=new $({props:{title:"RAG with LlamaIndex",local:"rag-with-llamaindex",headingTag:"h2"}}),Q=new $({props:{title:"Loading",local:"loading",headingTag:"h3"}}),D=new T({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}}),ee=new $({props:{title:"Indexing",local:"indexing",headingTag:"h3"}}),J=new Xl({props:{$$slots:{default:[Al]},$$scope:{ctx:y}}}),ie=new T({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}}),oe=new T({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}}),re=new $({props:{title:"Querying",local:"querying",headingTag:"h3"}}),he=new T({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}}),ge=new $({props:{title:"Final Result",local:"final-result",headingTag:"h2"}}),ce=new T({props:{code:"cHJpbnQoJTBBJTIwJTIwJTIwJTIwcXVlcnlfZW5naW5lLnF1ZXJ5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMldoYXQlMjBhcmUlMjB0aGUlMjB0aXRsZXMlMjBvZiUyMGFsbCUyMHRoZSUyMGJvb2tzJTIwYXZhaWxhYmxlJTNGJTIwU2hvdyUyMG1lJTIwdGhlJTIwY29udGV4dCUyMHVzZWQlMjB0byUyMGRlcml2ZSUyMHlvdXIlMjBhbnN3ZXIuJTIyJTBBJTIwJTIwJTIwJTIwKSUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(
<span class="hljs-meta">... </span>    query_engine.query(
<span class="hljs-meta">... </span>        <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>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>)`,wrap:!1}}),ye=new T({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}}),Me=new $({props:{title:"Conclusion and Future Improvements",local:"conclusion-and-future-improvements",headingTag:"h2"}}),Te=new $({props:{title:"Forcing Citations",local:"forcing-citations",headingTag:"h3"}}),Ce=new $({props:{title:"Using Extended Metadata",local:"using-extended-metadata",headingTag:"h3"}}),Ue=new $({props:{title:"Efficient Indexing",local:"efficient-indexing",headingTag:"h3"}}),Le=new Rl({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/en/rag_llamaindex_librarian.md"}}),{c(){p=s("meta"),w=a(),x=s("p"),c=a(),f(u.$$.fragment),M=a(),f(v.$$.fragment),je=a(),C=s("p"),C.innerHTML=qt,Ge=a(),f(k.$$.fragment),Ze=a(),U=s("p"),U.textContent=Yt,We=a(),I=s("p"),I.textContent=Pt,Be=a(),f(L.$$.fragment),Re=a(),_=s("p"),_.innerHTML=Ft,He=a(),f(j.$$.fragment),Ve=a(),G=s("p"),G.textContent=Et,Xe=a(),Z=s("ul"),Z.innerHTML=St,Ae=a(),f(W.$$.fragment),qe=a(),B=s("p"),B.textContent=Qt,Ye=a(),f(R.$$.fragment),Pe=a(),f(H.$$.fragment),Fe=a(),f(V.$$.fragment),Ee=a(),X=s("p"),X.textContent=zt,Se=a(),A=s("p"),A.innerHTML=Nt,Qe=a(),q=s("p"),q.innerHTML=Dt,ze=a(),f(Y.$$.fragment),Ne=a(),f(P.$$.fragment),De=a(),F=s("p"),F.textContent=Ot,Oe=a(),E=s("ol"),E.innerHTML=Kt,Ke=a(),S=s("p"),S.innerHTML=el,et=a(),f(Q.$$.fragment),tt=a(),z=s("p"),z.innerHTML=tl,lt=a(),N=s("p"),N.innerHTML=ll,nt=a(),f(D.$$.fragment),at=a(),O=s("p"),O.innerHTML=nl,it=a(),K=s("p"),K.innerHTML=al,st=a(),f(ee.$$.fragment),ot=a(),te=s("p"),te.innerHTML=il,rt=a(),le=s("p"),le.innerHTML=sl,mt=a(),f(J.$$.fragment),dt=a(),ne=s("p"),ne.innerHTML=ol,pt=a(),ae=s("p"),ae.innerHTML=rl,ut=a(),f(ie.$$.fragment),ft=a(),se=s("p"),se.innerHTML=ml,ht=a(),f(oe.$$.fragment),gt=a(),f(re.$$.fragment),bt=a(),me=s("p"),me.textContent=dl,ct=a(),de=s("p"),de.textContent=pl,wt=a(),pe=s("p"),pe.innerHTML=ul,yt=a(),ue=s("p"),ue.innerHTML=fl,$t=a(),fe=s("p"),fe.textContent=hl,Mt=a(),f(he.$$.fragment),xt=a(),f(ge.$$.fragment),vt=a(),be=s("p"),be.textContent=gl,Tt=a(),f(ce.$$.fragment),Jt=a(),we=s("pre"),we.textContent=bl,Ct=a(),f(ye.$$.fragment),kt=a(),$e=s("pre"),$e.textContent=cl,Ut=a(),f(Me.$$.fragment),It=a(),xe=s("p"),xe.textContent=wl,Lt=a(),ve=s("p"),ve.textContent=yl,_t=a(),f(Te.$$.fragment),jt=a(),Je=s("p"),Je.textContent=$l,Gt=a(),f(Ce.$$.fragment),Zt=a(),ke=s("p"),ke.innerHTML=Ml,Wt=a(),f(Ue.$$.fragment),Bt=a(),Ie=s("p"),Ie.textContent=xl,Rt=a(),f(Le.$$.fragment),Ht=a(),_e=s("p"),this.h()},l(e){const t=jl("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(l),w=i(e),x=o(e,"P",{}),Xt(x).forEach(l),c=i(e),h(u.$$.fragment,e),M=i(e),h(v.$$.fragment,e),je=i(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-15wt2km"&&(C.innerHTML=qt),Ge=i(e),h(k.$$.fragment,e),Ze=i(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-qfh19j"&&(U.textContent=Yt),We=i(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-17t611x"&&(I.textContent=Pt),Be=i(e),h(L.$$.fragment,e),Re=i(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1fw445c"&&(_.innerHTML=Ft),He=i(e),h(j.$$.fragment,e),Ve=i(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-13bey4p"&&(G.textContent=Et),Xe=i(e),Z=o(e,"UL",{"data-svelte-h":!0}),r(Z)!=="svelte-azwmvi"&&(Z.innerHTML=St),Ae=i(e),h(W.$$.fragment,e),qe=i(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1yta0e7"&&(B.textContent=Qt),Ye=i(e),h(R.$$.fragment,e),Pe=i(e),h(H.$$.fragment,e),Fe=i(e),h(V.$$.fragment,e),Ee=i(e),X=o(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-u4a6ea"&&(X.textContent=zt),Se=i(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-341xmi"&&(A.innerHTML=Nt),Qe=i(e),q=o(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-1od3m7l"&&(q.innerHTML=Dt),ze=i(e),h(Y.$$.fragment,e),Ne=i(e),h(P.$$.fragment,e),De=i(e),F=o(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-1dd5h8w"&&(F.textContent=Ot),Oe=i(e),E=o(e,"OL",{"data-svelte-h":!0}),r(E)!=="svelte-vs2u02"&&(E.innerHTML=Kt),Ke=i(e),S=o(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-1arec5s"&&(S.innerHTML=el),et=i(e),h(Q.$$.fragment,e),tt=i(e),z=o(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-vs6beo"&&(z.innerHTML=tl),lt=i(e),N=o(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-atznhb"&&(N.innerHTML=ll),nt=i(e),h(D.$$.fragment,e),at=i(e),O=o(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-17k0m2j"&&(O.innerHTML=nl),it=i(e),K=o(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-10xvxlh"&&(K.innerHTML=al),st=i(e),h(ee.$$.fragment,e),ot=i(e),te=o(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-73j9ky"&&(te.innerHTML=il),rt=i(e),le=o(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-1axkw64"&&(le.innerHTML=sl),mt=i(e),h(J.$$.fragment,e),dt=i(e),ne=o(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-dzonf1"&&(ne.innerHTML=ol),pt=i(e),ae=o(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-fkwvyv"&&(ae.innerHTML=rl),ut=i(e),h(ie.$$.fragment,e),ft=i(e),se=o(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-1181vy7"&&(se.innerHTML=ml),ht=i(e),h(oe.$$.fragment,e),gt=i(e),h(re.$$.fragment,e),bt=i(e),me=o(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-1v49o0l"&&(me.textContent=dl),ct=i(e),de=o(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-qxi4v1"&&(de.textContent=pl),wt=i(e),pe=o(e,"P",{"data-svelte-h":!0}),r(pe)!=="svelte-1esi2jc"&&(pe.innerHTML=ul),yt=i(e),ue=o(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-z54bvc"&&(ue.innerHTML=fl),$t=i(e),fe=o(e,"P",{"data-svelte-h":!0}),r(fe)!=="svelte-1xd6b55"&&(fe.textContent=hl),Mt=i(e),h(he.$$.fragment,e),xt=i(e),h(ge.$$.fragment,e),vt=i(e),be=o(e,"P",{"data-svelte-h":!0}),r(be)!=="svelte-1l7sm6m"&&(be.textContent=gl),Tt=i(e),h(ce.$$.fragment,e),Jt=i(e),we=o(e,"PRE",{"data-svelte-h":!0}),r(we)!=="svelte-czhhw9"&&(we.textContent=bl),Ct=i(e),h(ye.$$.fragment,e),kt=i(e),$e=o(e,"PRE",{"data-svelte-h":!0}),r($e)!=="svelte-13j10yu"&&($e.textContent=cl),Ut=i(e),h(Me.$$.fragment,e),It=i(e),xe=o(e,"P",{"data-svelte-h":!0}),r(xe)!=="svelte-hu2ihj"&&(xe.textContent=wl),Lt=i(e),ve=o(e,"P",{"data-svelte-h":!0}),r(ve)!=="svelte-8meymn"&&(ve.textContent=yl),_t=i(e),h(Te.$$.fragment,e),jt=i(e),Je=o(e,"P",{"data-svelte-h":!0}),r(Je)!=="svelte-5ludxz"&&(Je.textContent=$l),Gt=i(e),h(Ce.$$.fragment,e),Zt=i(e),ke=o(e,"P",{"data-svelte-h":!0}),r(ke)!=="svelte-1qo1u1t"&&(ke.innerHTML=Ml),Wt=i(e),h(Ue.$$.fragment,e),Bt=i(e),Ie=o(e,"P",{"data-svelte-h":!0}),r(Ie)!=="svelte-aaxqx0"&&(Ie.textContent=xl),Rt=i(e),h(Le.$$.fragment,e),Ht=i(e),_e=o(e,"P",{}),Xt(_e).forEach(l),this.h()},h(){At(p,"name","hf:doc:metadata"),At(p,"content",Yl)},m(e,t){Gl(document.head,p),n(e,w,t),n(e,x,t),n(e,c,t),g(u,e,t),n(e,M,t),g(v,e,t),n(e,je,t),n(e,C,t),n(e,Ge,t),g(k,e,t),n(e,Ze,t),n(e,U,t),n(e,We,t),n(e,I,t),n(e,Be,t),g(L,e,t),n(e,Re,t),n(e,_,t),n(e,He,t),g(j,e,t),n(e,Ve,t),n(e,G,t),n(e,Xe,t),n(e,Z,t),n(e,Ae,t),g(W,e,t),n(e,qe,t),n(e,B,t),n(e,Ye,t),g(R,e,t),n(e,Pe,t),g(H,e,t),n(e,Fe,t),g(V,e,t),n(e,Ee,t),n(e,X,t),n(e,Se,t),n(e,A,t),n(e,Qe,t),n(e,q,t),n(e,ze,t),g(Y,e,t),n(e,Ne,t),g(P,e,t),n(e,De,t),n(e,F,t),n(e,Oe,t),n(e,E,t),n(e,Ke,t),n(e,S,t),n(e,et,t),g(Q,e,t),n(e,tt,t),n(e,z,t),n(e,lt,t),n(e,N,t),n(e,nt,t),g(D,e,t),n(e,at,t),n(e,O,t),n(e,it,t),n(e,K,t),n(e,st,t),g(ee,e,t),n(e,ot,t),n(e,te,t),n(e,rt,t),n(e,le,t),n(e,mt,t),g(J,e,t),n(e,dt,t),n(e,ne,t),n(e,pt,t),n(e,ae,t),n(e,ut,t),g(ie,e,t),n(e,ft,t),n(e,se,t),n(e,ht,t),g(oe,e,t),n(e,gt,t),g(re,e,t),n(e,bt,t),n(e,me,t),n(e,ct,t),n(e,de,t),n(e,wt,t),n(e,pe,t),n(e,yt,t),n(e,ue,t),n(e,$t,t),n(e,fe,t),n(e,Mt,t),g(he,e,t),n(e,xt,t),g(ge,e,t),n(e,vt,t),n(e,be,t),n(e,Tt,t),g(ce,e,t),n(e,Jt,t),n(e,we,t),n(e,Ct,t),g(ye,e,t),n(e,kt,t),n(e,$e,t),n(e,Ut,t),g(Me,e,t),n(e,It,t),n(e,xe,t),n(e,Lt,t),n(e,ve,t),n(e,_t,t),g(Te,e,t),n(e,jt,t),n(e,Je,t),n(e,Gt,t),g(Ce,e,t),n(e,Zt,t),n(e,ke,t),n(e,Wt,t),g(Ue,e,t),n(e,Bt,t),n(e,Ie,t),n(e,Rt,t),g(Le,e,t),n(e,Ht,t),n(e,_e,t),Vt=!0},p(e,[t]){const vl={};t&2&&(vl.$$scope={dirty:t,ctx:e}),J.$set(vl)},i(e){Vt||(m(u.$$.fragment,e),m(v.$$.fragment,e),m(k.$$.fragment,e),m(L.$$.fragment,e),m(j.$$.fragment,e),m(W.$$.fragment,e),m(R.$$.fragment,e),m(H.$$.fragment,e),m(V.$$.fragment,e),m(Y.$$.fragment,e),m(P.$$.fragment,e),m(Q.$$.fragment,e),m(D.$$.fragment,e),m(ee.$$.fragment,e),m(J.$$.fragment,e),m(ie.$$.fragment,e),m(oe.$$.fragment,e),m(re.$$.fragment,e),m(he.$$.fragment,e),m(ge.$$.fragment,e),m(ce.$$.fragment,e),m(ye.$$.fragment,e),m(Me.$$.fragment,e),m(Te.$$.fragment,e),m(Ce.$$.fragment,e),m(Ue.$$.fragment,e),m(Le.$$.fragment,e),Vt=!0)},o(e){d(u.$$.fragment,e),d(v.$$.fragment,e),d(k.$$.fragment,e),d(L.$$.fragment,e),d(j.$$.fragment,e),d(W.$$.fragment,e),d(R.$$.fragment,e),d(H.$$.fragment,e),d(V.$$.fragment,e),d(Y.$$.fragment,e),d(P.$$.fragment,e),d(Q.$$.fragment,e),d(D.$$.fragment,e),d(ee.$$.fragment,e),d(J.$$.fragment,e),d(ie.$$.fragment,e),d(oe.$$.fragment,e),d(re.$$.fragment,e),d(he.$$.fragment,e),d(ge.$$.fragment,e),d(ce.$$.fragment,e),d(ye.$$.fragment,e),d(Me.$$.fragment,e),d(Te.$$.fragment,e),d(Ce.$$.fragment,e),d(Ue.$$.fragment,e),d(Le.$$.fragment,e),Vt=!1},d(e){e&&(l(w),l(x),l(c),l(M),l(je),l(C),l(Ge),l(Ze),l(U),l(We),l(I),l(Be),l(Re),l(_),l(He),l(Ve),l(G),l(Xe),l(Z),l(Ae),l(qe),l(B),l(Ye),l(Pe),l(Fe),l(Ee),l(X),l(Se),l(A),l(Qe),l(q),l(ze),l(Ne),l(De),l(F),l(Oe),l(E),l(Ke),l(S),l(et),l(tt),l(z),l(lt),l(N),l(nt),l(at),l(O),l(it),l(K),l(st),l(ot),l(te),l(rt),l(le),l(mt),l(dt),l(ne),l(pt),l(ae),l(ut),l(ft),l(se),l(ht),l(gt),l(bt),l(me),l(ct),l(de),l(wt),l(pe),l(yt),l(ue),l($t),l(fe),l(Mt),l(xt),l(vt),l(be),l(Tt),l(Jt),l(we),l(Ct),l(kt),l($e),l(Ut),l(It),l(xe),l(Lt),l(ve),l(_t),l(jt),l(Je),l(Gt),l(Zt),l(ke),l(Wt),l(Bt),l(Ie),l(Rt),l(Ht),l(_e)),l(p),b(u,e),b(v,e),b(k,e),b(L,e),b(j,e),b(W,e),b(R,e),b(H,e),b(V,e),b(Y,e),b(P,e),b(Q,e),b(D,e),b(ee,e),b(J,e),b(ie,e),b(oe,e),b(re,e),b(he,e),b(ge,e),b(ce,e),b(ye,e),b(Me,e),b(Te,e),b(Ce,e),b(Ue,e),b(Le,e)}}}const Yl='{"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":"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 Pl(y){return _l(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zl extends Jl{constructor(p){super(),Cl(this,p,Pl,ql,Tl,{})}}export{zl as component};
