Von 1.2 (ONNX)
ONNX export of wfzyx/von (von-1.2.0) — a non-autoregressive
decision model on ModernBERT-large: choice, yes/no ("noul") and score questions over a text, every option
scored at a [MASK] marker in one forward pass. Von-1.2's defining property is order invariance: each
option attends only to the question-and-text prefix and to itself, never to another option, and every option's
position ids restart at the prefix length — so an answer cannot depend on the order the options are listed in.
This export keeps that property inside the graph. Von's own PyTorch path hands ModernBERT two S x S attention
masks per row; here the graph builds both from a per-token option_id and the position ids, so a caller sends
integer arrays only.
Exported for SecuPi's unstructured AI service (SPAI), which runs it through ONNX Runtime from Java. Published so that service can fetch it without a PyTorch dependency; anyone else is welcome to use it under the same licence as the base model.
Files
| file | what it is |
|---|---|
onnx/model.onnx |
ModernBERT-large encoder, Von's two attention masks (built in-graph), the marker gather and Von's scoring MLP. fp32, opset 18. |
von_config.json |
special-token ids, the sliding window, and Von's calibration (scalar temperature, the input-conditioned calibration map, the zero-shot noul prior). |
marker_calibration.json |
the base checkpoint's own calibration file, verbatim, for provenance. |
tokenizer.json |
the checkpoint's tokenizer (ModernBERT byte-level BPE). |
There is no .onnx.data: the graph stays under the 2 GB protobuf limit.
The graph
| input | shape | |
|---|---|---|
input_ids |
[B, S] int64 |
right-padded with pad_token_id |
option_id |
[B, S] int64 |
-1 prefix (question, text, the [SEP] before the options and the closing [SEP]), k for every token of option k's span (its marker up to the next marker), -2 padding |
position_ids |
[B, S] int64 |
the raw index, except every option span restarts at the prefix length (markers[0]); padding continues the index |
marker_pos |
[B, K] int64 |
the [MASK] positions, zero-padded |
| output | shape | |
|---|---|---|
logits |
[B, K] float32 |
one raw logit per option marker (padded markers: ignore) |
How to run it
- Pack the text — exactly
OptionMarkerModel.pack_sequence:"<instructions> <text> [SEP] [MASK] <option 0> [MASK] <option 1> …"(instructions and text joined by a space and stripped; each option stripped). For a choice question the options are the label descriptions (or the label itself when it has none); for a yes/no question they are[true text, false text], in that order, defaulting to"Yes, condition holds true."/"No, condition is false.". - Tokenise the whole string with special tokens and no truncation (the encoder takes 8192 positions). The
markers are wherever
input_ids == mask_token_id; buildoption_idandposition_idsas above. - Run the graph, take
logits[:K]. - Calibrate as
OptionMarkerBackend._effective_temperaturedoes:T = clamp(bias + entropy·H + log_tokens·log10(text tokens)/4 + n_options·K/8, lo, hi)with the map invon_config.json,Hthe normalised entropy ofsoftmax(logits), and the text's token count without special tokens; thenp = softmax(logits / T). - For a yes/no question with no criteria, Von first asks the same question of an empty text, takes
bias = z_true − z_false, and subtractsa·bias + b(thenoul_zero_shot_prior) from the true logit before step 4. That pass depends only on the question, so it can be cached.
Von does not remove mask-token text from its input; a text containing [MASK] adds a marker. Callers should
replace it first.
Verification
Against native PyTorch von at commit
fb6e7a9
(tools/von-onnx-export/verify_von_export.py in the SecuPi repository): the in-graph masks reproduce von's
forward pass bit-exactly; ONNX matches PyTorch to 1.7e-5 on the marker logits; a padded batch equals each row
alone; and reversing the options reverses the logits (1.9e-6).
Where it does well
Measured through SPAI's /classify (1155 labelled records, CPU): best of every backend there on short text —
emotion 0.77, Banking77 (20 intents) 0.91, AG News 0.86, multi-label content flags 0.67 exact-match. On long,
form-like documents it is weak (2 of 7 test PDFs; 0.46–0.58 on arXiv papers), where its length-dependent
calibration flattens answers toward chance.