Expand description
Vector recall for the Stop step (internal evaluation “vectors”, not published).
Word matching (BM25) shortlists the lessons the consequence model reads at a turn end. It misses lessons that share no rare word with the work: paraphrased or abstract ones, German work against English lessons, renamed identifiers. Vectors add those, and only those:
- Where: only on the Stop path, after the free gate passed and right before the consequence model call (seconds), where loading the embedder is small next to it. Prompt, early delivery and the free gate stay BM25 only.
- How: no rank fusion. The shortlist is BM25’s top 20 as before, plus up to
kvector hits not already in it, under the same scope rule and done set (extend). The model decides relevance; vectors only add recall. R3b’s widening stays BM25-based. - Index: an embedded SeekStorm vector index per store (
<store>/vectors/), one vector per lesson (question + situations + consequence), updated afterborg learn/borg assimilate --apply, after a mesh sync brings new lessons, and byborg vectors --rebuild; a missing index is built by the first update. A lesson without a vector is simply BM25-only. - Model: Model2Vec potion-multilingual-128M from a local directory (
BORG_VECTOR_MODEL), fetched once byborg vectors --fetch; never downloaded inside a hook. The embedding matrix is mapped, not read: a query touches only the rows of its own tokens. - Fail open: no model, no index, a locked index or any error = BM25 only. On by default:
borg doctorwarns about a missing model or index (doctor.rs);BORG_VECTORS=offdisables it; a lean build (--no-default-features) never has it.
Re-exports§
pub use model::MODEL_FILES;pub use model::MODEL_REPO;pub use model::MODEL_REVISION;pub use model::enabled;pub use model::index_dir;pub use model::model_dir;pub use model::model_present;
Modules§
- doctor
- What
borg doctorandborg install --applysay about vector recall (vectors.rs): the model, and each store’s index. Vectors are on by default, so a missing model or index is a WARN with its fix; off by choice (BORG_VECTORS=off) or a lean build is fine. Read-only: nothing here fetches or builds. - model
- Where vector recall’s model and indexes live and whether they are there, without loading either:
what the hooks check before a query, and what
borg doctorreads (doctor.rs). No dependency on lessons or the engine.
Constants§
- DEFAULT_
K - Vector hits added to the shortlist at most (
BORG_VECTOR_K). Baseline: the internal evaluation “vectors” setting; with the whole-store pool (whole.rs) the shortlist only orders what fills the budget when the pool overflows. - SEGMENT_
BITS - SeekStorm’s segment number bits of the index (2^11 segments). Method: SeekStorm’s own default for an index of this size; borg-search’s evaluation builds its indexes with the same layout.
- SHORTLIST
- BM25 lessons the Stop’s consequence model sees before vector additions. Baseline: top 30 found as
much as top 20 plus vectors (internal evaluation “vectors”); with the whole-store pool it is the
overflow order’s head (whole.rs
select).
Functions§
- extend
- The Stop shortlist:
bm25(BM25’s top 20, asselect_scopedreturns it) and then, in vector order, up toklessons ofranked(lesson ids, best first) thatbm25lacks. Each added lesson must be inpool(the lessons not done this session), in scope forscope_text(rank_scoped’s rule), not superseded and not dormant (a dormant lesson needs a strong word match, which a vector hit is not). - k
- How many vector hits the Stop step adds at most (
BORG_VECTOR_K, defaultDEFAULT_K). - lesson_
text - The text a lesson is embedded from: question, situations, consequence.
- main
borg vectors: status of the model and the store’s index;--rebuild(re)builds the index;--fetchdownloads the model (pinned revision, sha256 checked);--query(reached only asborg debug vectors --query) prints the Stop step’s shortlist for a context on stdin (offline checks, latency). The exit code.- query_
tail - What the consequence model reads of the work (predict.rs
prompt): the lastTAILcharacters. - recall
- The ids of the lessons nearest to
text, best first, at mostn; empty whenever vectors are not available (fail open: no model, no index, the index being written, any error or panic). - refresh
- Bring the index of
lessonsup to date after lessons were written (borg learn,borg assimilate --apply, a mesh sync), building it if it is missing (the first lesson after--fetchneeds no--rebuild). Quiet and fail-open: without the model or with vectors off it does nothing; an error is one line on stderr. Returns the number of lessons embedded. - shortlist
- The Stop step’s shortlist for the lessons file
lessons: BM25’s topnovercontext(scoped byscope_text) extended by the vector index’s hits (extend). Without vectors (off, no model, no index, any error) it is exactly BM25’s topn. Also returns how many lessons the vectors added.