v2026.11.2
All Bundles
Bundle

Sentence embeddings from a pretrained BERT-family encoder exported to ONNX: the text is tokenized with WordPieceTokenizer, run through API.Onnx, and pooled into one vector per text.

A library of its own because it needs both System.NLP and API.Onnx, and the compiler resolves every class a linked library names: an embedder inside onnx.obl would make every ONNX program link nlp too, and one inside nlp.obl would make every NLP program need ONNX Runtime (docs/ML_BERT_DESIGN.md). Compile with -lib models,opencv,cipher,json,onnx,nlp,nlp_onnx.

Prediction

One text's classification: the top label, its score, and every label's score in label order.

Operations

GetIndex #

The top label's index.

method : public : GetIndex() ~ Int

Return

TypeDescription
Intindex

GetLabel #

The top label, from the model's id2label.

method : public : GetLabel() ~ String

Return

TypeDescription
Stringlabel

GetScore #

The top label's score: a probability under SOFTMAX or SIGMOID, the raw logit under NONE.

method : public : GetScore() ~ Float

Return

TypeDescription
Floatscore

GetScores #

Every label's score, in label order.

method : public : GetScores() ~ Float[]

Return

TypeDescription
Floatscores

IsTruncated #

Whether the text was longer than the model's maximum length and was cut to fit.

method : public : IsTruncated() ~ Bool

Return

TypeDescription
Booltrue when truncated

New # constructor

Constructor, for a classifier of the program's own.

New(top_label:String, index:Int, score:Float, scores:Float[], truncated:Bool)

Parameters

NameTypeDescription
top_labelStringthe top label
indexIntthe top label's index
scoreFloatthe top label's score
scoresFloatevery label's score, in label order
truncatedBoolwhether text was dropped to fit the model

ToString #

The label and its score, e.g. "POSITIVE 0.9998".

method : public : ToString() ~ String

Return

TypeDescription
Stringtext form