Chat with Complex PDF Using IBM WatsonX, LlamaParser, Langchain and ChromaDB 📚 (Using LlamaParse for RAG Applications with LlamaIndex)
🚀 Chat seamlessly with complex PDF (with texts and tables) using IBM WatsonX, LlamaParser, Langchain & ChromaDB Vector DB with Seamless Streamlit Deployment. Get instant, Accurate responses from Awesome IBM WatsonX Language Model. 📚💬 Transform your PDF experience now! 🔥✨
This PDF Chat Agent is a Streamlit-based web application designed to facilitate interactive conversations with a chatbot. The app allows users to upload complex PDF document(with text and complex tables), extract markdown information from them, and train a chatbot using this extracted content. Users can then engage in real-time conversations with the chatbot.
The application follows these steps to create supirior RAG pipeline to provide responses to your questions:
-
PDF Loading and Parsing : The app reads PDF document and parse it to markdown using LlamaParse.
LlamaParse
is an API created byLlamaIndex
to efficiently parse and represent files for efficient retrieval and context augmentation using LlamaIndex frameworks. It seamlessly integrates with the advanced indexing/retrieval capabilities that the open-source framework offers, enabling users to build state-of-the-art document RAG. -
Create VectorStoreIndex : Extract
base_nodes
andobjects
to createVectorStoreIndex
-
Build Recursive Query Engine : Build recursive retrieval/query engine using
MarkdownElementNodeParser
for parsing the LlamaParse output markdown results. It does this in 2 steps,- Initalize our reranker using
FlagEmbeddingReranker
powered by theBAAI/bge-reranker-large
. We'll be leveraging this repo to leverage ourBAAI/bge-reranker-large
. - Set up our recursive query engine!
- Initalize our reranker using
-
Response Generation : Generate reponse for the user prompt by querying the vector index using query engine.
-
Built with IBM WatsonX API and Langchain Extension: Yes! you heard it right.. this app is build using
IBM WatsonX Generative AI API
andLangchain
extension to create LLM and Embeddings. There is no OOTB support for IBM WatsonX API in LlamaParse. This app is developed to leverage parsing capabilities of LlamaParse with IBM WatsonX. -
Supports LlamaIndex V0.10: What is unique and special about this?? IBM WatsonX LlamaIndex extension still uses
LlamaIndex V0.9
.LlamaIndex V0.10
has several major changes, and one of the key changes is the replacement ofServiceContext
withSettings
. If you try to use LlamaParse (which uses LlamaIndex V0.10) along with IBM WatsonX LlamaIndex extension, it will not work. -
Parsing PDF to Markdown using IBM WatsonX LLM: This is an important. LlamaIndex
MarkdownElementNodeParser
usesOPENAI Pydentic
under the hood. So it was breaking for some of the tables when using WatsonX LLM. To fix this, I modified theBaseElementNodeParser
so that I can pass LLM as None and disable table summary option. Creating sumamry takes lot of time and it breakes for some table when using WatsonX LLM. -
ChromaDB as Vector Store: It uses
ChromaDB
as VectorStore to persist the data.
Clone the repository:
git clone https://github.com/IBM/watsonx-chat-complex-pdf-LlamaParser.git
Install the required Python packages:
pip install -r requirements.txt
Set up your WatsonX API key from https://bam.res.ibm.com/
Set up your LlamaCloud API key from https://cloud.llamaindex.ai/
Run the Streamlit app:
streamlit run chatbot.py
Distributed under the MIT License. See LICENSE
for more information.