LLM_RAG_Langchain_Embedding_FAISS_Gradio: Retrieval-Augmented Generation (RAG) with Gradio UI, LangChain, Groq and OpenAI LLMs
This repository provides a modular, class-based Python project for Retrieval-Augmented Generation (RAG) using Gradio, LangChain, FAISS, HuggingFace embeddings, and Groq/OpenAI-compatible LLMs. It is designed for easy extension, best practices, and onboarding new LLM developers.
- File & URL Support: Upload files (PDF, DOCX, CSV, TXT, etc.) or paste a public URL for processing.
- Model Selection: Choose from multiple LLMs Like GPT, LLama and embedding models via dropdowns in the UI. All model tokens and names are read from
config.yaml. - Persistent Vectorstore: Automatically saves and loads FAISS vectorstores for each unique file or URL, enabling fast reloading and reuse.
- Chunking & Embedding: Documents are split into overlapping chunks and embedded using the selected HuggingFace model for efficient retrieval.
- Question Answering: Ask questions about the uploaded or linked content using the selected LLM.
- Gradio UI: Simple, interactive web interface for document loading, model selection, and Q&A.
- Class-based, Pythonic Design: All core logic is encapsulated in the
RAGGradioAppclass for maintainability and extensibility.
├── LLM_RAG_Langchain_Embedding_FAISS_Gradio/
│ ├── rag_gradio_llm.py # Main class-based RAG Gradio app (entry point)
│ ├── config.yaml # Model/API configuration
│ ├── chunks/ # Persistent vectorstore storage (auto-generated)
│ ├── requirements.txt # Python dependencies
│ ├── readme.md # This file
│ └── ... # Other scripts and legacy files
-
Clone the repo:
git clone <repo-url> cd LLM_RAG_Langchain_Embedding_FAISS_Gradio
-
Install dependencies:
pip install -r requirements.txt
-
Prepare
config.yaml: Example:llm_models: - name: "llama3-8b-8192" api_key: "YOUR_GROQ_API_KEY" api_base: "https://api.groq.com/openai/v1" embedding_models: - "all-MiniLM-L6-v2"
- You can add as many LLMs and embedding models as you like.
-
Run the app:
python rag_gradio_llm.py
- Upload a file or paste a URL in the Gradio interface.
- Select your LLM and embedding model from the dropdowns.
- Click Load Document(s) to process and index the content.
- Enter your question in the textbox and click Get Answer.
- The main logic is in
rag_gradio_llm.pyinside theRAGGradioAppclass. - All configuration is handled via
config.yaml. - The code is modular, with clear docstrings and comments for each method.
- You can extend the app by subclassing
RAGGradioAppor adding new methods. - Debug print statements are included to help trace LLM calls and QA chain creation.
- See the code comments for guidance on each step of the RAG pipeline.
- Fork the repo and create a feature branch.
- Follow PEP8 and use class-based, modular design.
- Add docstrings and comments for clarity.
- Submit a pull request with a clear description of your changes.
MIT
