DeterministicTestEmbedder class

A deterministic 384-dimension embedder for mechanism tests: indexing, storage, freshness, ranking order and output, without a model.

Each vector counts the text's lowercase words, hashed into 383 dimensions with 32-bit FNV-1a, plus a constant last component, so no vector is zero; it is normalized to length 1. Texts that share words are therefore similar, which is enough to check that a search returns what a test expects. It is not a retrieval model, and its scores are no evidence of relevance (ADR-0017).

It counts the documents and queryTexts it encodes and throws a StateError once disposed. Extend it to fail or wait in a test.

Inheritance

Constructors

DeterministicTestEmbedder({String modelName = defaultModelName, List<double> vectorOf(String text)?})
An embedder reporting modelName; vectorOf replaces the word-hash wordVector, for instance to pin the scores of a fixture.

Properties

dimension → int
The dimension of the embedding vectors returned by this embedder.
no setteroverride
disposals ↔ int
How often dispose ran.
getter/setter pair
documents ↔ int
Document inputs encoded so far.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
isDisposed → bool
Whether dispose ran.
no setter
modelName → String
The name of the model used to generate the embeddings.
final
queries → int
Query vectors encoded so far.
no setter
queryTexts → List<String>
Query texts encoded so far, in order.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sourceName → String
The source of the embeddings (e.g., 'llamadart', 'openai').
no setteroverride

Methods

dispose() → Future<void>
Cleans up any resources used by the embedder.
override
embedChunk(Chunk chunk) → Future<Embedding>
Wraps generateEmbedding to build an Embedding object from a Chunk.
inherited
generateEmbedding(String text) → Future<List<double>>
Generates a document embedding for the given text (used for chunks).
override
generateEmbeddings(List<String> texts) → Future<List<List<double>>>
Generates one document embedding for each entry in texts.
inherited
generateQueryVector(String text) → Future<List<double>>
Generates a query embedding for the given text (used for search). Default falls back to document behavior for embedders that don't differentiate.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

wordVector(String text) → List<double>
The default vector of text.

Constants

defaultModelName → const String
The modelName when none is given.
source → const String
The sourceName of every DeterministicTestEmbedder.
vectorDimension → const int
The length of every vector, which ObjectBoxStore requires.