Skip to content

Commit 401a789

Browse files
author
Daniele Briggi
committed
chore(readme): improve
1 parent 54d105e commit 401a789

File tree

3 files changed

+119
-105
lines changed

3 files changed

+119
-105
lines changed

README.md

Lines changed: 56 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# SQLite RAG
22

3-
A hybrid search engine built on SQLite with AI and Vector extensions. SQLite-RAG combines vector similarity search with full-text search using Reciprocal Rank Fusion (RRF) for enhanced document retrieval.
3+
[![Run Tests](https://github.com/sqliteai/sqlite-rag/actions/workflows/test.yaml/badge.svg?branch=main&event=release)](https://github.com/sqliteai/sqlite-rag/actions/workflows/test.yaml)
4+
[![codecov](https://codecov.io/github/sqliteai/sqlite-rag/graph/badge.svg?token=30KYPY7864)](https://codecov.io/github/sqliteai/sqlite-rag)
5+
![PyPI - Version](https://img.shields.io/pypi/v/sqlite-rag?link=https%3A%2F%2Fpypi.org%2Fproject%2Fsqlite-rag%2F)
6+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sqlite-rag?link=https%3A%2F%2Fpypi.org%2Fproject%2Fsqlite-rag)
7+
8+
A hybrid search engine built on SQLite with [SQLite AI](https://github.com/sqliteai/sqlite-ai) and [SQLite Vector](https://github.com/sqliteai/sqlite-vector) extensions. SQLite RAG combines vector similarity search with full-text search ([FTS5](https://www.sqlite.org/fts5.html) extension) using Reciprocal Rank Fusion (RRF) for enhanced document retrieval.
49

510
## Features
611

712
- **Hybrid Search**: Combines vector embeddings with full-text search for optimal results
813
- **SQLite-based**: Built on SQLite with AI and Vector extensions for reliability and performance
9-
- **Multi-format Support**: Process 25+ file formats including PDF, DOCX, Markdown, code files
10-
- **Intelligent Chunking**: Token-aware text chunking with configurable overlap
14+
- **Multi-format Text Support**: Process text file formats including PDF, DOCX, Markdown, code files
15+
- **Recursive Character Text Splitter**: Token-aware text chunking with configurable overlap
1116
- **Interactive CLI**: Command-line interface with interactive REPL mode
1217
- **Flexible Configuration**: Customizable embedding models, search weights, and chunking parameters
1318

@@ -19,8 +24,16 @@ pip install sqlite-rag
1924

2025
## Quick Start
2126

27+
Download the model [Embedding Gemma](https://huggingface.co/unsloth/embeddinggemma-300m-GGUF) from Hugging Face chosen as default model:
28+
29+
```bash
30+
sqlite-rag download-model unsloth/embeddinggemma-300m-GGUF embeddinggemma-300M-Q8_0.gguf
31+
```
32+
33+
Then start with default settings:
34+
2235
```bash
23-
# Initialize and add documents
36+
# Initialize sqliterag.sqlite database and add documents
2437
sqlite-rag add /path/to/documents --recursive
2538

2639
# Search your documents
@@ -33,111 +46,56 @@ sqlite-rag
3346
> exit
3447
```
3548

36-
## CLI Commands
37-
38-
### Document Management
49+
For help run:
3950

40-
**Add files or directories:**
4151
```bash
42-
sqlite-rag add <path> [--recursive] [--absolute-paths] [--metadata '{"key": "value"}']
52+
sqlite-rag --help
4353
```
4454

45-
**Add raw text:**
46-
```bash
47-
sqlite-rag add-text "your text content" [uri] [--metadata '{"key": "value"}']
48-
```
49-
50-
**List all documents:**
51-
```bash
52-
sqlite-rag list
53-
```
55+
## CLI Commands
5456

55-
**Remove documents:**
56-
```bash
57-
sqlite-rag remove <path-or-uuid> [--yes]
58-
```
57+
### Configuration
5958

60-
### Search & Query
59+
Settings are stored in the database and should be set before adding any documents.
6160

62-
**Hybrid search:**
6361
```bash
64-
sqlite-rag search "your query" [--limit 10] [--debug]
65-
```
66-
67-
Use `--debug` to see detailed ranking information including vector ranks, FTS ranks, and combined scores.
62+
# Interactive configuration
63+
sqlite-rag configure
6864

69-
### Database Operations
70-
71-
**Rebuild indexes and embeddings:**
72-
```bash
73-
sqlite-rag rebuild [--remove-missing]
74-
```
65+
# View current settings
66+
sqlite-rag settings
7567

76-
**Clear entire database:**
77-
```bash
78-
sqlite-rag reset [--yes]
68+
# View available configuration options
69+
sqlite-rag configure --help
7970
```
8071

81-
### Configuration
72+
To use a different database path, use the global `--database` option:
8273

83-
**View current settings:**
8474
```bash
85-
sqlite-rag settings
86-
```
75+
# Single command with custom database
76+
sqlite-rag --database mydb.db add-text "What's AI?"
8777

88-
**Update configuration:**
89-
```bash
90-
sqlite-rag set [options]
78+
# Interactive mode with custom database
79+
sqlite-rag --database mydb.db
9180
```
9281

93-
Available settings:
94-
- `--model-path-or-name`: Embedding model (file path or HuggingFace model)
95-
- `--embedding-dim`: Vector dimensions
96-
- `--chunk-size`: Text chunk size (tokens)
97-
- `--chunk-overlap`: Token overlap between chunks
98-
- `--weight-fts`: Full-text search weight (0.0-1.0)
99-
- `--weight-vec`: Vector search weight (0.0-1.0)
100-
- `--quantize-scan`: Enable quantized vectors for faster search
101-
- `--quantize-preload`: Preload quantized vectors in memory
102-
103-
## Python API
82+
### Model Management
10483

105-
```python
106-
from sqlite_rag import SQLiteRag
84+
You can experiment with other models from Hugging Face by downloading them with:
10785

108-
# Create RAG instance
109-
rag = SQLiteRag.create("./database.sqlite")
110-
111-
# Add documents
112-
rag.add("/path/to/documents", recursive=True)
113-
rag.add_text("Raw text content", uri="doc.txt")
114-
115-
# Search
116-
results = rag.search("search query", top_k=5)
117-
for result in results:
118-
print(f"Score: {result.score}")
119-
print(f"Content: {result.content}")
120-
print(f"URI: {result.uri}")
121-
122-
# List documents
123-
documents = rag.list_documents()
124-
125-
# Remove document
126-
rag.remove_document("document-id-or-path")
127-
128-
# Database operations
129-
rag.rebuild(remove_missing=True)
130-
rag.reset()
86+
```bash
87+
# Download GGUF models from Hugging Face
88+
sqlite-rag download-model <model-repo> <filename>
13189
```
13290

13391
## Supported File Formats
13492

135-
SQLite-RAG supports 25+ file formats through the MarkItDown library:
93+
SQLite RAG supports the following file formats:
13694

137-
- **Text**: `.txt`, `.md`, `.csv`, `.json`, `.xml`
95+
- **Text**: `.txt`, `.md`, `.mdx`, `.csv`, `.json`, `.xml`, `.yaml`, `.yml`
13896
- **Documents**: `.pdf`, `.docx`, `.pptx`, `.xlsx`
139-
- **Code**: `.py`, `.js`, `.html`, `.css`, `.sql`
140-
- **And many more**: `.rtf`, `.odt`, `.epub`, `.zip`, etc.
97+
- **Code**: `.c`, `.cpp`, `.css`, `.go`, `.h`, `.hpp`, `.html`, `.java`, `.js`, `.mjs`, `.kt`, `.php`, `.py`, `.rb`, `.rs`, `.swift`, `.ts`, `.tsx`
98+
- **Web Frameworks**: `.svelte`, `.vue`
14199

142100
## How It Works
143101

@@ -147,19 +105,22 @@ SQLite-RAG supports 25+ file formats through the MarkItDown library:
147105
4. **Hybrid Search**: Queries are processed through both search methods
148106
5. **Result Fusion**: Results are combined using Reciprocal Rank Fusion for optimal relevance
149107

150-
## Default Configuration
151108

152-
- **Model**: Qwen3-Embedding-0.6B (Q8_0 quantized, 1024 dimensions)
153-
- **Chunking**: 12,000 tokens per chunk with 1,200 token overlap
154-
- **Vectors**: FLOAT16 storage with cosine similarity
155-
- **Search**: Equal weighting (1.0) for vector and full-text results
156-
- **Database**: `./sqliterag.sqlite`
109+
## Development
110+
111+
### Installation
157112

158-
## Extensions Required
113+
For development, clone the repository and install with development dependencies:
159114

160-
SQLite-RAG requires these SQLite extensions:
115+
```bash
116+
# Clone the repository
117+
git clone https://github.com/sqliteai/sqlite-rag.git
118+
cd sqlite-rag
161119

162-
- **[sqlite-ai](https://github.com/sqliteai/sqlite-ai)**: LLM model loading and embedding generation
163-
- **[sqlite-vector](https://github.com/sqliteai/sqlite-vector)**: Vector storage and similarity search
120+
# Create virtual environment
121+
python -m venv .venv
122+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
164123

165-
These are automatically installed as dependencies.
124+
# Install in development mode
125+
pip install -e .[dev]
126+
```

model_evaluation/README.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
1-
# 1. Process dataset
2-
python test_ms_marco.py process --config example_config.json --limit-rows 100
1+
# Model Evaluation Python Script
32

4-
# 2. Evaluate (saves to example_config_evaluation_results.txt)
5-
python test_ms_marco.py evaluate --config example_config.json --limit-rows 100
3+
A simple evaluation script for SQLite Rag using the MS MARCO dataset. Compares performance against the [MTEB leaderboard](https://huggingface.co/spaces/mteb/leaderboard) benchmarks.
4+
5+
## MS MARCO Dataset
6+
7+
**MS MARCO**: Microsoft Question-Answering dataset with real web queries and passages.
8+
9+
## Evaluation Metrics
10+
11+
- **Hit Rate (HR@k)**: Percentage of queries with relevant results in top-k
12+
- **MRR**: Mean Reciprocal Rank - position-weighted relevance score
13+
- **NDCG**: Normalized Discounted Cumulative Gain - ranking quality metric
14+
15+
## Usage
16+
17+
### 1. Setup Configuration
18+
19+
Create an example config file and then edit it with your model settings:
20+
21+
```bash
22+
python ms_marco.py create-config
23+
```
24+
25+
### 2. Process Dataset
26+
27+
```bash
28+
python ms_marco.py process --config configs/my_config.json --limit-rows 100
29+
```
30+
31+
Processes MS MARCO passages into the SQLite Rag database for evaluation.
32+
33+
### 3. Evaluate Performance
34+
35+
```bash
36+
python ms_marco.py evaluate --config configs/my_config.json --limit-rows 100
37+
```
38+
39+
Runs evaluation and saves results to `results/my_config_evaluation_results.txt`.
40+
41+
> **Note**: Without proper hardware, processing and evaluating the entire database may take a lot of time.
42+
> Use `--limit-rows` to process and evaluate only the first n rows.
43+
44+
## Example Results
45+
46+
```
47+
Metric @1 @3 @5 @10
48+
Hit Rate 0.650 0.780 0.820 0.850
49+
MRR 0.650 0.710 0.720 0.725
50+
NDCG 0.650 0.715 0.735 0.750
51+
```

model_evaluation/ms_marco.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ def main():
486486
)
487487
parser.add_argument(
488488
"action",
489-
choices=["process", "evaluate"],
490-
help="Action to perform: 'process' to add passages to database, 'evaluate' to test search quality",
489+
choices=["process", "evaluate", "create-config"],
490+
help="Action to perform: 'process' to add passages to database, 'evaluate' to test search quality, 'create-config' to generate example configuration",
491491
)
492492
parser.add_argument(
493493
"--limit-rows",
@@ -498,16 +498,23 @@ def main():
498498
parser.add_argument(
499499
"--config",
500500
type=str,
501-
required=True,
501+
required=False,
502502
help="JSON configuration file with RAG settings and database path",
503503
)
504504

505505
args = parser.parse_args()
506506

507+
if args.action == "create-config":
508+
print("Creating example configuration file...")
509+
config_file = create_example_config()
510+
print(f"Configuration file created: {config_file}")
511+
print("Edit the file with your settings and then run process/evaluate.")
512+
return
513+
514+
# Config is required for process and evaluate actions
507515
if args.config is None:
508-
print("Missing config file. Creating example config...")
509-
create_example_config()
510-
print("Please edit ms_marco_config.json with your settings and try again.")
516+
print("Error: --config is required for process and evaluate actions")
517+
print("Use 'create-config' action to generate an example configuration file")
511518
return
512519

513520
try:

0 commit comments

Comments
 (0)