betto_inferencing 0.1.0-dev.3
betto_inferencing: ^0.1.0-dev.3 copied to clipboard
ONNX Runtime inference and embedding models for dense text retrieval.
Changelog #
0.1.0-dev.3 #
Features #
multilingual-e5-smallregistered inModelCatalogand validated — this package's first cross-lingual embedding model, ~100 languages, 384 dimensions (same asbge-small-en-v1.5, so no SQ8/index-format change for consumers switching models). Uses the plain fp32model.onnxexport (not a quantized or GPU-oriented variant — see theModelCatalogdoc comment for the trade-off analysis) andXlmRobertaTokenizerfor tokenization. Real checksums verified via the newtool/register_model.dart.EmbeddingKind— newdocument/queryenum, and a correspondingkindparameter onEmbeddingModel.embed()(defaultEmbeddingKind.document, source-compatible for existing callers).OnnxEmbeddingModel.embed()uses it to applyModelSpec.meta's'documentPrefix'/'queryPrefix'when the loaded model defines them —multilingual-e5-smallrequires a mandatory"passage: "/"query: "prefix per its model card;bge-small-en-v1.5has neither key, so its behaviour is byte-for-byte unchanged.ModelTokenizer— new shared interface (encode(String) -> TokenizerOutput) implemented by bothBertTokenizerandXlmRobertaTokenizer.OnnxEmbeddingModel.load()selects the concrete implementation via a newModelSpec.meta['tokenizerFamily']key ('bert'or'xlmr', added explicitly tobge-small-en-v1.5's own entry too) rather than a compile-time fork, so a third tokenizer family is additive.tool/register_model.dart— new one-off dev tool that downloads aModelCatalogentry's asset files from the exact URLModelSpecuses at runtime and computes their SHA-256 digests viapackage:crypto, so a registered checksum is guaranteed to match what a real download verifies.
Changes #
placeholder-modelreplaces the previousbge-m3-v1.0stub entry inModelCatalog. The old entry had placeholder all-zero checksums and could never actually be downloaded or validated — a registered model that would silently fail with a confusing checksum-mismatch error rather than a clear "not supported" message.placeholder-modelis a permanent, deliberatelyvalidated: falsetest fixture (non-resolvableexample.invalidURLs) that exists solely to give tests a stable, always-unvalidated registered id to assert catalog gating behaviour against. Registeringbge-m3properly (a real 1024-dimensional multilingual model) is deferred future work — its ONNX export exceeds the 2 GB single-file limit and needsModelSpec/ModelDownloadersupport for a splitmodel.onnx+model.onnx_datalayout first.
0.1.0-dev.2 #
Features #
XlmRobertaTokenizer— XLM-RoBERTa-family SentencePiece/Unigram tokenizer (e.g.multilingual-e5-small), returning the sameTokenizerOutputtypeBertTokenizeruses. Composes a from-scratchCharsmapTrie(a Darts double-array trie reader for SentencePiece'sprecompiled_charsmapnormalizer) withdart_sentencepiece_tokenizer's public API, working around two defects in that package's HuggingFacetokenizer.jsonloading path — seeREADME.mdfor details andNOTICEfor third-party attribution.tool/generate_xlmr_parity_corpus.dartandtest/fixtures/xlmr_parity_corpus.json— a 58-language (+3 edge case) byte-exact tokenizer parity corpus, extracted from the NLTK UDHR corpus (same sourcebetto_lang_detectoruses) and annotated with realAutoTokenizertoken ids. Gated by a new test in thetest-macosintegration suite, additive to the smaller 11-entry gate already in place.
Fixes #
XlmRobertaTokenizer— empty-string input no longer produces a spurious extra token._metaspacewas unconditionally adding a dummy-prefix space before replacing spaces with▁, so""became"▁"— itself a valid standalone vocabulary piece — yielding[<s>, ▁, </s>]instead of the realAutoTokenizer's[<s>, </s>]. Found by the new 61-entry parity corpus above.
0.1.0-dev.1 #
Initial development release providing ONNX Runtime inference and embedding models for dense text retrieval on native platforms (macOS, Linux, Windows, Android, iOS).
Features #
EmbeddingModel— abstract interface for text-to-vector embedding, decoupling consumers from any specific inference backend.OnnxEmbeddingModel— ONNX Runtime implementation backed by BGE Small En v1.5, delivering dense embeddings suitable for semantic search and retrieval tasks.BertTokenizer/TokenizerOutput— BERT WordPiece tokenizer with configurable word segmentation (defaultRegExpTokenizer; drop-inIcuTokenizersupport viapackage:betto_icu).ModelCatalog— allowlist provider that gates model use behind download-on-demand viaModelDownloaderfrombetto_onnxrt. Registered models:bge-small-en-v1.5(validated),bge-m3-v1.0(registered, not yet validated — throwsUnsupportedError).quantise/dequantise— SQ8 scalar quantization helpers for compact vector storage and retrieval.- Re-exports
DownloadProgress,ModelDownloader,ModelFile,ModelSpec, andResolvedModelfrombetto_onnxrtas part of the stable public API.