{"id":15142598,"url":"https://github.com/younis-ali/rag-pipeline-app","last_synced_at":"2025-04-16T02:35:00.502Z","repository":{"id":257065612,"uuid":"857232241","full_name":"younis-ali/rag-pipeline-app","owner":"younis-ali","description":"Implement RAG using LangChain and HuggingFace embedding models","archived":false,"fork":false,"pushed_at":"2024-09-14T15:09:45.000Z","size":9424,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T04:12:48.757Z","etag":null,"topics":["fastapi","huggingface-embeddings","langchain","question-answering","rag","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/younis-ali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-14T05:31:02.000Z","updated_at":"2025-02-13T14:59:58.000Z","dependencies_parsed_at":"2024-09-14T17:49:09.583Z","dependency_job_id":null,"html_url":"https://github.com/younis-ali/rag-pipeline-app","commit_stats":null,"previous_names":["younis-ali/rag-pipeline-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younis-ali%2Frag-pipeline-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younis-ali%2Frag-pipeline-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younis-ali%2Frag-pipeline-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younis-ali%2Frag-pipeline-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/younis-ali","download_url":"https://codeload.github.com/younis-ali/rag-pipeline-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249184779,"owners_count":21226462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","huggingface-embeddings","langchain","question-answering","rag","streamlit"],"created_at":"2024-09-26T09:43:02.062Z","updated_at":"2025-04-16T02:35:00.483Z","avatar_url":"https://github.com/younis-ali.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAG QA Bot\n\nThis application allows users to upload PDF files, create a vector database from the document using open-source HuggingFace embeddings, and ask questions related to the PDF content using a Retrieval-Augmented Generation approach. The app integrates with LangChain Framework, OpenAI's LLM and HuggingFace embeddings.\n\n## Features\n- Upload a PDF file and save it locally. Later we can create the API to delete the old files.\n- Create a vector database from the PDF's content using HuggingFace model `sentence-transformers/all-mpnet-base-v2`\n- Ask questions about the PDF content.\n- View the context used for answering the questions that is toggleable via a checkbox.\n- The POC of RAG pipeline is tested in using `rag_pipeline.ipynb`\n\n## Screenshots of the RAG app\n\n![first](https://github.com/user-attachments/assets/4c720ae0-14ba-4829-9dff-e0ec37621aa2)\n\n![third](https://github.com/user-attachments/assets/00a9baaa-5a10-4274-9348-16d3e42ea53e)\n\n![Screenshot from 2024-09-14 20-05-29](https://github.com/user-attachments/assets/077b3d5b-60d1-4c1e-b9bb-b7d698362c29)\n\n \n\n## Installation\n### Clone the Repository\n```bash\ngit clone https://github.com/yourusername/rag-qa-bot.git\ncd rag-qa-bot\n```\n### Set up a Virtual Environment (optional but recommended)\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n### Install Dependencies\n```bash\npip install -r requirements.txt\n```\n\n### The main packages are:\n- `streamlit`: For the web UI.\n- `PyPDFLoader`: To extract content from PDF files.\n- `langchain`: For embeddings, document chunking, and question-answering.\n- `faiss-cpu`: For vector store creation and retrieval.\n- `openai`: To integrate with OpenAI's language models.\n\n## Configuration\n\nWe provide a `config.json` file in the root directory, this will allow you to select the models at your choice, with the following details:\n\n```json\n{\n  \"embedding_model\": \"sentence-transformers/all-MiniLM-L6-v2\",\n  \"openai_api_key\": \"your_openai_api_key\",\n  \"openai_model\": \"gpt-3.5-turbo\",\n  \"vector_db_path\": \"./vector_store\"\n}\n```\n## Usage\n\n### Running the App\nTo launch the Streamlit web app, run the following command in your terminal:\n\n```bash\nstreamlit run main.py\n```\nbrowse the url `http://localhost:8501/`\n\n## How It Works\n\n1. **PDF Upload**: The user uploads a PDF file using  the Streamlit file uploader.\n2. **Document Chunking**: The PDF content is split into manageable chunks using the `RecursiveCharacterTextSplitter` api fo LangChain.\n3. **Embeddings Generation**: The chunks are passed through a HuggingFace embedding model to generate embeddings.\n4. **Vector Store Creation**: The embeddings are stored in a FAISS-based vector store, which is then saved locally.\n5. **Question Answering**: When a user asks a question, the system retrieves the relevant context from the vector store and generates an answer using OpenAI's LLM.\n\n## Project Structure\n\n```bash\n|-- src/\n|   |-- utils.py             # Helper functions such as file-saving logic\n    |-- rag_application.py   # Class to implement the RAG pipeline\n|-- main.py                  # Main Streamlit app file\n|-- requirements.txt         # List of required dependencies\n|-- config.json              # Configuration file\n|-- rag_pipeline.ipynb       # Test and POC the RAG pipeline\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounis-ali%2Frag-pipeline-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyounis-ali%2Frag-pipeline-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounis-ali%2Frag-pipeline-app/lists"}