Spaces:
Sleeping
Sleeping
File size: 3,385 Bytes
4cf0e20 af8b652 693d949 4cf0e20 693d949 4cf0e20 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 693d949 af8b652 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
---
title: "Paper-based RAG"
emoji: "π"
colorFrom: "blue"
colorTo: "indigo"
sdk: gradio
sdk_version: 5.8.0
app_file: app.py
python_version: 3.11.0
models:
- sentence-transformers/all-mpnet-base-v2
tags:
- question-answering
- gradio
- LLM
- document-processing
---
# Document QA System
Document Question-Answering system that utilizes LlamaIndex for document indexing, generation, and retrieval and Gradio for the user interface.
## Technologies
- Data source
- [Paper about BERT](https://arxiv.org/pdf/1810.04805) located in the data directory are used as the data source for indexing.
- Chunking
- Document chunking is handled by [all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
- LLM
- The system utilizes the `gpt-4o-mini` for generating responses
- Retriever, Reranker
- gpt-4o-mini is used
- UI
- The user interface is built with Gradio
## Installation
### Prerequisites
1. **Docker**:
- [Install Docker](https://docs.docker.com/get-docker/)
2. **API keys**
- [OpenAI](https://platform.openai.com/api-keys)
- [LLamaParse](https://docs.cloud.llamaindex.ai/llamaparse/getting_started/get_an_api_key):
### Using HuggingFace Spaces
1. Follow the link to the [paper-based-rag](https://huggingface.co/spaces/Gepe55o/paper_based_rag) on Spaces.
2. Upload your paper for indexing or use the default [paper](https://arxiv.org/pdf/1810.04805) about BERT.
### Using Docker
1. **Build the Docker Image**:
```bash
docker build -t doc-qa-system .
```
2. **Run the Docker Container**:
```bash
docker run -p 7860:7860 doc-qa-system
```
4. **Access the Interface**:
- Open your browser and go to `http://localhost:7860`.
### Using Python
1. **Install Dependencies**:
```bash
pip install -r requirements.txt
```
2. **Add paper to the data directory**:
- Add the paper you want to index to the `data` directory or use default [paper](https://arxiv.org/pdf/1810.04805) about BERT.
2. **Run indexing data**:
```bash
python index.py
```
3. **Run the Application**:
```bash
python app.py
```
## Project structure
```bash
βββ app.py # Gradio application
βββ main.py # Main script for answering queries
βββ utils/ # Utility functions and helpers
β βββ constant.py # Constant values used in the project
β βββ index.py # Handles document indexing
β βββ retriever.py # Retrieves and ranks documents
β βββ settings.py # Configuration settings
βββ data/ # Directory containing documents to be indexed
βββ index/ # Stores the generated index files
β βββ default__vector_store.json
β βββ docstore.json
β βββ graph_store.json
β βββ image__vector_store.json
β βββ index_store.json
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ README.md # Project documentation
```
## Example questions
- What is the pre-training procedure for BERT, and how does it differ from traditional supervised learning?
- Can you describe how BERT can be fine-tuned for tasks like question answering or sentiment analysis? |