Live Link - https://prabhjotschugh-genai-doc-qna.onrender.com/
Document QnA using Langchain is a robust solution designed to enable question answering on textual documents, employing advanced natural language processing techniques. This project integrates OpenAI's embedding model for semantic understanding, FAISS library for efficient similarity searches, and Langchain's pre-trained question answering models.
-
Embedding Generation: OpenAI's embedding model is utilized to generate numerical representations of words and phrases from textual data. These embeddings capture the semantic meaning of the text, facilitating accurate understanding of context.
-
Search Index Creation: The solution organizes the generated embeddings into a search index using the FAISS library. This index structure enables rapid and efficient similarity searches, enhancing the retrieval of relevant information from the document.
-
Question Answering Model: Langchain's pre-trained question answering models are seamlessly integrated into the solution. These models are adept at comprehending questions and extracting precise answers from the provided textual context.
-
Query Execution: Users can input their questions into the system, which then executes queries against the search index using the loaded question answering model. This process matches the query with relevant embeddings in the index to retrieve context-aware answers promptly.
app-openai.py
: Contains the implementation of the question answering system using OpenAI's models.app.py
: Implements the question answering system using open-source models.index.html
: HTML template for the frontend interface.styles.css
: CSS styles for the frontend interface.
To run the application:
-
Clone the repository:
git clone https://github.com/prabhjotschugh/Doc-QnA-using-Langchain cd document-qna-using-langchain
-
Install the required Python packages:
pip install -r req.txt
-
Set your OpenAI API key (if using OpenAI's model):
export OPENAI_API_KEY="your-openai-api-key"
-
Set your HuggingFace API key (if using open-source models):
export HUGGINGFACEHUB_API_TOKEN="your-huggingface-api-key"
-
Start the Flask app:
python app.py
-
Open your web browser and navigate to
http://127.0.0.1:5000/
to access the application.