File size: 6,934 Bytes
0400df3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# πŸš€ Quick Start Guide - Collar Multimodal RAG Demo

Get your production-ready multimodal RAG system up and running in minutes!

## ⚑ 5-Minute Setup

### 1. **Install Dependencies**
```bash
pip install -r requirements.txt
```

### 2. **Start the Application**
```bash
python app.py
```

### 3. **Access the Application**
Open your browser and go to: `http://localhost:7860`

### 4. **Login with Default Users**
- **Team A**: `admin_team_a` / `admin123_team_a`
- **Team B**: `admin_team_b` / `admin123_team_b`

## 🎯 Key Features to Try

### **Enhanced Multi-Page Citations**
1. Upload multiple documents
2. Ask complex queries like: "What are the different types of explosives and their safety procedures?"
3. The system automatically detects complex queries and retrieves multiple relevant pages
4. See intelligent citations grouped by document collections with relevance scores
5. View multiple pages in the gallery display

### **Team Repository Management**
1. Login as Team A user
2. Upload documents with a collection name like "Safety Manuals"
3. Switch to Team B user - notice you can't see Team A's documents

### **Chat History**
1. Make several queries
2. Go to "πŸ’¬ Chat History" tab
3. See your conversation history with timestamps and cited pages

### **Advanced Querying**
1. Set "Number of pages to retrieve" to 5
2. Ask a complex question
3. View multiple relevant pages and AI response with citations

### **Enhanced Detailed Responses**
1. Ask any question and receive comprehensive, detailed answers
2. Get extensive background information and context
3. See step-by-step explanations and practical applications
4. Receive safety considerations and best practices
5. Get technical specifications and measurements
6. View quality assessment and recommendations for further research

### **CSV Table Generation**
1. Ask for data in table format: "Show me a table of safety procedures"
2. Request CSV data: "Create a CSV with the comparison data"
3. Get structured responses with downloadable CSV content
4. View table information including rows, columns, and data sources
5. Copy CSV content to use in Excel, Google Sheets, or other applications

## πŸ”§ Configuration

### Environment Variables (.env file)
```env
# AI Models
colpali=colpali-v1.3
ollama=llama2

# Performance
flashattn=1
temperature=0.8
batchsize=5

# Database
metrictype=IP
mnum=16
efnum=500
topk=50
```

### Customizing for Your Use Case

#### **For Large Document Collections**
```env
batchsize=10
topk=100
efnum=1000
```

#### **For Faster Processing**
```env
batchsize=2
flashattn=0
```

#### **For Higher Accuracy**
```env
temperature=0.3
topk=200
```

## πŸ“ File Structure
```
colpali-milvus-multimodal-rag-master/
β”œβ”€β”€ app.py                          # Main application
β”œβ”€β”€ requirements.txt                # Dependencies
β”œβ”€β”€ README.md                      # Full documentation
β”œβ”€β”€ QUICK_START.md                 # This file
β”œβ”€β”€ test_production_features.py    # Test suite
β”œβ”€β”€ deploy_production.py           # Production deployment
β”œβ”€β”€ app_database.db               # SQLite database (auto-created)
β”œβ”€β”€ pages/                        # Document pages (auto-created)
β”œβ”€β”€ logs/                         # Application logs
└── uploads/                      # Uploaded files
```

## πŸ§ͺ Testing

Run the test suite to verify everything works:
```bash
python test_production_features.py
```

Test the multi-page citation system:
```bash
python test_multipage_citations.py
```

Test the page count fix:
```bash
python test_page_count_fix.py
```

Test the enhanced detailed responses:
```bash
python test_detailed_responses.py
```

Test the page usage fix:
```bash
python test_page_usage_fix.py
```

Test the table generation functionality:
```bash
python test_table_generation.py
```

## πŸš€ Production Deployment

For production deployment, run:
```bash
python deploy_production.py
```

This will:
- βœ… Check prerequisites
- βœ… Setup environment
- βœ… Install dependencies
- βœ… Create database
- βœ… Setup logging
- βœ… Create Docker configurations
- βœ… Run tests

## πŸ” Troubleshooting

### **Common Issues**

#### **"No module named 'bcrypt'"**
```bash
pip install bcrypt
```

#### **"Docker not running"**
- Start Docker Desktop
- Wait for it to fully initialize

#### **"Ollama not found"**
```bash
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
ollama serve
```

#### **"CUDA out of memory"**
Reduce batch size in .env:
```env
batchsize=2
```

#### **"Database locked"**
```bash
# Stop the application and restart
# Or delete the database file to start fresh
rm app_database.db
```

#### **"Getting fewer pages than requested"**
- The system now ensures exactly the requested number of pages are returned
- Check the console logs for debugging information
- Run the page count test: `python test_page_count_fix.py`
- If issues persist, check that documents have enough content for the query

#### **"LLM only cites 2 pages when 3 are requested"**
- The system now verifies that LLM uses all provided pages
- Enhanced prompts explicitly instruct to use ALL pages
- Page usage verification detects missing references
- Run the page usage test: `python test_page_usage_fix.py`
- Check console logs for page usage verification messages

### **Performance Optimization**

#### **For GPU Users**
```env
flashattn=1
batchsize=8
```

#### **For CPU Users**
```env
flashattn=0
batchsize=2
```

#### **For Large Datasets**
```env
topk=200
efnum=1000
mnum=32
```

## πŸ“Š Monitoring

### **Check Application Status**
- View logs in `logs/app.log`
- Monitor database size: `ls -lh app_database.db`
- Check uploaded documents: `ls -la pages/`

### **Performance Metrics**
- Query response time
- Document processing time
- Memory usage
- GPU utilization (if applicable)

## πŸ” Security Best Practices

### **For Development**
- Use default passwords (already configured)
- Run on localhost only

### **For Production**
- Change default passwords
- Use HTTPS
- Set up proper firewall rules
- Regular database backups
- Monitor access logs

## πŸ“ž Support

### **Getting Help**
1. Check the troubleshooting section above
2. Review the full README.md
3. Run the test suite: `python test_production_features.py`
4. Check application logs: `tail -f logs/app.log`

### **Feature Requests**
- Multi-language support
- Advanced analytics dashboard
- API endpoints
- Mobile app
- Integration with external systems

## πŸŽ‰ What's Next?

After getting familiar with the basic features:

1. **Upload Your Documents**: Replace the sample documents with your own
2. **Customize Models**: Experiment with different AI models
3. **Scale Up**: Add more users and teams
4. **Integrate**: Connect with your existing systems
5. **Deploy**: Move to production with the deployment script

---

**Happy RAG-ing! πŸš€**

*Made by Collar - Enhanced with Team Management & Chat History*