Downloads · 30 days
0
DanKau/en_core_web_trf-3.8.0-onnx
en_core_web_trf-3.8.0-onnx is a token classification model from DanKau. Use it when you need labels on individual words, such as names. It is set up for onnx. The card lists the license as mit.
ONNX export of the transformer + NER components of encorewebtrf 3.8.0, the English transformer pipeline trained by Explosion on OntoNotes 5. Exported with spaCy 3.8.7. All weights and tokenizer rules come from the rel…
Downloads · 30 days
0
Access
Public
Updated Sep 6, 2026
Repo size
497 MB
Likes
0
Public
Click a slice to open those files.
.onnx497 MB · 99%
From the Hugging Face model README
en_core_web_trf 3.8.0 — NER (ONNX)ONNX export of the transformer + NER components of
en_core_web_trf 3.8.0, the English
transformer pipeline trained by Explosion on OntoNotes 5. Exported with
spaCy 3.8.7. All weights and tokenizer rules come from the released checkpoint — nothing was
retrained, distilled, or substituted.
The pipeline's tagger, parser, attribute_ruler and lemmatizer are not included.
This export answers "which entities are in this text", not "what is the parse of this text",
and its output is therefore not comparable to the model card's full-pipeline benchmark.
spaCy's NER is a transition-based parser, not a token classifier: it walks a state machine one word at a time, and the next action depends on the action just taken. That data-dependent loop is what makes the pipeline resist a single-graph export. The split here leaves the loop to the host and puts everything with weights in it into ONNX — three graphs, one of which is re-run per word against a cache computed once per document.
Exported for SecuPi's unstructured AI service (SPAI), which runs it through ONNX Runtime from Java with no Python at inference time. Published so that service can fetch it without a spaCy or PyTorch dependency; anyone else is welcome to use it under the same licence as the base model.
| file | what it is |
|---|---|
onnx/encoder.onnx | the checkpoint's trained roberta-base (curated-transformers), sub-word piece ids to 768-d piece vectors. |
onnx/precompute.onnx | the learned 768→64 token projection (tok2vec's final linear), then the NER head's lower affine transform pre-applied for all three state features, with the trained padding row prepended. Run once per document. |
onnx/transition.onnx | gather the three state features out of that cache, sum, add the bias, maxout over the two pieces, and mask the actions never seen in training. Emits the 74 action scores. Run once per word. |
spacy_config.json | window/stride, hidden size, BOS/EOS ids, and the ordered 74-action list — the decode contract. |
spacy_tokenizer.json | the English rule tokenizer: prefix/suffix/infix/URL regexes and the 1,347 tokenizer exceptions, taken from the pinned pipeline. |
tokenizer.json | the byte-level BPE in HuggingFace tokenizers form, rebuilt from the checkpoint's own vocab and merges so it can be loaded by any tokenizers binding. Verified piece-for-piece against spaCy's own piece encoder. |
There is no .onnx.data: the encoder stays under the 2 GB protobuf limit.
The neural parts are here; the tokenization, windowing, pooling and state machine are yours.
Tokenize with spaCy's rules, from spacy_tokenizer.json — split on whitespace, then apply
exceptions, prefixes, suffixes, URL match and infixes. Entity offsets are word offsets, so a
tokenizer that disagrees with spaCy's shifts every span it produces. Note whitespace tokens
are real tokens with no sub-words.
Encode each word as bpe(" " + word) when a space precedes it, bpe(word) otherwise,
and record each word's piece count. Prepend BOS (0) and append EOS (2) to the stream.
Window the whole piece stream — BOS and EOS included — at window 144 with stride 104,
run encoder.onnx on each window, and average the overlaps (a piece covered by two
windows gets the mean of its two vectors, not the last one). This is what spaCy's
with_spans strided-spans layer does, and skipping the average changes the entities on any
text over 144 pieces.
Mean-pool each word's pieces into one 768-d vector. A word with zero pieces pools to zeros.
Run precompute.onnx once over all W word vectors → cached of shape [W+1, 3, 74, 2].
Row 0 is the trained padding vector, so word w lives at row w + 1 — which is why the
state features below are passed as -1-based indices and incremented in the graph.
Walk the state machine. State features are three word indices:
[current word, first word of the open entity or -1, last word of the open entity or -1].
Run transition.onnx with cached and that context, take the highest-scoring valid
action, apply it, and repeat until every word is consumed. Validity is the BILUO grammar:
| action | valid when |
|---|---|
O | no entity is open |
B-X | no entity is open, this is not the last word, X non-empty |
U-X | no entity is open, X non-empty |
I-X | an entity of type X is open and this is not the last word |
L-X | an entity of type X is open |
B/U open an entity at the current word; L/U close one, emitting the span from the
opening word's start offset to the current word's end offset. Actions are indexed by their
position in spacy_config.json's actions.
18 entity types: PERSON, ORG, GPE, LOC, FAC, NORP, PRODUCT, EVENT,
WORK_OF_ART, LAW, LANGUAGE, DATE, TIME, PERCENT, MONEY, QUANTITY, ORDINAL,
CARDINAL.
There are none, and this is not a limitation of the export. A greedy transition parser
commits to one action per word; the action score is an unnormalised maxout activation over a
state, not a probability of the entity being right, and it is not comparable across states or
across documents. spaCy's own Doc.ents carries no per-entity confidence either. Emit a
constant for a hard prediction rather than passing the activation off as one — a threshold over
these numbers filters nothing meaningful.
The exporter checks each graph against the PyTorch module it came from at export time, and then replays 13 texts end to end — including a 315-token document spanning four encoder windows, emoji, non-ASCII names, URLs, and text with no entities at all — asserting that the token offsets, piece ids, per-graph outputs and final entity spans equal what native spaCy 3.8.7 produces on the same input. The same 13 fixtures are replayed from the Java runtime.
Tolerances: 2e-4 on the encoder and precompute graphs, 2e-3 on transition scores, and
exact equality on the resulting entity spans and labels.
MIT, following the base model. The weights are Explosion's, from
en_core_web_trf 3.8.0;
this repository only changes their serialisation format.