hardkpentium101 commited on
Commit
e7a70f5
·
1 Parent(s): 2d51ea8

update readme and setup md

Browse files
Files changed (2) hide show
  1. README.md +12 -89
  2. setup.md +89 -0
README.md CHANGED
@@ -1,89 +1,12 @@
1
- # Hindi RAG System - Fixed
2
-
3
- This repository contains a Hindi RAG (Retrieval-Augmented Generation) system that allows users to search and ask questions about Hindi poems and stories. The system was experiencing an issue with meta tensors during initialization, which has now been fixed.
4
-
5
- ## Issue Fixed
6
-
7
- **Problem**: `Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.`
8
-
9
- **Solution**:
10
- 1. Updated the `llm_manager.py` to properly handle model initialization and avoid meta tensor issues
11
- 2. Updated the `embedding_generator.py` to check for meta tensors and use `to_empty()` method when needed
12
- 3. Added proper error handling for meta tensor cases
13
-
14
- ## Prerequisites
15
-
16
- - Python 3.8+
17
- - Virtual environment (recommended)
18
-
19
- ## Setup Instructions
20
-
21
- 1. **Clone the repository** (if you haven't already):
22
- ```bash
23
- git clone <repository-url>
24
- cd hindi_rag
25
- ```
26
-
27
- 2. **Create and activate a virtual environment**:
28
- ```bash
29
- python -m venv venv
30
- source venv/bin/activate # On Windows: venv\Scripts\activate
31
- ```
32
-
33
- 3. **Install dependencies**:
34
- ```bash
35
- pip install transformers torch qdrant-client langchain-huggingface openai python-dotenv
36
- ```
37
-
38
- 4. **Set up Qdrant**:
39
- - Option 1: Install and run Qdrant locally (follow instructions at https://qdrant.tech/documentation/quick-start/)
40
- - Option 2: Use Qdrant Cloud (update `.env` with your credentials)
41
-
42
- 5. **Configure environment variables** (if needed):
43
- - Copy `.env.example` to `.env` and update values as needed
44
-
45
- 6. **Prepare data**:
46
- - Place your Hindi literature data in the `data/` directory in JSON format
47
- - Sample format: `{"title": "...", "author": "...", "text": "...", "genre": "..."}`
48
-
49
- ## Running the Application
50
-
51
- 1. **Start Qdrant** (if running locally):
52
- ```bash
53
- # Follow Qdrant startup instructions
54
- # Usually: docker run -p 6333:6333 qdrant/qdrant
55
- ```
56
-
57
- 2. **Run the Streamlit application**:
58
- ```bash
59
- streamlit run frontend/app.py
60
- ```
61
-
62
- 3. **Access the application**:
63
- - Open your browser and go to `http://localhost:8080` (or as displayed in the terminal)
64
-
65
- ## Key Files Modified
66
-
67
- - `src/llm_manager.py`: Fixed meta tensor issue during model initialization
68
- - `src/embedding_generator.py`: Added meta tensor handling for embedding models
69
- - Both files now properly handle the transition from meta tensors to actual device tensors
70
-
71
- ## Features
72
-
73
- - Hindi literature search and question answering
74
- - Support for poems, stories, and other literary forms
75
- - Multilingual embedding support
76
- - Local LLM inference with fallback options
77
- - Streamlit-based user interface
78
-
79
- ## Troubleshooting
80
-
81
- If you encounter issues:
82
- 1. Make sure Qdrant is running and accessible
83
- 2. Verify your environment variables in `.env`
84
- 3. Check that all dependencies are installed
85
- 4. Ensure your data files are in the correct format in the `data/` directory
86
-
87
- ## Contributing
88
-
89
- Feel free to submit issues and enhancement requests. Pull requests are welcome!
 
1
+ ---
2
+ title: HindiRAG
3
+ emoji: 😻
4
+ colorFrom: pink
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 6.3.0
8
+ app_file: frontend/app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
setup.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hindi RAG System - Fixed
2
+
3
+ This repository contains a Hindi RAG (Retrieval-Augmented Generation) system that allows users to search and ask questions about Hindi poems and stories. The system was experiencing an issue with meta tensors during initialization, which has now been fixed.
4
+
5
+ ## Issue Fixed
6
+
7
+ **Problem**: `Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.`
8
+
9
+ **Solution**:
10
+ 1. Updated the `llm_manager.py` to properly handle model initialization and avoid meta tensor issues
11
+ 2. Updated the `embedding_generator.py` to check for meta tensors and use `to_empty()` method when needed
12
+ 3. Added proper error handling for meta tensor cases
13
+
14
+ ## Prerequisites
15
+
16
+ - Python 3.8+
17
+ - Virtual environment (recommended)
18
+
19
+ ## Setup Instructions
20
+
21
+ 1. **Clone the repository** (if you haven't already):
22
+ ```bash
23
+ git clone <repository-url>
24
+ cd hindi_rag
25
+ ```
26
+
27
+ 2. **Create and activate a virtual environment**:
28
+ ```bash
29
+ python -m venv venv
30
+ source venv/bin/activate # On Windows: venv\Scripts\activate
31
+ ```
32
+
33
+ 3. **Install dependencies**:
34
+ ```bash
35
+ pip install transformers torch qdrant-client langchain-huggingface openai python-dotenv
36
+ ```
37
+
38
+ 4. **Set up Qdrant**:
39
+ - Option 1: Install and run Qdrant locally (follow instructions at https://qdrant.tech/documentation/quick-start/)
40
+ - Option 2: Use Qdrant Cloud (update `.env` with your credentials)
41
+
42
+ 5. **Configure environment variables** (if needed):
43
+ - Copy `.env.example` to `.env` and update values as needed
44
+
45
+ 6. **Prepare data**:
46
+ - Place your Hindi literature data in the `data/` directory in JSON format
47
+ - Sample format: `{"title": "...", "author": "...", "text": "...", "genre": "..."}`
48
+
49
+ ## Running the Application
50
+
51
+ 1. **Start Qdrant** (if running locally):
52
+ ```bash
53
+ # Follow Qdrant startup instructions
54
+ # Usually: docker run -p 6333:6333 qdrant/qdrant
55
+ ```
56
+
57
+ 2. **Run the Streamlit application**:
58
+ ```bash
59
+ streamlit run frontend/app.py
60
+ ```
61
+
62
+ 3. **Access the application**:
63
+ - Open your browser and go to `http://localhost:8080` (or as displayed in the terminal)
64
+
65
+ ## Key Files Modified
66
+
67
+ - `src/llm_manager.py`: Fixed meta tensor issue during model initialization
68
+ - `src/embedding_generator.py`: Added meta tensor handling for embedding models
69
+ - Both files now properly handle the transition from meta tensors to actual device tensors
70
+
71
+ ## Features
72
+
73
+ - Hindi literature search and question answering
74
+ - Support for poems, stories, and other literary forms
75
+ - Multilingual embedding support
76
+ - Local LLM inference with fallback options
77
+ - Streamlit-based user interface
78
+
79
+ ## Troubleshooting
80
+
81
+ If you encounter issues:
82
+ 1. Make sure Qdrant is running and accessible
83
+ 2. Verify your environment variables in `.env`
84
+ 3. Check that all dependencies are installed
85
+ 4. Ensure your data files are in the correct format in the `data/` directory
86
+
87
+ ## Contributing
88
+
89
+ Feel free to submit issues and enhancement requests. Pull requests are welcome!