<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bookshelf on Ash Tewari</title><link>https://www.tewari.info/tag/bookshelf/</link><description>Recent content in Bookshelf on Ash Tewari</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Mon, 31 Mar 2025 02:29:39 +0000</lastBuildDate><atom:link href="https://www.tewari.info/tag/bookshelf/feed.xml" rel="self" type="application/rss+xml"/><item><title>Understanding RAG @ All Things Open AI 2025</title><link>https://www.tewari.info/2025/03/30/understanding-rag-all-things-open-ai-2025/</link><pubDate>Mon, 31 Mar 2025 02:29:39 +0000</pubDate><guid>https://www.tewari.info/2025/03/30/understanding-rag-all-things-open-ai-2025/</guid><description>&lt;p&gt;&lt;strong&gt;What I learned while creating Bookshelf (open source RAG Application)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;I had the opportunity to speak at the &lt;a class="link" href="https://allthingsopen.ai/" target="_blank" rel="noopener"&#10; &gt;AllThingsOpen.ai 2025 Conference&lt;/a&gt; recently. It was a wonderful experience to learn from and share with so many amazing fellow presenters and attendees. All Things Open AI 2025 session recordings are available now.&lt;/p&gt;&#10;&lt;p&gt;I spoke about several key aspects of Retrieval-Augmented Generation (RAG) and vector databases. The main topics I addressed included The Core Concepts of RAG, Embedding Models vs. Inference Models, Handling Multiple Embeddings and various Optimizations Beyond Naive RAG such as chunking strategies, enrichment with metadata, auto-merging retriever, and reranking models. Finally, I touched on Local Execution and GPU Utilization.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/ato-ai-2025-bookshelf-rag-ash-slide01.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;You can watch the recording here: &lt;a class="link" href="https://youtu.be/vWrG8whSHwk?si=CJg0qlb5FwTU9w7y" target="_blank" rel="noopener"&#10; &gt;YouTube - How I created Bookshelf: An Open Source AI-Powered Personal Knowledge Base - Ash Tewari&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The slides can be downloaded from here: (&lt;a class="link" href="https://drive.google.com/drive/folders/1SSceCPGBytJ7B4nP2kQyX_DPpP6iHenH?usp=sharing" target="_blank" rel="noopener"&#10; &gt;Google Drive Link&lt;/a&gt;)&lt;/p&gt;&#10;&lt;p&gt;References and Links:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;AI Powered Bookshelf - &lt;a class="link" href="https://www.tewari.info/2024/04/28/ai-powered-bookshelf/" &gt;Blog Post&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;HuggingFace - &lt;a class="link" href="https://huggingface.co/spaces/mteb/leaderboard" target="_blank" rel="noopener"&#10; &gt;MTEB Leaderboard&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;PyTorch - &lt;a class="link" href="https://pytorch.org/get-started/locally/" target="_blank" rel="noopener"&#10; &gt;Local Execution&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://ai.plainenglish.io/a-brief-introduction-to-retrieval-augmented-generation-rag-b7eb70982891" target="_blank" rel="noopener"&#10; &gt;Medium - A Brief Introduction to Retrieval Augmented Generation(RAG)&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;[Microsoft - RAG Architecture](http://Design and develop a RAG solution)&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://docs.aws.amazon.com/sagemaker/latest/dg/jumpstart-foundation-models-customize-rag.html" target="_blank" rel="noopener"&#10; &gt;Amazon - Retrieval Augmented Generation&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;</description></item><item><title>AI Powered Bookshelf</title><link>https://www.tewari.info/2024/04/28/ai-powered-bookshelf/</link><pubDate>Mon, 29 Apr 2024 00:25:55 +0000</pubDate><guid>https://www.tewari.info/2024/04/28/ai-powered-bookshelf/</guid><description>&lt;p&gt;Bookshelf is a Generative AI application built as a rudimentary, but fairly capable, &lt;a class="link" href="https://docs.llamaindex.ai/en/stable/use_cases/q_and_a/" target="_blank" rel="noopener"&#10; &gt;RAG&lt;/a&gt; implementation written in &lt;a class="link" href="https://www.python.org/doc/" target="_blank" rel="noopener"&#10; &gt;python&lt;/a&gt;. It can use an open source LLM model (running locally or in the cloud) or a GPT model via OpenAI&amp;rsquo;s API.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;The application is created using &lt;a class="link" href="https://streamlit.io/" target="_blank" rel="noopener"&#10; &gt;streamlit&lt;/a&gt;.&lt;/li&gt;&#10;&lt;li&gt;I used &lt;a class="link" href="https://www.llamaindex.ai/" target="_blank" rel="noopener"&#10; &gt;llama-index&lt;/a&gt; for orchestrating the loading of documents into the &lt;a class="link" href="https://en.wikipedia.org/wiki/Vector_database" target="_blank" rel="noopener"&#10; &gt;vector database&lt;/a&gt;. Only TokenTextSplitter is currently used. It does not optimize for PDF, html and other formats.&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://www.trychroma.com/" target="_blank" rel="noopener"&#10; &gt;ChromaDb&lt;/a&gt; is the vector database to store the embedding vectors and metadata of the document nodes.&lt;/li&gt;&#10;&lt;li&gt;You can use any open source embeddings model from &lt;a class="link" href="https://huggingface.co/models?other=embeddings" target="_blank" rel="noopener"&#10; &gt;HuggingFace&lt;/a&gt;.&lt;/li&gt;&#10;&lt;li&gt;Bookshelf will automatically use the GPU when creating local embeddings, if the GPU is available on your machine.&lt;/li&gt;&#10;&lt;li&gt;You can use &lt;a class="link" href="https://platform.openai.com/docs/guides/embeddings" target="_blank" rel="noopener"&#10; &gt;OpenAI embeddings&lt;/a&gt; as well. There is no way to use a specific OpenAI embedding model or configure the parameters yet.&lt;/li&gt;&#10;&lt;li&gt;Use OpenAI API or any OpenAI compatible LLM API (using &lt;a class="link" href="https://lmstudio.ai/" target="_blank" rel="noopener"&#10; &gt;LMStudio&lt;/a&gt;, &lt;a class="link" href="https://ollama.com/" target="_blank" rel="noopener"&#10; &gt;Ollama&lt;/a&gt; or &lt;a class="link" href="https://github.com/oobabooga/text-generation-webui" target="_blank" rel="noopener"&#10; &gt;text-generation-webui&lt;/a&gt;) of your choice.&lt;/li&gt;&#10;&lt;li&gt;There is a live demo on streamlit cloud - &lt;a class="link" href="https://bookshelf.streamlit.app/" target="_blank" rel="noopener"&#10; &gt;https://bookshelf.streamlit.app/&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;The demo allows only OpenAI integration. You can run it locally for accessing Open Source embedding models and LLMs.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;Live demo - &lt;a class="link" href="https://bookshelf.streamlit.app/" target="_blank" rel="noopener"&#10; &gt;https://bookshelf.streamlit.app/&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;You will need your OpenAI api key for the demo.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-39.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;If you are running it locally, you will have the option of using an Open Source LLM instance via an API Url. In the screenshot, I am using an open source Embedding Model from HuggingFace (sentence-transformers/all-mpnet-base-v2) and The local LLM server at http://localhost:1234/v1&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-40.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;Collections tab shows all collections in the database. It also shows the names of all the files in the selected collection. You can inspect individual chunks for the metadata and text of each chunk. You can delete all contents of the collection &lt;strong&gt;(&lt;/strong&gt; &lt;strong&gt;there is no warning&lt;/strong&gt; &lt;strong&gt;)&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-38.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;You can modify the collection name to create a new collection. Multiple files can be uploaded at the same time. You can specify if you want to extract metadata from the file contents. &lt;strong&gt;Enabling this option can add significant cost&lt;/strong&gt; because it employs Extractors which use LLM to generate title, summaries, keywords and questions for each document.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-41.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;On the Retrieve tab, you can query chunks which are semantically related to your query.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-43.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;On the Prompt tab, you can prompt your LLM. The context as well as the Prompt Template is editable.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-44.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;Here is an example of using the context retrieved from chunks in the Vector database to query the LLM.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-45.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;This inference was performed using &lt;a class="link" href="https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf" target="_blank" rel="noopener"&#10; &gt;Phi3&lt;/a&gt; model running locally on LMStudio.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-46.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;Code is on Github - &lt;a class="link" href="https://github.com/ashtewari/bookshelf" target="_blank" rel="noopener"&#10; &gt;https://github.com/ashtewari/bookshelf&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Have fun!&lt;/p&gt;&#10;</description></item></channel></rss>