From 942be2271cca9671fdbacf205c5df04c17b4e845 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Sat, 19 Jul 2025 19:57:37 +0300 Subject: [PATCH] Update docs --- README.md | 6 +++--- docs/configuration.md | 10 +++++++--- docs/index.md | 6 +++--- docs/python.md | 7 +++++-- src/haiku/rag/config.py | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2d70755b..2220b6d7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Retrieval-Augmented Generation (RAG) library on SQLite. - **Multiple embedding providers**: Ollama, VoyageAI, OpenAI - **Multiple QA providers**: Ollama, OpenAI, Anthropic - **Hybrid search**: Vector + full-text search with Reciprocal Rank Fusion -- **Reranking**: Optional result reranking with MixedBread AI or Cohere +- **Reranking**: Default search result reranking with MixedBread AI or Cohere - **Question answering**: Built-in QA agents on your documents - **File monitoring**: Auto-index files when run as server - **40+ file formats**: PDF, DOCX, HTML, Markdown, audio, URLs @@ -50,8 +50,8 @@ async with HaikuRAG("database.db") as client: # Add document doc = await client.create_document("Your content") - # Search (with optional reranking) - results = await client.search("query", rerank=True) + # Search (reranking enabled by default) + results = await client.search("query") for chunk, score in results: print(f"{score:.3f}: {chunk.content}") diff --git a/docs/configuration.md b/docs/configuration.md index ef5fb00a..4dea64e6 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -105,12 +105,17 @@ ANTHROPIC_API_KEY="your-api-key" ## Reranking -Reranking improves search quality by re-ordering the initial search results using specialized models. When enabled, the system retrieves more candidates (3x the requested limit) and then reranks them to return the most relevant results. +Reranking is **enabled by default** and improves search quality by re-ordering the initial search results using specialized models. When enabled, the system retrieves more candidates (3x the requested limit) and then reranks them to return the most relevant results. + +If you use the default reranked (running locally), it can slow down searching significantly. To disable reranking for faster searches: + +```bash +RERANK=false +``` ### MixedBread AI (Default) ```bash -RERANK=true RERANK_PROVIDER="mxbai" RERANK_MODEL="mixedbread-ai/mxbai-rerank-base-v2" ``` @@ -126,7 +131,6 @@ uv pip install haiku.rag --extra cohere Then configure: ```bash -RERANK=true RERANK_PROVIDER="cohere" RERANK_MODEL="rerank-v3.5" COHERE_API_KEY="your-api-key" diff --git a/docs/index.md b/docs/index.md index 19da8d6d..aa969d6a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,13 +1,13 @@ # haiku.rag -`haiku.rag` is a Retrieval-Augmented Generation (RAG) library built to work on SQLite alone without the need for external vector databases. It uses [sqlite-vec](https://github.com/asg017/sqlite-vec) for storing the embeddings and performs semantic (vector) search as well as full-text search combined through Reciprocal Rank Fusion. Both open-source (Ollama) as well as commercial (OpenAI, VoyageAI) embedding providers are supported. - +`haiku.rag` is a Retrieval-Augmented Generation (RAG) library built to work on SQLite alone without the need for external vector databases. It uses [sqlite-vec](https://github.com/asg017/sqlite-vec) for storing the embeddings and performs semantic (vector) search as well as full-text search combined through Reciprocal Rank Fusion. Both open-source (Ollama, MixedBread AI) as well as commercial (OpenAI, VoyageAI) embedding providers are supported. ## Features - **Local SQLite**: No need to run additional servers - **Support for various embedding providers**: Ollama, VoyageAI, OpenAI or add your own - **Hybrid Search**: Vector search using `sqlite-vec` combined with full-text search `FTS5`, using Reciprocal Rank Fusion +- **Reranking**: Optional result reranking with MixedBread AI or Cohere - **Question Answering**: Built-in QA agents using Ollama, OpenAI, or Anthropic. - **File monitoring**: Automatically index files when run as a server - **Extended file format support**: Parse 40+ file formats including PDF, DOCX, HTML, Markdown, audio and more. Or add a URL! @@ -34,7 +34,7 @@ async with HaikuRAG("database.db") as client: results = await client.search("query") # Ask questions - answer = await client.ask("Who is the author of haiku.rag?") + answer = await client.ask("Who is the author of haiku.rag?", rerank=False) ``` Or use the CLI: diff --git a/docs/python.md b/docs/python.md index 8ad47f4e..dc8121b5 100644 --- a/docs/python.md +++ b/docs/python.md @@ -76,7 +76,9 @@ async for doc_id in client.rebuild_database(): ## Searching Documents -Basic search: +The search method performs hybrid search (vector + full-text) with **reranking enabled by default** for improved relevance: + +Basic search (with reranking): ```python results = await client.search("machine learning algorithms", limit=5) for chunk, score in results: @@ -90,7 +92,8 @@ With options: results = await client.search( query="machine learning", limit=5, # Maximum results to return - k=60 # RRF parameter for reciprocal rank fusion + k=60, # RRF parameter for reciprocal rank fusion + rerank=False # Disable reranking for faster search ) # Process results diff --git a/src/haiku/rag/config.py b/src/haiku/rag/config.py index f174a81c..898f3856 100644 --- a/src/haiku/rag/config.py +++ b/src/haiku/rag/config.py @@ -19,7 +19,7 @@ class AppConfig(BaseModel): EMBEDDINGS_MODEL: str = "mxbai-embed-large" EMBEDDINGS_VECTOR_DIM: int = 1024 - RERANK: bool = False + RERANK: bool = True RERANK_PROVIDER: str = "mxbai" RERANK_MODEL: str = "mixedbread-ai/mxbai-rerank-base-v2"