Namespace Qavren.Edge.Embeddings.Onnx
Classes
- EdgeEmbeddingException
Every failure this package raises. It carries exactly the five codes spec 15.1 allocates to
Qavren.Edge.Embeddings.Onnx- TokenizerAssetMissing (5101), TokenizerKindUnsupported (5102), EmbeddingDimensionMismatch (5103), EmbeddingPresetNotFound (5104) and EmbeddingInputTooLong (5105) - and invents none: 15.1 is a closed list and a sixth code would be an SP1 edit this plan does not have.
- EdgeEmbeddings
The naming convention that connects a generator to its query-prefixed sibling.
- EdgeTokenizer
Builds WordPiece tokenizers over a
vocab.txt.
- EmbeddingPooler
Allocation-free pooling over a session output span. Public because it is worth testing alone.
- EmbeddingPreset
Everything the ONNX graph does not tell you. A wrong preset is a silent quality bug, so every field that changes the numbers is
required.
- EmbeddingPresets
The four pinned presets. Only half of this catalogue is hand-written: every
OnnxModelManifest- repo, full commit SHA, per-file path, role, size and SHA-256, and SPDX licence - lives inEmbeddingPresets.g.cs, generated from onepaths-infocall per repo and committed a wave earlier. Nothing here retypes a digest.
- OnnxEmbeddingGenerator
The single public leaf. It implements the LITERAL closed generic MEVD pattern-matches; a generator typed to any other input type is silently unresolvable by a vector store. Thread-safe: concurrent calls serialise on one semaphore around ORT
Run.
- OnnxEmbeddingGeneratorInfo
What one generator is, as diagnostics and a consumer see it.
- OnnxEmbeddingOptions
Everything
AddOnnxEmbeddingsconfigures. Every default here changes behaviour.
- OnnxEmbeddingsEdgeBuilderExtensions
Registers on-device embeddings on the Qavren.Edge builder.
- TokenizedBatch
One padded batch, row-major, ready to wrap in OrtValues.
The three
long[]are RENTED from ArrayPool<T>.Sharedby EncodeBatch(IReadOnlyList<string>, int, IReadOnlyList<int>), so each one may be LONGER than Qavren.Edge.Embeddings.Onnx.TokenizedBatch.TensorLength. Spec 11 pools them because an ingest batch would otherwise allocate3 * BatchSize * SequenceLengthlongs per batch on the one path that runs once per document. Every layout contract below is therefore over the FIRST Qavren.Edge.Embeddings.Onnx.TokenizedBatch.TensorLength elements:array.AsMemory(0, TensorLength)is what reachesOrtValue.CreateTensorValueFromMemory, andarray.Lengthcarries no meaning. Anything past that window is whatever the previous renter left behind.
- WordPieceTokenizerOptions
WordPiece construction settings. Every default here changes behaviour.
Interfaces
- IEdgeTokenizer
The one abstraction over
Microsoft.ML.TokenizersSP2 exposes. Implementations hold the CONCRETE tokenizer type, never theTokenizerbase:BertTokenizer.EncodeToIdsis declarednew, so a base-typed field silently drops[CLS]and[SEP].
- IEdgeTokenizerProvider
Builds the tokenizer on first use and caches it for the process. A provider rather than a directly-injected IEdgeTokenizer, because the vocab file is
OnnxModelFileRole.Vocabularyinside the same manifest as the graph, and spec 10 keeps provisioning LAZY: on a first launch there is no vocab path at the moment DI constructs the generator, and DI factories cannot await a download. So the generator takes this, and the firstGenerateAsyncawaits it - the same call that already awaitsIOnnxSessionHost.AcquireAsync, which provisions the same manifest. Construction parses the whole vocab, so it happens exactly once PER PRESET, behind aSemaphoreSlim(1), and each built instance is reused for the process lifetime. Per preset, not once overall: the keyedAddOnnxEmbeddings(name, ...)overload exists so two presets can coexist in one process, and they differ in LowerCase and MaxSequenceLength - handing one preset's tokenizer to the other is a silent quality bug, never an exception.
Enums
- EdgeTokenizerKind
Which tokenizer family a preset's tokenizer asset belongs to.
- EmbeddingInputKind
Which of a preset's two prefixes an instance applies.
- EmbeddingPooling
How a batch's
last_hidden_statecollapses into one vector per input.
- EmbeddingTruncation
What happens to an input longer than the preset's maximum sequence length.