Skip to main content

Crate scour

Crate scour 

Source
Expand description

§Scour

Embeddable hybrid search primitives for Rust — the in-process core of a retrieval pipeline, with zero dependencies:

  • bm25::Bm25Index — Okapi BM25 keyword search (inverted index, Porter stemming, stopword removal)
  • hnsw::HnswIndex — HNSW approximate nearest neighbor vector index (cosine distance, soft deletes, deterministic construction)
  • fuse::rrf_fuse — Reciprocal Rank Fusion to merge lexical and semantic rankings
  • chunk::chunk_text — UTF-8-safe, boundary-aware text chunking for embedding pipelines
  • HybridIndex — the four combined: one type that indexes text + vectors and serves fused hybrid queries

§Example

use scour::HybridIndex;

let mut index = HybridIndex::new(3); // 3-dim embeddings for the demo
index.add("doc-a", "rust systems programming", &[1.0, 0.0, 0.0]);
index.add("doc-b", "gardening in spring", &[0.0, 1.0, 0.0]);

// Hybrid query: keyword text + query embedding, fused with RRF.
let results = index.search("rust programming", &[0.9, 0.1, 0.0], 2);
assert_eq!(results[0].0, "doc-a");

Bring your own embeddings: Scour is deliberately model-agnostic. Any &[f32] works — ONNX, candle, an HTTP embedding service, or test fixtures.

Re-exports§

pub use bm25::Bm25Index;
pub use chunk::chunk_text;
pub use chunk::chunk_text_with_overlap;
pub use embed::embed;
pub use embed::DEMO_DIM;
pub use fuse::rrf_fuse;
pub use fuse::rrf_fuse_scored;
pub use fuse::DEFAULT_RRF_K;
pub use hnsw::cosine_distance;
pub use hnsw::HnswIndex;
pub use hnsw::HnswParams;

Modules§

bm25
Okapi BM25 keyword search over an in-memory inverted index.
chunk
Boundary-aware, UTF-8-safe text chunking for embedding pipelines.
corpus
Seeded demo corpus for the live Scour demo.
embed
Deterministic, dependency-free text embeddings for the live demo.
fuse
Reciprocal Rank Fusion (RRF) for combining ranked result lists.
hnsw
HNSW (Hierarchical Navigable Small World) approximate nearest neighbor index with cosine distance and soft deletes.
text
Text analysis: Unicode-aware tokenization, English stopword removal, and a Porter stemmer.

Structs§

HybridIndex
A combined lexical + vector index serving RRF-fused hybrid queries.