MuhammadAzfar commited on
Commit
290a8b8
·
1 Parent(s): 43da372

Add Hugging Face Space metadata to README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -195
README.md CHANGED
@@ -1,198 +1,12 @@
1
- # 🔬 ResearchMind AI
2
-
3
- <div align="center">
4
-
5
- ![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)
6
- ![Gradio](https://img.shields.io/badge/Gradio-UI-FF6F00?style=for-the-badge)
7
- ![Groq](https://img.shields.io/badge/Groq-LLM-000000?style=for-the-badge)
8
- ![RAG](https://img.shields.io/badge/RAG-Retrieval--Augmented--Generation-6A5ACD?style=for-the-badge)
9
- ![Agentic](https://img.shields.io/badge/Agentic-Plan%20%E2%86%92%20Write%20%E2%86%92%20Verify-E91E63?style=for-the-badge)
10
- ![FAISS](https://img.shields.io/badge/FAISS-Vector%20Search-009688?style=for-the-badge)
11
- ![Tests](https://img.shields.io/badge/Tests-26%20passing-2E7D32?style=for-the-badge)
12
- ![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)
13
-
14
- ### A multi-agent research assistant that plans, researches, writes, and **fact-checks its own reports**
15
-
16
- </div>
17
-
18
- ---
19
-
20
- ## 📖 Overview
21
-
22
- Most AI research tools return fluent text you have to trust blindly. ResearchMind AI is built around a different idea: **every claim in the report is cited, and a second agent checks each claim against the exact passages it cites** before you see the result.
23
-
24
- Give it a topic and a team of cooperating agents does the work:
25
-
26
- | Agent | Job |
27
- |---|---|
28
- | 🧭 **Planner** | Breaks the topic into focused research sub-questions |
29
- | 🔍 **Researcher** | Searches the web for every sub-question in parallel (Tavily) |
30
- | 🧩 **Retriever** | Chunks and embeds all sources, then ranks the best passages with FAISS cosine search |
31
- | ✍️ **Writer** | Drafts a report that may only use the retrieved sources, citing them as `[1]`, `[2]` |
32
- | 🔎 **Checker** | Verifies each cited claim against the passages it cites: *supported / partial / unsupported* |
33
- | 🛠️ **Reviser** | Rewrites or removes flagged claims, then the Checker re-verifies (the feedback loop) |
34
- | 🌍 **Translator** | Optionally renders the *verified* English report in Urdu |
35
-
36
- The UI shows this activity live: the plan, sources found, passages retrieved, and the fact-check verdicts.
37
-
38
- ---
39
-
40
- ## ✨ Features
41
-
42
- - **Agentic pipeline** with a self-correcting verify → revise loop
43
- - **Real RAG**: per-request in-memory FAISS index (normalized embeddings, cosine similarity), per-source caps so one page cannot dominate, relevance floor to drop weak passages
44
- - **Inline citations** `[n]` with a sources list built by code (URLs are never invented by the model); invented citation numbers are stripped automatically
45
- - **Claim-level verification** with an honest score shown on every report
46
- - **Bring your own documents**: upload PDF / TXT / MD, mix them with web results, or run on your documents only
47
- - **Research depth** presets: Quick, Standard, Deep
48
- - **Report styles**: Standard, Summary, Academic
49
- - **English and Urdu** output (Urdu is translated *after* verification, so the checking happens on the original English text)
50
- - **Export** to Markdown (all languages) and PDF (English) with clickable source links
51
- - **Model fallback and rate-limit retry** across several Groq models
52
- - **Offline test suite** (26 tests) and a **batch evaluation script**
53
-
54
- ---
55
-
56
- ## 🏗️ Architecture
57
-
58
- ```text
59
- Topic + options (style, depth, language, documents)
60
- │
61
- ▼
62
- ┌────────────────────────┐
63
- │ Planner (fast LLM) │──► 2–5 sub-questions
64
- └───────────┬────────────┘
65
- ▼
66
- ┌─────────────────────────────────────┐
67
- │ Researcher: parallel Tavily search │ + uploaded PDF/TXT/MD
68
- └───────────────────┬─────────────────┘
69
- ▼
70
- ┌─────────────────────────────────────┐
71
- │ Retriever: chunk → embed (MiniLM) │
72
- │ → FAISS cosine index → top passages │
73
- │ per sub-question │
74
- └───────────────────┬─────────────────┘
75
- ▼
76
- ┌────────────────────────┐
77
- │ Writer (70B, streaming)│──► cited draft
78
- └───────────┬────────────┘
79
- ▼
80
- ┌─────────────────────────────────────────────┐
81
- │ Checker: each claim vs. the passages it cites│
82
- └───────────┬─────────────────────────────────┘
83
- │ flagged claims?
84
- yes ┌───┴───┐ no
85
- ▼ │
86
- ┌──────────────┐│
87
- │ Reviser ││ (re-check; keep the revision only if it scores better)
88
- └──────┬───────┘│
89
- └────────┤
90
- ▼
91
- Translator (optional) → Report + Sources + Verification
92
- ```
93
-
94
- ---
95
-
96
- ## 🧰 Tech Stack
97
-
98
- Python · Gradio · Groq (Llama 3.3 70B for writing, Llama 3.1 8B for planning and checking, with fallbacks) · Tavily · Sentence-Transformers (`all-MiniLM-L6-v2`) · FAISS · LangChain text splitters · pypdf · ReportLab
99
-
100
- ---
101
-
102
- ## 🚀 Getting Started
103
-
104
- ```bash
105
- git clone https://github.com/muhammadazfar-ai/ResearchMind-AI.git
106
- cd ResearchMind-AI
107
- python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
108
- pip install -r requirements.txt
109
- cp .env.example .env # then add your keys
110
- python app.py
111
- ```
112
-
113
- You need a free [Groq](https://console.groq.com) key and a [Tavily](https://tavily.com) key. Never commit `.env`.
114
-
115
- ### Run on Hugging Face Spaces
116
- 1. Create a new **Gradio** Space and push this repository.
117
- 2. In *Settings → Variables and secrets*, add `GROQ_API_KEY` and `TAVILY_API_KEY` as **secrets**.
118
- 3. The Space installs `requirements.txt` and runs `app.py` automatically.
119
-
120
- ---
121
-
122
- ## 📊 Evaluation
123
-
124
- Run the pipeline over a topic list and measure how well-grounded the reports are:
125
-
126
- ```bash
127
- python evaluate.py --limit 5 # first 5 topics in evaluation/topics.txt
128
- python evaluate.py --depth Quick --pause 15
129
- ```
130
-
131
- It writes `evaluation/results.json` and `evaluation/RESULTS.md` with, per topic and on average:
132
- - **Claim support rate**: share of cited claims fully supported by their sources, for the first draft and after the Checker/Reviser loop
133
- - **Citation coverage**: share of factual sentences that carry a citation
134
- - Sources per report, claims checked, and time per report
135
-
136
- > Paste your own `RESULTS.md` summary here after running it, so the numbers in this README are yours.
137
-
138
  ---
139
-
140
- ## 🧪 Tests
141
-
142
- ```bash
143
- pip install -r requirements-dev.txt
144
- python -m pytest
145
- ```
146
-
147
- The suite runs fully offline with scripted fake search, embedding and LLM components. It covers retrieval ranking, citation cleaning, claim extraction, the full verify → revise loop (including a planted false claim that must be caught and removed), document loading, Urdu translation flow, error paths, and the UI handler.
148
-
149
  ---
150
 
151
- ## ⚙️ Configuration
152
-
153
- All tuning lives in [`src/config.py`](src/config.py): chunk size, depth presets, how many passages go to the Writer, relevance thresholds, fact-check batch size. Model order per role is in [`src/llm.py`](src/llm.py) and can be overridden with `GROQ_WRITER_MODEL` / `GROQ_FAST_MODEL`.
154
-
155
- ---
156
-
157
- ## ⚠️ Limitations
158
-
159
- - **The fact-check measures grounding, not absolute truth.** An LLM judges whether a claim matches the passages it cites. If a source is wrong, the report can still be "supported". Verify critical facts yourself.
160
- - **Free-tier rate limits.** Deep research makes many API calls; the app retries and falls back to other models, but it can still be slow or fail under tight limits.
161
- - **Urdu PDF export is not supported** (standard PDF fonts cannot shape Urdu). Urdu reports download as Markdown.
162
- - **Scanned PDFs** have no text layer and need OCR before upload.
163
- - The Urdu translation is machine-generated and was not reviewed by a native speaker.
164
-
165
- ---
166
-
167
- ## 📂 Project Structure
168
-
169
- ```text
170
- ResearchMind-AI/
171
- ├── app.py # Gradio UI: controls, live agent log, exports
172
- ├── evaluate.py # Batch evaluation (support rate, coverage, timing)
173
- ├── requirements.txt
174
- ├── requirements-dev.txt
175
- ├── pytest.ini
176
- ├── .env.example
177
- ├── evaluation/
178
- │ └── topics.txt # Topics used by evaluate.py
179
- ├── src/
180
- │ ├── agents.py # Planner, Researcher, Writer, Checker, Reviser, Translator
181
- │ ├── pipeline.py # Orchestration + live activity trace
182
- │ ├── evidence.py # Chunking, FAISS index, passage selection per question
183
- │ ├── embeddings.py # Sentence-Transformers + cosine index
184
- │ ├── search.py # Tavily web search
185
- │ ├── documents.py # PDF / TXT / MD loading
186
- │ ├── llm.py # Groq client, model fallback, streaming
187
- │ ├── prompts.py # All agent prompts
188
- │ ├── chunking.py # Recursive text splitter
189
- │ └── config.py # Tunable settings
190
- ├── tests/ # Offline test suite
191
- └── screenshot/
192
- ```
193
-
194
- ---
195
-
196
- ## 📄 License
197
-
198
- MIT. See [LICENSE](LICENSE).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: ResearchMind AI
3
+ emoji: ??
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ app_file: app.py
8
+ pinned: false
 
 
 
9
  ---
10
 
11
+ # ResearchMind AI
12
+ A multi-agent AI research assistant.