Table of Contents

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 in EmbeddingPresets.g.cs, generated from one paths-info call 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 AddOnnxEmbeddings configures. 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>.Shared by 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 allocate 3 * BatchSize * SequenceLength longs 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 reaches OrtValue.CreateTensorValueFromMemory, and array.Length carries 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.Tokenizers SP2 exposes. Implementations hold the CONCRETE tokenizer type, never the Tokenizer base: BertTokenizer.EncodeToIds is declared new, 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.Vocabulary inside 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 first GenerateAsync awaits it - the same call that already awaits IOnnxSessionHost.AcquireAsync, which provisions the same manifest. Construction parses the whole vocab, so it happens exactly once PER PRESET, behind a SemaphoreSlim(1), and each built instance is reused for the process lifetime. Per preset, not once overall: the keyed AddOnnxEmbeddings(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_state collapses into one vector per input.

EmbeddingTruncation

What happens to an input longer than the preset's maximum sequence length.