|
1 | 1 | # FastRAG
|
2 |
| -A simple RAG application that is optimized to run fast on general grade PCs |
3 | 2 |
|
| 3 | +FastRAG is a simple Retrieval-Augmented Generation (RAG) application optimized for fast performance on general-grade PCs. It provides a chatbot interface that leverages vector-based search and large language models (LLMs) for answering questions and interacting with document-based data. |
4 | 4 |
|
5 |
| -# TODO |
6 |
| -- [ ] Make stubbs test |
| 5 | +--- |
7 | 6 |
|
| 7 | +### 🚀 Launch API and Demo Locally |
8 | 8 |
|
9 |
| -`pip install llama-index-embeddings-huggingface` may install unnecessary nvidia-cuda libraries be careful to install cpuonly stuffs |
| 9 | +To get started with FastRAG locally, follow these steps: |
10 | 10 |
|
| 11 | +1. Clone the repository: |
| 12 | + ```bash |
| 13 | + git clone https://github.com/bibekyess/FastRAG.git |
| 14 | + ``` |
| 15 | + |
| 16 | +2. Navigate to the project directory: |
| 17 | + ```bash |
| 18 | + cd FastRAG |
| 19 | + ``` |
| 20 | + |
| 21 | +3. Build and launch the containers: |
| 22 | + ```bash |
| 23 | + docker compose up --build |
| 24 | + ``` |
| 25 | + |
| 26 | +This will start the FastRAG API and demo with all necessary services. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +### 🛠️ API Endpoints |
| 31 | + |
| 32 | +The FastRAG application launches several API endpoints for different purposes: |
| 33 | + |
| 34 | +1. **Get Conversation History** |
| 35 | + - **Method**: `GET` |
| 36 | + - **Endpoint**: `/conversation-history` |
| 37 | + - **Parameters**: |
| 38 | + - `collection_name` (str): Name of the collection to fetch history from. |
| 39 | + - `limit` (int): Number of history entries to return. Default is 10. |
| 40 | + |
| 41 | +2. **Add to Conversation History** |
| 42 | + - **Method**: `POST` |
| 43 | + - **Endpoint**: `/conversation-history` |
| 44 | + - **Body**: |
| 45 | + - `collection_name` (str): Name of the collection to fetch history from. |
| 46 | + - `query` (str): User input query |
| 47 | + - `response_text` (str): AI response |
| 48 | + |
| 49 | +3. **Parse Document** |
| 50 | + - **Method**: `POST` |
| 51 | + - **Endpoint**: `/parse` |
| 52 | + - **Parameters**: |
| 53 | + - `file` (UploadFile): The document to be parsed. |
| 54 | + - `index_id` (str): Index name for the document. Default is `files`. |
| 55 | + - `splitting_type` (Literal['raw', 'md']): Splitting type for the document. Default is `raw` (based on chunk settings). |
| 56 | + |
| 57 | +4. **Chat with the Bot** |
| 58 | + - **Method**: `POST` |
| 59 | + - **Endpoint**: `/chat` |
| 60 | + - **Body**: |
| 61 | + - `user_input` (str): The user's query. |
| 62 | + - `index_id` (str): The index to search. Default is `"files"`. |
| 63 | + - `llm_text` (str): The LLM model to use. Default is `"local"`. |
| 64 | + - `dense_top_k` (int): The number of top results to return from the vector search. Default is 5. |
| 65 | + - `upgrade_user_input` (bool): Flag to indicate whether to upgrade the user input from conversation history. Default is `False`. |
| 66 | + - `stream` (bool): Flag to enable streaming of results. Default is `True`. |
| 67 | + |
| 68 | + |
| 69 | +### 🖥️ User Interface |
| 70 | + |
| 71 | +- **Gradio UI**: FastRAG features a simple Gradio-based user interface for interacting with the chatbot. |
| 72 | +- **Real-time Chat**: Users can upload a document and ask questions in real-time, with previous conversations stored and utilized for context-based improvements. [Providing the option to upload document is in progress] |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +### 🗃️ Storage and Database |
| 77 | + |
| 78 | +- **QdrantDB**: The vector embeddings and chatbot conversation history are stored in QdrantDB. This allows the chatbot to utilize previous conversation context for improved responses. |
| 79 | +--- |
| 80 | + |
| 81 | +### ⚡ Model Backend |
| 82 | + |
| 83 | +- **Model**: [bartowski/Llama-3.2-3B-Instruct-GGUF](https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF) |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +### ⏱️ Latency Tracking |
| 88 | + |
| 89 | +- **UI Display**: Latency of the chatbot's response is displayed in the Gradio interface. |
| 90 | +- **Logging**: Detailed logs of latency and other events are saved for debugging and performance monitoring. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | + |
| 95 | +### 🧾 Document Parsing Options |
| 96 | + |
| 97 | +FastRAG offers multiple options for segmenting documents into chunks: |
| 98 | + |
| 99 | +1. **Raw Format**: This option allows experimenting with various chunk sizes, strides, and overlapping settings for raw text parsing. |
| 100 | +2. **Markdown Format**: This method segments the document based on semantic information, creating more context-aware chunks. |
| 101 | + |
| 102 | +--- |
11 | 103 |
|
0 commit comments