Expand description
§graphrt-rag
Retrieval building blocks for graphrt workflows and the knowledge-retrieval node.
Embedder,VectorStore,Reranker,Retriever: pluggable traits.MemoryStore: in-process cosine + BM25 store (optionally file-backed).SqliteStore(featuresqlite): the same search over one SQLite file, with incremental writes and several processes sharing the database.OpenAiEmbedder,HttpReranker,HttpRetriever(featurehttp) andQdrantStore(featureqdrant).- [
LocalEmbedder] (featurelocal-embed): sentence embeddings computed in this process with candle, no embedding server or API key. chunk_textandIngestorfor indexing documents.KnowledgeBase: the service the node uses, built in code or from aKnowledgeConfigfile.
use std::sync::Arc;
use graphrt_core::{Registry, Services};
use graphrt_rag::{Document, HashEmbedder, KnowledgeBase, MemoryStore};
let kb = KnowledgeBase::new()
.with_store_dataset("faq", Arc::new(MemoryStore::new()), Arc::new(HashEmbedder::new(256)), None);
kb.ingestor("faq").unwrap().ingest(&Document::new("faq", "returns", "Items can be returned within 30 days.")).await.unwrap();
let mut registry = Registry::with_builtins();
graphrt_rag::register(&mut registry);
let services = Services::new().with(kb);Structs§
- Chunker
Config - Chunking parameters.
- Dataset
Config - One dataset entry.
- Dataset
Details - A dataset as listed for management UIs.
- Dataset
Info - Public description of a dataset.
- Dataset
Spec - A dataset created at runtime from the stores, embedders and rerankers a
knowledge config declares (see
KnowledgeBase::create_dataset). - DocExtractor
- Extracts text from any format supported by
graphrt-doc. - Document
- A document to ingest.
- Document
Summary - One document of a dataset, as listed by
VectorStore::list_documents. - Hash
Embedder - Feature-hashing embedder.
- Hit
- One retrieved chunk with its relevance score (higher is better).
- Http
Reranker - Reranker for Cohere/Jina/Voyage-compatible APIs.
- Http
Reranker Config - Configuration of a
/rerankendpoint (Cohere, Jina, Voyage, vLLM, TEI…). - Http
Retriever - A
Retrieverthat delegates to a remote RAG service. - Http
Retriever Config - Configuration of a remote retrieval endpoint.
- Http
Settings - Shared HTTP settings.
- Hybrid
Weights - How vector and keyword scores are blended.
- Ingest
Report - Outcome of an ingestion.
- Ingestor
- Chunks, embeds (in batches) and stores documents.
- Keyword
Query - Keyword (BM25) query.
- Knowledge
Base - Dataset id -> retriever registry.
- Knowledge
Config - Declarative knowledge-base configuration (
knowledge.yaml/.json). - Knowledge
Retrieval Node - Retrieves chunks from a
KnowledgeBaseservice. - Memory
Store - In-memory
VectorStorewith cosine similarity and BM25 keyword search. - Metadata
Condition - One metadata condition, e.g.
{name: "lang", comparison_operator: "is", value: "en"}. - Metadata
Filter - A set of metadata conditions.
- Open
AiEmbedder - Embedder for any OpenAI-compatible embeddings API (OpenAI, Azure, Ollama, vLLM, Jina, …).
- Open
AiEmbedder Config - Configuration of an OpenAI-compatible
/embeddingsendpoint. - Plain
Text Extractor - Extractor for UTF-8 text formats (plain text, Markdown, JSON, CSV, HTML as-is).
- Qdrant
Config - Qdrant connection settings.
- Qdrant
Store VectorStorebacked by Qdrant.- Resource
Names - Names of the stores, embedders and rerankers runtime datasets can use.
- Retrieval
Request - A high-level retrieval request.
- Secret
- A string that never appears in
Debugoutput. - Sqlite
Store VectorStorepersisted in one SQLite file, with cosine and BM25 search.- Store
Retriever - A
Retrieverover aVectorStore+Embedder(+ optionalReranker). - Stored
Chunk - A chunk as stored in a
VectorStore. - Text
Chunk - One chunk of a document.
- Unknown
Operator - Error for an unsupported comparison operator.
- Vector
Query - Vector similarity query.
Enums§
Constants§
- DEFAULT_
DOCUMENT_ PAGE - Default and largest page size for document listings.
- DISABLED_
KEY - Reserved chunk metadata key marking a disabled document: its chunks stay stored but every search skips them.
- KIND
- Node kind.
- MAX_
DOCUMENT_ PAGE
Traits§
- Embedder
- Turns text into embedding vectors.
- Extractor
- Turns raw document bytes into text for ingestion (PDF, DOCX, … extractors plug in here).
- Reranker
- Re-scores documents against a query (cross-encoder style).
- Retriever
- End-to-end retrieval: query in, ranked hits out. Implement this to plug an external RAG service in place of the built-in store pipeline.
- Vector
Store - Stores chunks with vectors and answers similarity queries.
Functions§
- check_
vector - Check that a vector can be stored or searched: non-empty and finite.
- chunk_
text - Split
textinto chunks (children carrying their parent index in parent-child mode). - content_
hash - Stable 64-bit FNV-1a hash rendered as hex.
- cosine
- Cosine similarity (0 when either vector is zero or lengths differ).
- descriptor
- Catalog entry for the node.
- dot
- Dot product written as 8 independent accumulators so the compiler can vectorize it.
- finalize
- Apply the score threshold, then keep the best
top_k. - is_
disabled - Whether chunk metadata marks its document as disabled.
- merge_
weighted - Blend vector (cosine, clamped to
[0, 1]) and keyword (BM25 divided by the best BM25 score) scores by id:score = wv * vector + wk * keyword, with weights normalized to sum to 1. Missing components count as 0. - register
- Register the
knowledge-retrievalnode. - rerank
- Replace scores with reranker scores and re-sort.
- tokenize
- Lower-cased alphanumeric tokens. CJK characters become one token each so languages without spaces still get a usable keyword index.