neorag 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neorag-0.1.0/LICENSE +21 -0
- neorag-0.1.0/PKG-INFO +316 -0
- neorag-0.1.0/README.md +267 -0
- neorag-0.1.0/pyproject.toml +65 -0
- neorag-0.1.0/setup.cfg +4 -0
- neorag-0.1.0/src/neorag/__init__.py +7 -0
- neorag-0.1.0/src/neorag/agent/__init__.py +0 -0
- neorag-0.1.0/src/neorag/agent/direct.py +17 -0
- neorag-0.1.0/src/neorag/agent/fast.py +66 -0
- neorag-0.1.0/src/neorag/agent/prompts.py +53 -0
- neorag-0.1.0/src/neorag/agent/react.py +208 -0
- neorag-0.1.0/src/neorag/agent/tools.py +80 -0
- neorag-0.1.0/src/neorag/cli.py +272 -0
- neorag-0.1.0/src/neorag/config.py +232 -0
- neorag-0.1.0/src/neorag/data/__init__.py +0 -0
- neorag-0.1.0/src/neorag/data/chunker.py +51 -0
- neorag-0.1.0/src/neorag/data/loaders.py +135 -0
- neorag-0.1.0/src/neorag/data/qa_dataset.py +153 -0
- neorag-0.1.0/src/neorag/embeddings/__init__.py +0 -0
- neorag-0.1.0/src/neorag/embeddings/embedder.py +76 -0
- neorag-0.1.0/src/neorag/env.py +22 -0
- neorag-0.1.0/src/neorag/eval/__init__.py +0 -0
- neorag-0.1.0/src/neorag/eval/metrics.py +51 -0
- neorag-0.1.0/src/neorag/llm/__init__.py +0 -0
- neorag-0.1.0/src/neorag/llm/base.py +38 -0
- neorag-0.1.0/src/neorag/llm/local_hf.py +110 -0
- neorag-0.1.0/src/neorag/llm/openai_compat.py +114 -0
- neorag-0.1.0/src/neorag/logging_utils.py +20 -0
- neorag-0.1.0/src/neorag/pipeline.py +65 -0
- neorag-0.1.0/src/neorag/retrieval/__init__.py +0 -0
- neorag-0.1.0/src/neorag/retrieval/passage.py +26 -0
- neorag-0.1.0/src/neorag/retrieval/reranker.py +55 -0
- neorag-0.1.0/src/neorag/retrieval/retriever.py +40 -0
- neorag-0.1.0/src/neorag/store/__init__.py +0 -0
- neorag-0.1.0/src/neorag/store/vector_store.py +74 -0
- neorag-0.1.0/src/neorag/training/__init__.py +0 -0
- neorag-0.1.0/src/neorag/training/data_format.py +77 -0
- neorag-0.1.0/src/neorag/training/sft.py +168 -0
- neorag-0.1.0/src/neorag/ui.py +276 -0
- neorag-0.1.0/src/neorag/web/__init__.py +0 -0
- neorag-0.1.0/src/neorag/web/scraper.py +119 -0
- neorag-0.1.0/src/neorag/web/search.py +130 -0
- neorag-0.1.0/src/neorag/web/websearch.py +197 -0
- neorag-0.1.0/src/neorag.egg-info/PKG-INFO +316 -0
- neorag-0.1.0/src/neorag.egg-info/SOURCES.txt +54 -0
- neorag-0.1.0/src/neorag.egg-info/dependency_links.txt +1 -0
- neorag-0.1.0/src/neorag.egg-info/entry_points.txt +2 -0
- neorag-0.1.0/src/neorag.egg-info/requires.txt +28 -0
- neorag-0.1.0/src/neorag.egg-info/top_level.txt +1 -0
- neorag-0.1.0/tests/test_agent_parsing.py +41 -0
- neorag-0.1.0/tests/test_chunker.py +55 -0
- neorag-0.1.0/tests/test_data_format.py +38 -0
- neorag-0.1.0/tests/test_fast.py +53 -0
- neorag-0.1.0/tests/test_metrics.py +38 -0
- neorag-0.1.0/tests/test_vector_store.py +49 -0
- neorag-0.1.0/tests/test_web.py +159 -0
neorag-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Naitik (https://github.com/naitik0409)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
neorag-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: neorag
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A self-hosted RAG agent you fine-tune from a weak open-source model into a retrieval-grounded specialist - free web research, local vector store, model-agnostic LLM
|
|
5
|
+
Author: Naitik
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/naitik0409/NeoRAG
|
|
8
|
+
Project-URL: Documentation, https://github.com/naitik0409/NeoRAG/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/naitik0409/NeoRAG/issues
|
|
10
|
+
Keywords: rag,llm,agents,retrieval,fine-tuning,local-ai,chromadb,web-search,embeddings
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: torch>=2.1
|
|
26
|
+
Requires-Dist: transformers>=5.0
|
|
27
|
+
Requires-Dist: accelerate>=0.30
|
|
28
|
+
Requires-Dist: peft>=0.11
|
|
29
|
+
Requires-Dist: datasets>=2.19
|
|
30
|
+
Requires-Dist: chromadb>=0.5
|
|
31
|
+
Requires-Dist: pyyaml>=6.0
|
|
32
|
+
Requires-Dist: pypdf>=4.0
|
|
33
|
+
Requires-Dist: python-docx>=1.1
|
|
34
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
35
|
+
Requires-Dist: rich>=13.0
|
|
36
|
+
Requires-Dist: tqdm>=4.66
|
|
37
|
+
Requires-Dist: openai>=1.40
|
|
38
|
+
Provides-Extra: train
|
|
39
|
+
Requires-Dist: trl>=0.9; extra == "train"
|
|
40
|
+
Requires-Dist: bitsandbytes>=0.43; (platform_system == "Linux" or platform_system == "Windows") and extra == "train"
|
|
41
|
+
Requires-Dist: sentence-transformers>=2.7; extra == "train"
|
|
42
|
+
Requires-Dist: faiss-cpu>=1.8; extra == "train"
|
|
43
|
+
Provides-Extra: eval
|
|
44
|
+
Requires-Dist: ragas>=0.1; extra == "eval"
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
47
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
<div align="center">
|
|
51
|
+
|
|
52
|
+
# NeoRAG
|
|
53
|
+
|
|
54
|
+
**A self-hosted RAG agent you fine-tune from a weak open-source model into a retrieval-grounded specialist.**
|
|
55
|
+
|
|
56
|
+
*100% free information layer · model-agnostic LLM slot · fully local retrieval*
|
|
57
|
+
|
|
58
|
+
[](https://pypi.org/project/neorag/)
|
|
59
|
+
[](https://www.python.org/)
|
|
60
|
+
[](LICENSE)
|
|
61
|
+
[](tests)
|
|
62
|
+
[](https://github.com/naitik0409)
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## What is NeoRAG?
|
|
69
|
+
|
|
70
|
+
NeoRAG is an **agentic Retrieval-Augmented Generation system** built on three uncompromising principles:
|
|
71
|
+
|
|
72
|
+
| # | Principle | Meaning |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| 1 | **Information gathering is always free** | Web search, page scraping, embeddings, and the vector store need zero API keys and zero credits — no rate-limit death, no billing surprises. |
|
|
75
|
+
| 2 | **The LLM slot is model-agnostic** | Any model in the world fits: local HuggingFace checkpoints, Groq free tier, OpenRouter free models, Ollama, LM Studio, vLLM, or paid clouds. Switching models is one config change. |
|
|
76
|
+
| 3 | **The weak model becomes a strong one** | A fine-tuning loop teaches your small local model grounded, cited answering *and* the agent's JSON tool protocol — so it behaves like a disciplined RAG specialist, not a chatbot. |
|
|
77
|
+
|
|
78
|
+
NeoRAG answers questions from your local documents **and** the live web, always with numbered citations, always through one command-line interface.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
┌─────────────────────────────────────────────────┐
|
|
86
|
+
data/corpus/* │ NEO RAG PIPELINE │
|
|
87
|
+
(pdf/md/docx/...) │ │
|
|
88
|
+
│ ingest │ ┌─────────┐ ┌──────────┐ ┌───────────┐ │
|
|
89
|
+
▼ │ │ chunker │──▶│ embedder │──▶│ ChromaDB │ │
|
|
90
|
+
┌──────────────┐ │ └─────────┘ │ (MiniLM) │ │ (local) │ │
|
|
91
|
+
│ load corpus │ │ └──────────┘ └─────┬─────┘ │
|
|
92
|
+
└──────────────┘ │ │ retrieve │
|
|
93
|
+
│ ┌──────────────────────────┐ ▼ │
|
|
94
|
+
web (free): │ │ DuckDuckGo + scraper │ ┌──────────┐ │
|
|
95
|
+
DuckDuckGo HTML search │ │ 7-day cache, freshness- │─▶│ Retriever│ │
|
|
96
|
+
SearxNG fallback │ │ aware (time-sensitive │ └────┬─────┘ │
|
|
97
|
+
──────────────────────▶│ │ queries bypass cache) │ │ │
|
|
98
|
+
│ └──────────────────────────┘ ▼ │
|
|
99
|
+
│ ┌───────────┐ │
|
|
100
|
+
│ │ LLM │ │
|
|
101
|
+
│ │ any model │ │
|
|
102
|
+
│ └─────┬─────┘ │
|
|
103
|
+
└──────────────────────────────────│─────────────┘
|
|
104
|
+
▼
|
|
105
|
+
┌──────────────────────────┐
|
|
106
|
+
│ FAST MODE 1 LLM call │
|
|
107
|
+
│ AGENT MODE ReAct loop │
|
|
108
|
+
│ → cited answer + sources│
|
|
109
|
+
└──────────────────────────┘
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Installation
|
|
115
|
+
|
|
116
|
+
**From PyPI (recommended):**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pip install neorag
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**From source:**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
git clone https://github.com/naitik0409/NeoRAG.git
|
|
126
|
+
cd NeoRAG
|
|
127
|
+
pip install -e .
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Optional extras:**
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install "neorag[train]" # LoRA fine-tuning: trl, bitsandbytes, sentence-transformers, faiss
|
|
134
|
+
pip install "neorag[dev]" # pytest + ruff
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Requirements: Python 3.10+. **No GPU needed to chat** — CPU-only machines run the full fast mode. A GPU (local CUDA or free Colab T4) is only needed for the `train` step.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Quickstart (60 seconds)
|
|
142
|
+
|
|
143
|
+
The fastest path is the free Groq tier — one key, no config file needed:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# 1. Get a free key at https://console.groq.com (no card, no credits)
|
|
147
|
+
# 2. Make it visible:
|
|
148
|
+
setx GROQ_API_KEY "gsk_your_key" # Windows (new terminal after)
|
|
149
|
+
export GROQ_API_KEY="gsk_your_key" # macOS/Linux
|
|
150
|
+
|
|
151
|
+
# 3. Chat — that's it. Zero config.
|
|
152
|
+
neorag chat
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Or put the key in a `.env` file in your working directory:
|
|
156
|
+
|
|
157
|
+
```ini
|
|
158
|
+
GROQ_API_KEY=gsk_your_key
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Without any key, NeoRAG still works fully offline with a local model (`Qwen/Qwen2.5-0.5B-Instruct` by default — weak but free, and exactly what the fine-tuning loop upgrades):
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
neorag chat --backend local
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Answer modes
|
|
170
|
+
|
|
171
|
+
| Mode | How it works | Best for | Start with |
|
|
172
|
+
|---|---|---|---|
|
|
173
|
+
| **Fast** *(default)* | Parallel local-docs + web retrieval, merged numbered context, **one** LLM call | everyday questions, speed | `neorag chat` |
|
|
174
|
+
| **Agent** | ReAct loop: the model reasons, calls `search` / `web_search` tools step by step, cites, then answers | hard multi-hop questions | `neorag chat --agent` |
|
|
175
|
+
| **Direct** | Your local corpus only — web disabled | private knowledge bases | `neorag chat --direct` |
|
|
176
|
+
|
|
177
|
+
Toggle anytime inside chat with `/mode`, `/web`, `/steps`.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Your own free "Tavily"
|
|
182
|
+
|
|
183
|
+
NeoRAG's web module needs no API key — it is search + scraping, entirely yours:
|
|
184
|
+
|
|
185
|
+
- **Search:** DuckDuckGo HTML (with `lite` endpoint + SearxNG fallbacks), redirect unwrapping
|
|
186
|
+
- **Scrape:** concurrent page fetching, 7-day local cache, politeness delay, per-page text caps
|
|
187
|
+
- **Freshness-aware:** time-sensitive queries (prices, news, "today", "latest"...) **bypass the cache automatically**; general questions stay cached for speed — controlled by `web.freshness: auto | always | cached`
|
|
188
|
+
- **Corpus building:** research a topic once, own it forever
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
neorag research "transformer architecture explained" # search + scrape + ingest
|
|
192
|
+
neorag research "daily gold price india" --pages 5
|
|
193
|
+
neorag chat --direct # now answers from your corpus
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Everything lands in `data/corpus/web/<topic>/` and is embedded on the spot.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Fine-tuning loop: weak → powerful
|
|
201
|
+
|
|
202
|
+
The core promise: upgrade a small open model into a retrieval-grounded specialist with your own data — for free.
|
|
203
|
+
|
|
204
|
+
| Step | Command | What it does |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| 1. Generate data | `neorag build-dataset` | Synthetic QA pairs + **agent-trajectory examples** (the model learns the exact JSON tool protocol it must follow at inference) from your corpus |
|
|
207
|
+
| 2. Train | `neorag train` | LoRA/QLoRA SFT with prompt-token masking (chat-template aware). Local CUDA — or the bundled free Colab notebook on a T4 |
|
|
208
|
+
| 3. Merge | `neorag merge` | Bake the adapter into a standalone model |
|
|
209
|
+
| 4. Deploy | point config at it | `llm.model_id: checkpoints/neorag-sft-merged` |
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
neorag build-dataset --per-chunk 2
|
|
213
|
+
neorag train # or: notebooks/colab_training.ipynb (free T4)
|
|
214
|
+
neorag merge
|
|
215
|
+
neorag evaluate --dataset data/finetune/sft.jsonl --limit 25 --direct
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Evaluation metrics: token-F1, answer rate, citation precision, gave-up rate.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Any LLM, one config
|
|
223
|
+
|
|
224
|
+
| You want | `llm.backend` | Settings |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| Local HuggingFace model *(default, free)* | `local` | `model_id: Qwen/Qwen2.5-0.5B-Instruct` |
|
|
227
|
+
| **Your fine-tuned model** | `local` | `model_id: checkpoints/neorag-sft-merged` |
|
|
228
|
+
| Groq free tier *(default when `GROQ_API_KEY` set)* | `api` | base `https://api.groq.com/openai/v1` — live models: `openai/gpt-oss-120b`, `openai/gpt-oss-20b`, `qwen/qwen3.8-27b` |
|
|
229
|
+
| OpenRouter free models | `api` | base `https://openrouter.ai/api/v1`, model `...:free` |
|
|
230
|
+
| Ollama (local, free) | `api` | base `http://localhost:11434/v1` |
|
|
231
|
+
| LM Studio / vLLM / any OpenAI-compatible server | `api` | same pattern |
|
|
232
|
+
| Paid clouds (OpenAI, Gemini, ...) | `api` | same pattern — optional, never required |
|
|
233
|
+
|
|
234
|
+
No config file at all? Set three env vars and go:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
export NEORAG_LLM_BACKEND=api
|
|
238
|
+
export NEORAG_LLM_API_BASE=https://openrouter.ai/api/v1
|
|
239
|
+
export NEORAG_LLM_MODEL=meta-llama/llama-3.3-70b-instruct:free
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Full key reference: [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md).
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Commands
|
|
247
|
+
|
|
248
|
+
| Command | Purpose |
|
|
249
|
+
|---|---|
|
|
250
|
+
| `neorag chat [--agent] [--direct] [--steps]` | interactive terminal UI (fast mode by default) |
|
|
251
|
+
| `neorag ingest [--clear]` | chunk + embed `data/corpus/` into the local vector store |
|
|
252
|
+
| `neorag research "<query>" [--pages N] [--no-ingest]` | free web search + scrape → saved + embedded |
|
|
253
|
+
| `neorag build-dataset [--per-chunk N] [--limit N]` | generate the SFT fine-tuning set |
|
|
254
|
+
| `neorag train` / `neorag merge` | LoRA fine-tune / bake the adapter |
|
|
255
|
+
| `neorag evaluate [--dataset ...] [--limit N]` | F1 / answer rate / citation precision |
|
|
256
|
+
| `neorag wipe` | clear the vector store |
|
|
257
|
+
|
|
258
|
+
**Chat commands:** `/mode` fast↔agent · `/web` toggle web tool · `/steps` show agent trace · `/stats` corpus + model info · `/clear` · `/help` · `/quit`
|
|
259
|
+
|
|
260
|
+
Supported document types: `txt`, `md`, `pdf`, `docx`, `html`, `csv`, `json` — drop files into `data/corpus/` and run `neorag ingest`.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## What's inside
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
neorag/
|
|
268
|
+
├── data/ loaders (8 formats), chunker, QA-dataset generator
|
|
269
|
+
├── embeddings/ MiniLM mean-pooling embedder (thread-safe, batched)
|
|
270
|
+
├── store/ ChromaDB persistent wrapper
|
|
271
|
+
├── retrieval/ dense retriever + optional cross-encoder reranker
|
|
272
|
+
├── web/ DDG/SearxNG search, scraper with cache + freshness, WebSearcher
|
|
273
|
+
├── agent/ ReAct loop, tools, prompts, fast/direct one-call paths
|
|
274
|
+
├── llm/ local HF backend + OpenAI-compatible backend (SDK + fallback)
|
|
275
|
+
├── training/ data formatting (prompt masking), LoRA/QLoRA trainer, merge
|
|
276
|
+
├── eval/ token-F1, answer rate, citation precision
|
|
277
|
+
├── ui/ rich terminal UI: banner, live spinner phases, panels
|
|
278
|
+
└── cli.py argparse command surface
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Documentation
|
|
284
|
+
|
|
285
|
+
| Doc | Contents |
|
|
286
|
+
|---|---|
|
|
287
|
+
| [`docs/USAGE.md`](docs/USAGE.md) | every command, chat commands, env vars |
|
|
288
|
+
| [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md) | every config key explained |
|
|
289
|
+
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | module map, data flow, design decisions |
|
|
290
|
+
| [`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md) | production setup, service install, backups |
|
|
291
|
+
| [`docs/SECURITY.md`](docs/SECURITY.md) | API key hygiene, data boundaries |
|
|
292
|
+
| [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) | known issues and fixes |
|
|
293
|
+
| [`docs/ROADMAP.md`](docs/ROADMAP.md) | planned work |
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Development
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
git clone https://github.com/naitik0409/NeoRAG.git
|
|
301
|
+
cd NeoRAG
|
|
302
|
+
pip install -e ".[dev]"
|
|
303
|
+
pytest tests -q # 36 tests
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Issues and pull requests welcome: https://github.com/naitik0409/NeoRAG/issues
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
<div align="center">
|
|
311
|
+
|
|
312
|
+
**Author:** [Naitik](https://github.com/naitik0409) · [GitHub profile](https://github.com/naitik0409) · [Repository](https://github.com/naitik0409/NeoRAG)
|
|
313
|
+
|
|
314
|
+
Licensed under the [MIT License](LICENSE) — free to use, modify, and distribute.
|
|
315
|
+
|
|
316
|
+
</div>
|
neorag-0.1.0/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# NeoRAG
|
|
4
|
+
|
|
5
|
+
**A self-hosted RAG agent you fine-tune from a weak open-source model into a retrieval-grounded specialist.**
|
|
6
|
+
|
|
7
|
+
*100% free information layer · model-agnostic LLM slot · fully local retrieval*
|
|
8
|
+
|
|
9
|
+
[](https://pypi.org/project/neorag/)
|
|
10
|
+
[](https://www.python.org/)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
[](tests)
|
|
13
|
+
[](https://github.com/naitik0409)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## What is NeoRAG?
|
|
20
|
+
|
|
21
|
+
NeoRAG is an **agentic Retrieval-Augmented Generation system** built on three uncompromising principles:
|
|
22
|
+
|
|
23
|
+
| # | Principle | Meaning |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| 1 | **Information gathering is always free** | Web search, page scraping, embeddings, and the vector store need zero API keys and zero credits — no rate-limit death, no billing surprises. |
|
|
26
|
+
| 2 | **The LLM slot is model-agnostic** | Any model in the world fits: local HuggingFace checkpoints, Groq free tier, OpenRouter free models, Ollama, LM Studio, vLLM, or paid clouds. Switching models is one config change. |
|
|
27
|
+
| 3 | **The weak model becomes a strong one** | A fine-tuning loop teaches your small local model grounded, cited answering *and* the agent's JSON tool protocol — so it behaves like a disciplined RAG specialist, not a chatbot. |
|
|
28
|
+
|
|
29
|
+
NeoRAG answers questions from your local documents **and** the live web, always with numbered citations, always through one command-line interface.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## How it works
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
┌─────────────────────────────────────────────────┐
|
|
37
|
+
data/corpus/* │ NEO RAG PIPELINE │
|
|
38
|
+
(pdf/md/docx/...) │ │
|
|
39
|
+
│ ingest │ ┌─────────┐ ┌──────────┐ ┌───────────┐ │
|
|
40
|
+
▼ │ │ chunker │──▶│ embedder │──▶│ ChromaDB │ │
|
|
41
|
+
┌──────────────┐ │ └─────────┘ │ (MiniLM) │ │ (local) │ │
|
|
42
|
+
│ load corpus │ │ └──────────┘ └─────┬─────┘ │
|
|
43
|
+
└──────────────┘ │ │ retrieve │
|
|
44
|
+
│ ┌──────────────────────────┐ ▼ │
|
|
45
|
+
web (free): │ │ DuckDuckGo + scraper │ ┌──────────┐ │
|
|
46
|
+
DuckDuckGo HTML search │ │ 7-day cache, freshness- │─▶│ Retriever│ │
|
|
47
|
+
SearxNG fallback │ │ aware (time-sensitive │ └────┬─────┘ │
|
|
48
|
+
──────────────────────▶│ │ queries bypass cache) │ │ │
|
|
49
|
+
│ └──────────────────────────┘ ▼ │
|
|
50
|
+
│ ┌───────────┐ │
|
|
51
|
+
│ │ LLM │ │
|
|
52
|
+
│ │ any model │ │
|
|
53
|
+
│ └─────┬─────┘ │
|
|
54
|
+
└──────────────────────────────────│─────────────┘
|
|
55
|
+
▼
|
|
56
|
+
┌──────────────────────────┐
|
|
57
|
+
│ FAST MODE 1 LLM call │
|
|
58
|
+
│ AGENT MODE ReAct loop │
|
|
59
|
+
│ → cited answer + sources│
|
|
60
|
+
└──────────────────────────┘
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
**From PyPI (recommended):**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install neorag
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**From source:**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/naitik0409/NeoRAG.git
|
|
77
|
+
cd NeoRAG
|
|
78
|
+
pip install -e .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Optional extras:**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install "neorag[train]" # LoRA fine-tuning: trl, bitsandbytes, sentence-transformers, faiss
|
|
85
|
+
pip install "neorag[dev]" # pytest + ruff
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Requirements: Python 3.10+. **No GPU needed to chat** — CPU-only machines run the full fast mode. A GPU (local CUDA or free Colab T4) is only needed for the `train` step.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Quickstart (60 seconds)
|
|
93
|
+
|
|
94
|
+
The fastest path is the free Groq tier — one key, no config file needed:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 1. Get a free key at https://console.groq.com (no card, no credits)
|
|
98
|
+
# 2. Make it visible:
|
|
99
|
+
setx GROQ_API_KEY "gsk_your_key" # Windows (new terminal after)
|
|
100
|
+
export GROQ_API_KEY="gsk_your_key" # macOS/Linux
|
|
101
|
+
|
|
102
|
+
# 3. Chat — that's it. Zero config.
|
|
103
|
+
neorag chat
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Or put the key in a `.env` file in your working directory:
|
|
107
|
+
|
|
108
|
+
```ini
|
|
109
|
+
GROQ_API_KEY=gsk_your_key
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Without any key, NeoRAG still works fully offline with a local model (`Qwen/Qwen2.5-0.5B-Instruct` by default — weak but free, and exactly what the fine-tuning loop upgrades):
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
neorag chat --backend local
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Answer modes
|
|
121
|
+
|
|
122
|
+
| Mode | How it works | Best for | Start with |
|
|
123
|
+
|---|---|---|---|
|
|
124
|
+
| **Fast** *(default)* | Parallel local-docs + web retrieval, merged numbered context, **one** LLM call | everyday questions, speed | `neorag chat` |
|
|
125
|
+
| **Agent** | ReAct loop: the model reasons, calls `search` / `web_search` tools step by step, cites, then answers | hard multi-hop questions | `neorag chat --agent` |
|
|
126
|
+
| **Direct** | Your local corpus only — web disabled | private knowledge bases | `neorag chat --direct` |
|
|
127
|
+
|
|
128
|
+
Toggle anytime inside chat with `/mode`, `/web`, `/steps`.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Your own free "Tavily"
|
|
133
|
+
|
|
134
|
+
NeoRAG's web module needs no API key — it is search + scraping, entirely yours:
|
|
135
|
+
|
|
136
|
+
- **Search:** DuckDuckGo HTML (with `lite` endpoint + SearxNG fallbacks), redirect unwrapping
|
|
137
|
+
- **Scrape:** concurrent page fetching, 7-day local cache, politeness delay, per-page text caps
|
|
138
|
+
- **Freshness-aware:** time-sensitive queries (prices, news, "today", "latest"...) **bypass the cache automatically**; general questions stay cached for speed — controlled by `web.freshness: auto | always | cached`
|
|
139
|
+
- **Corpus building:** research a topic once, own it forever
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
neorag research "transformer architecture explained" # search + scrape + ingest
|
|
143
|
+
neorag research "daily gold price india" --pages 5
|
|
144
|
+
neorag chat --direct # now answers from your corpus
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Everything lands in `data/corpus/web/<topic>/` and is embedded on the spot.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Fine-tuning loop: weak → powerful
|
|
152
|
+
|
|
153
|
+
The core promise: upgrade a small open model into a retrieval-grounded specialist with your own data — for free.
|
|
154
|
+
|
|
155
|
+
| Step | Command | What it does |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| 1. Generate data | `neorag build-dataset` | Synthetic QA pairs + **agent-trajectory examples** (the model learns the exact JSON tool protocol it must follow at inference) from your corpus |
|
|
158
|
+
| 2. Train | `neorag train` | LoRA/QLoRA SFT with prompt-token masking (chat-template aware). Local CUDA — or the bundled free Colab notebook on a T4 |
|
|
159
|
+
| 3. Merge | `neorag merge` | Bake the adapter into a standalone model |
|
|
160
|
+
| 4. Deploy | point config at it | `llm.model_id: checkpoints/neorag-sft-merged` |
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
neorag build-dataset --per-chunk 2
|
|
164
|
+
neorag train # or: notebooks/colab_training.ipynb (free T4)
|
|
165
|
+
neorag merge
|
|
166
|
+
neorag evaluate --dataset data/finetune/sft.jsonl --limit 25 --direct
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Evaluation metrics: token-F1, answer rate, citation precision, gave-up rate.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Any LLM, one config
|
|
174
|
+
|
|
175
|
+
| You want | `llm.backend` | Settings |
|
|
176
|
+
|---|---|---|
|
|
177
|
+
| Local HuggingFace model *(default, free)* | `local` | `model_id: Qwen/Qwen2.5-0.5B-Instruct` |
|
|
178
|
+
| **Your fine-tuned model** | `local` | `model_id: checkpoints/neorag-sft-merged` |
|
|
179
|
+
| Groq free tier *(default when `GROQ_API_KEY` set)* | `api` | base `https://api.groq.com/openai/v1` — live models: `openai/gpt-oss-120b`, `openai/gpt-oss-20b`, `qwen/qwen3.8-27b` |
|
|
180
|
+
| OpenRouter free models | `api` | base `https://openrouter.ai/api/v1`, model `...:free` |
|
|
181
|
+
| Ollama (local, free) | `api` | base `http://localhost:11434/v1` |
|
|
182
|
+
| LM Studio / vLLM / any OpenAI-compatible server | `api` | same pattern |
|
|
183
|
+
| Paid clouds (OpenAI, Gemini, ...) | `api` | same pattern — optional, never required |
|
|
184
|
+
|
|
185
|
+
No config file at all? Set three env vars and go:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
export NEORAG_LLM_BACKEND=api
|
|
189
|
+
export NEORAG_LLM_API_BASE=https://openrouter.ai/api/v1
|
|
190
|
+
export NEORAG_LLM_MODEL=meta-llama/llama-3.3-70b-instruct:free
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Full key reference: [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md).
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Commands
|
|
198
|
+
|
|
199
|
+
| Command | Purpose |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `neorag chat [--agent] [--direct] [--steps]` | interactive terminal UI (fast mode by default) |
|
|
202
|
+
| `neorag ingest [--clear]` | chunk + embed `data/corpus/` into the local vector store |
|
|
203
|
+
| `neorag research "<query>" [--pages N] [--no-ingest]` | free web search + scrape → saved + embedded |
|
|
204
|
+
| `neorag build-dataset [--per-chunk N] [--limit N]` | generate the SFT fine-tuning set |
|
|
205
|
+
| `neorag train` / `neorag merge` | LoRA fine-tune / bake the adapter |
|
|
206
|
+
| `neorag evaluate [--dataset ...] [--limit N]` | F1 / answer rate / citation precision |
|
|
207
|
+
| `neorag wipe` | clear the vector store |
|
|
208
|
+
|
|
209
|
+
**Chat commands:** `/mode` fast↔agent · `/web` toggle web tool · `/steps` show agent trace · `/stats` corpus + model info · `/clear` · `/help` · `/quit`
|
|
210
|
+
|
|
211
|
+
Supported document types: `txt`, `md`, `pdf`, `docx`, `html`, `csv`, `json` — drop files into `data/corpus/` and run `neorag ingest`.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## What's inside
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
neorag/
|
|
219
|
+
├── data/ loaders (8 formats), chunker, QA-dataset generator
|
|
220
|
+
├── embeddings/ MiniLM mean-pooling embedder (thread-safe, batched)
|
|
221
|
+
├── store/ ChromaDB persistent wrapper
|
|
222
|
+
├── retrieval/ dense retriever + optional cross-encoder reranker
|
|
223
|
+
├── web/ DDG/SearxNG search, scraper with cache + freshness, WebSearcher
|
|
224
|
+
├── agent/ ReAct loop, tools, prompts, fast/direct one-call paths
|
|
225
|
+
├── llm/ local HF backend + OpenAI-compatible backend (SDK + fallback)
|
|
226
|
+
├── training/ data formatting (prompt masking), LoRA/QLoRA trainer, merge
|
|
227
|
+
├── eval/ token-F1, answer rate, citation precision
|
|
228
|
+
├── ui/ rich terminal UI: banner, live spinner phases, panels
|
|
229
|
+
└── cli.py argparse command surface
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Documentation
|
|
235
|
+
|
|
236
|
+
| Doc | Contents |
|
|
237
|
+
|---|---|
|
|
238
|
+
| [`docs/USAGE.md`](docs/USAGE.md) | every command, chat commands, env vars |
|
|
239
|
+
| [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md) | every config key explained |
|
|
240
|
+
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | module map, data flow, design decisions |
|
|
241
|
+
| [`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md) | production setup, service install, backups |
|
|
242
|
+
| [`docs/SECURITY.md`](docs/SECURITY.md) | API key hygiene, data boundaries |
|
|
243
|
+
| [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) | known issues and fixes |
|
|
244
|
+
| [`docs/ROADMAP.md`](docs/ROADMAP.md) | planned work |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Development
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git clone https://github.com/naitik0409/NeoRAG.git
|
|
252
|
+
cd NeoRAG
|
|
253
|
+
pip install -e ".[dev]"
|
|
254
|
+
pytest tests -q # 36 tests
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Issues and pull requests welcome: https://github.com/naitik0409/NeoRAG/issues
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
<div align="center">
|
|
262
|
+
|
|
263
|
+
**Author:** [Naitik](https://github.com/naitik0409) · [GitHub profile](https://github.com/naitik0409) · [Repository](https://github.com/naitik0409/NeoRAG)
|
|
264
|
+
|
|
265
|
+
Licensed under the [MIT License](LICENSE) — free to use, modify, and distribute.
|
|
266
|
+
|
|
267
|
+
</div>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "neorag"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A self-hosted RAG agent you fine-tune from a weak open-source model into a retrieval-grounded specialist - free web research, local vector store, model-agnostic LLM"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Naitik" }]
|
|
13
|
+
keywords = ["rag", "llm", "agents", "retrieval", "fine-tuning", "local-ai", "chromadb", "web-search", "embeddings"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
"Topic :: Text Processing :: Indexing",
|
|
26
|
+
]
|
|
27
|
+
urls = { Homepage = "https://github.com/naitik0409/NeoRAG", Documentation = "https://github.com/naitik0409/NeoRAG/tree/main/docs", Issues = "https://github.com/naitik0409/NeoRAG/issues" }
|
|
28
|
+
dependencies = [
|
|
29
|
+
"torch>=2.1",
|
|
30
|
+
"transformers>=5.0",
|
|
31
|
+
"accelerate>=0.30",
|
|
32
|
+
"peft>=0.11",
|
|
33
|
+
"datasets>=2.19",
|
|
34
|
+
"chromadb>=0.5",
|
|
35
|
+
"pyyaml>=6.0",
|
|
36
|
+
"pypdf>=4.0",
|
|
37
|
+
"python-docx>=1.1",
|
|
38
|
+
"beautifulsoup4>=4.12",
|
|
39
|
+
"rich>=13.0",
|
|
40
|
+
"tqdm>=4.66",
|
|
41
|
+
"openai>=1.40",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
train = [
|
|
46
|
+
"trl>=0.9",
|
|
47
|
+
"bitsandbytes>=0.43; platform_system == 'Linux' or platform_system == 'Windows'",
|
|
48
|
+
"sentence-transformers>=2.7",
|
|
49
|
+
"faiss-cpu>=1.8",
|
|
50
|
+
]
|
|
51
|
+
eval = ["ragas>=0.1"]
|
|
52
|
+
dev = ["pytest>=8.0", "ruff>=0.4"]
|
|
53
|
+
|
|
54
|
+
[project.scripts]
|
|
55
|
+
neorag = "neorag.cli:main"
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
where = ["src"]
|
|
59
|
+
|
|
60
|
+
[tool.ruff]
|
|
61
|
+
line-length = 100
|
|
62
|
+
target-version = "py310"
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
testpaths = ["tests"]
|
neorag-0.1.0/setup.cfg
ADDED