Spaces:
Configuration error
Configuration error
Orel MAZOR
commited on
Commit
Β·
3cce64e
1
Parent(s):
08f3a23
readme
Browse files- .DS_Store +0 -0
- .github/workflows/sync_to_hf_space.yml +20 -0
- README.md +177 -15
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
.github/workflows/sync_to_hf_space.yml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Sync to Hugging Face Space
|
2 |
+
on:
|
3 |
+
push:
|
4 |
+
branches: [main]
|
5 |
+
jobs:
|
6 |
+
sync-to-hub:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
steps:
|
9 |
+
- uses: actions/checkout@v3
|
10 |
+
with:
|
11 |
+
fetch-depth: 0
|
12 |
+
lfs: true
|
13 |
+
- name: Push to Hugging Face Space
|
14 |
+
env:
|
15 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
16 |
+
run: |
|
17 |
+
git config --global user.email "[email protected]"
|
18 |
+
git config --global user.name "Your Name"
|
19 |
+
git remote add space https://huggingface.co/spaces/Coool2/Final_Assignment_Template
|
20 |
+
git push -f https://Coool2:[email protected]/spaces/Coool2/Final_Assignment_Template main
|
README.md
CHANGED
@@ -1,15 +1,177 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# π€ Advanced GAIA Agents Challenge Solution
|
2 |
+
|
3 |
+
A comprehensive solution for the [Hugging Face Agents Course Unit 4 GAIA Challenge](https://huggingface.co/learn/agents-course/unit4/hands-on), featuring advanced multimodal AI agents with dynamic RAG capabilities, quantized models for Kaggle compatibility, and both synchronous/asynchronous execution modes.
|
4 |
+
|
5 |
+
## π Features
|
6 |
+
|
7 |
+
### π§ Dual Agent Architecture
|
8 |
+
- **Agent 1 (LlamaIndex)**: Advanced multimodal agent with dynamic knowledge base and hybrid reranking
|
9 |
+
- **Agent 2 (Smolagents)**: Gemini-powered agent with BM25 retrieval and observability
|
10 |
+
|
11 |
+
### Features for Agent 1
|
12 |
+
### π― Multimodal Capabilities
|
13 |
+
- **BAAI Visualized Embedding**: BGE-M3 based multimodal embeddings running on cuda:1
|
14 |
+
- **Pixtral 12B Quantized**: FP8/4-bit quantized vision-language model for resource-constrained environments
|
15 |
+
- **Hybrid Retrieval**: Text + visual content processing with ColPali and SentenceTransformer reranking
|
16 |
+
|
17 |
+
### β‘ Execution Modes
|
18 |
+
- **Asynchronous Mode**: Concurrent question processing for maximum speed
|
19 |
+
- **Kaggle Compatibility**: Optimized for resource-constrained environments
|
20 |
+
|
21 |
+
### π Advanced RAG System
|
22 |
+
- **Dynamic Knowledge Base**: Automatically updated with web search results
|
23 |
+
- **Multimodal Parsing**: Handles text, images, PDFs, audio, and video files
|
24 |
+
- **Smart Reranking**: Hybrid approach combining text and visual rerankers
|
25 |
+
|
26 |
+
## ποΈ Architecture
|
27 |
+
|
28 |
+
```
|
29 |
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
30 |
+
β APP β
|
31 |
+
β (Async/Sync Modes) β
|
32 |
+
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
|
33 |
+
β
|
34 |
+
ββββββββββ΄βββββββββ
|
35 |
+
β β
|
36 |
+
ββββββΌβββββ ββββββΌβββββ
|
37 |
+
βAgent 1 β βAgent 2 β
|
38 |
+
βLlamaIdx β βSmolagentβ
|
39 |
+
ββββββ¬βββββ ββββββ¬βββββ
|
40 |
+
β β
|
41 |
+
ββββββΌβββββ ββββββΌβββββ
|
42 |
+
βDynamic β βBM25 + β
|
43 |
+
βRAG + β βLangfuse β
|
44 |
+
βHybrid β βObserv. β
|
45 |
+
βRerank β β β
|
46 |
+
βββββββββββ βββββββββββ
|
47 |
+
```
|
48 |
+
|
49 |
+
## π Quick Start
|
50 |
+
|
51 |
+
### Prerequisites
|
52 |
+
|
53 |
+
### Installation
|
54 |
+
|
55 |
+
1. **Clone the repository**:
|
56 |
+
```bash
|
57 |
+
git clone https://github.com/yourusername/gaia-agents-challenge
|
58 |
+
cd gaia-agents-challenge
|
59 |
+
```
|
60 |
+
|
61 |
+
2. **Install FlagEmbedding with visual support**:
|
62 |
+
```bash
|
63 |
+
git clone https://github.com/FlagOpen/FlagEmbedding.git
|
64 |
+
cd FlagEmbedding/research/visual_bge
|
65 |
+
pip install -e .
|
66 |
+
cd ../../..
|
67 |
+
```
|
68 |
+
|
69 |
+
3. **Install additional dependencies**:
|
70 |
+
#### For Agent 1:
|
71 |
+
```bash
|
72 |
+
pip install -r requirements.txt
|
73 |
+
```
|
74 |
+
#### For Agent 2:
|
75 |
+
```bash
|
76 |
+
pip install -r requirements2.txt
|
77 |
+
```
|
78 |
+
|
79 |
+
|
80 |
+
4. **Set environment variables**:
|
81 |
+
```bash
|
82 |
+
export GOOGLE_API_KEY="your_gemini_api_key"
|
83 |
+
export HUGGINGFACEHUB_API_TOKEN="your_hf_token"
|
84 |
+
export LANGFUSE_PUBLIC_KEY="your_langfuse_public_key" # Optional
|
85 |
+
export LANGFUSE_SECRET_KEY="your_langfuse_secret_key" # Optional
|
86 |
+
```
|
87 |
+
|
88 |
+
### Usage
|
89 |
+
|
90 |
+
```bash
|
91 |
+
# LlamaIndex Agent
|
92 |
+
python agent.py
|
93 |
+
|
94 |
+
# Smolagents Agent
|
95 |
+
python agent2.py
|
96 |
+
```
|
97 |
+
|
98 |
+
## π Project Structure
|
99 |
+
|
100 |
+
```
|
101 |
+
βββ agent.py # LlamaIndex-based agent with dynamic RAG
|
102 |
+
βββ agent2.py # Smolagents-based agent with observability
|
103 |
+
βββ appasync.py # Original async Gradio interface
|
104 |
+
βββ app.py # Original sync Gradio interface
|
105 |
+
βββ custom_models.py # Custom model implementations
|
106 |
+
βββ requirements.txt # Python dependencies
|
107 |
+
βββ README.md # This file
|
108 |
+
```
|
109 |
+
|
110 |
+
## π§ͺ Testing
|
111 |
+
|
112 |
+
### Run Individual Components
|
113 |
+
```bash
|
114 |
+
# Test BAAI embedding
|
115 |
+
python -c "from custom_models import BaaiMultimodalEmbedding; print('BAAI OK')"
|
116 |
+
|
117 |
+
# Test Pixtral quantized
|
118 |
+
python -c "from custom_models import PixtralQuantizedLLM; print('Pixtral OK')"
|
119 |
+
|
120 |
+
# Test agents
|
121 |
+
python agent.py
|
122 |
+
python agent2.py
|
123 |
+
```
|
124 |
+
|
125 |
+
### Run GAIA Evaluation
|
126 |
+
```bash
|
127 |
+
# Through the web interface
|
128 |
+
python app.py
|
129 |
+
|
130 |
+
# Or programmatically
|
131 |
+
python -c "
|
132 |
+
from agent2 import GAIAAgent
|
133 |
+
agent = GAIAAgent()
|
134 |
+
result = agent.solve_gaia_question({'Question': 'Test question', 'task_id': 'test'})
|
135 |
+
print(result)
|
136 |
+
"
|
137 |
+
```
|
138 |
+
|
139 |
+
## οΏ½οΏ½οΏ½ Customization
|
140 |
+
|
141 |
+
### Adding New Models
|
142 |
+
1. Create a new class in `custom_models.py`
|
143 |
+
2. Implement the required interfaces
|
144 |
+
3. Update the agent configuration
|
145 |
+
|
146 |
+
### Modifying RAG Behavior
|
147 |
+
- Edit `DynamicQueryEngineManager` in `agent.py`
|
148 |
+
- Adjust reranking strategies in `HybridReranker`
|
149 |
+
- Configure search parameters in `enhanced_web_search_tool`
|
150 |
+
|
151 |
+
### UI Customization
|
152 |
+
- Modify `app_unified.py` for interface changes
|
153 |
+
- Add new execution modes
|
154 |
+
- Integrate additional observability tools
|
155 |
+
|
156 |
+
## π Troubleshooting
|
157 |
+
|
158 |
+
### Common Issues
|
159 |
+
|
160 |
+
#### Model Loading Failures
|
161 |
+
- Check internet connectivity for model downloads
|
162 |
+
- Verify HuggingFace token permissions
|
163 |
+
- Clear model cache: `rm -rf ~/.cache/huggingface/`
|
164 |
+
|
165 |
+
#### Visual BGE Import Errors
|
166 |
+
```bash
|
167 |
+
# Ensure proper installation
|
168 |
+
cd FlagEmbedding/research/visual_bge
|
169 |
+
pip install -e .
|
170 |
+
```
|
171 |
+
|
172 |
+
## π References
|
173 |
+
|
174 |
+
- [GAIA Benchmark](https://huggingface.co/datasets/gaia-benchmark/GAIA)
|
175 |
+
- [LlamaIndex](https://github.com/run-llama/llama_index)
|
176 |
+
- [BGE Models](https://github.com/FlagOpen/FlagEmbedding)
|
177 |
+
- [Gradio](https://github.com/gradio-app/gradio)
|