This model is an early experimental release from the kniv cascade research
program and is no longer maintained. It predates the current
5-head cascade architecture (POS, NER, DEP, SRL, CLS) and the
bottom-up layer-selective training methodology that produces our
current production teacher.
The current model offers significantly better quality across all tasks,
includes Semantic Role Labeling and Dialog Act Classification heads,
and has reproducible benchmarks against standard public test sets.
This repository is preserved for reproducibility and historical reference.
No further updates, bug fixes, or evaluation runs are planned.
kniv-deberta-v3-nlp-en
Multi-task NLP model for English that performs NER, POS tagging, dependency parsing, and sentence classification in a single forward pass. Designed for edge and embedded deployment as the core linguistic analysis layer of the uniko cognitive memory system.
This is the student model, trained via knowledge distillation from kniv-deberta-v3-large-nlp-en (435M parameter teacher). Shipped as an INT8-quantized ONNX model for efficient CPU inference.
Compared to DistilRoBERTa (82M parameters), DeBERTa-v3-small offers:
Smaller transformer body (44M non-embedding params vs 82M) at the same depth (6 layers, 768 hidden); 142M total with 128K-token SentencePiece vocabulary
Disentangled attention -- separate content and position representations improve token-level tasks like NER and dependency parsing
The student matches or exceeds the teacher on NER and CLS external benchmarks despite being 3x smaller, likely due to regularization benefits of the smaller architecture and longer distillation training (10 epochs vs 5).
Architecture
Shared DeBERTa-v3-small encoder with four linear classification heads. One encoder forward pass produces all four outputs.
Geopolitical entities -- countries, cities, states
LOC
Non-GPE locations -- mountain ranges, bodies of water
PRODUCT
Objects, vehicles, foods, etc. (not services)
EVENT
Named hurricanes, battles, wars, sports events
WORK_OF_ART
Titles of books, songs, etc.
LAW
Named documents made into laws
LANGUAGE
Any named language
DATE
Absolute or relative dates or periods
TIME
Times smaller than a day
PERCENT
Percentage, including %
MONEY
Monetary values, including unit
QUANTITY
Measurements (weight, distance, etc.)
ORDINAL
"first", "second", etc.
CARDINAL
Numerals that are not another type
CLS dialog act labels (9)
Label
Description
inform
Declarative factual content
correction
Correcting prior information
agreement
Agreement or confirmation
question
Genuine question
plan_commit
Stating intent or commitment
request
Imperative or request
feedback
Reaction or backchannel
social
Greetings, closings, politeness
filler
Discourse markers, hesitations
dep2label encoding
Dependency parsing is reformulated as token classification using the rel-pos encoding from Strzyz et al. (2019). Each token receives a composite label encoding its head attachment, making dependency parsing compatible with the same multi-task token classification architecture used for NER and POS.
Each label has the format {signed_offset}@{relation}@{head_UPOS}:
+1@nsubj@VERB
This means:
+1 -- the head is the 1st token of matching POS to the right
nsubj -- the dependency relation to the head
VERB -- the UPOS tag of the head token
Decoding back to a dependency tree is O(n) per sentence. The label vocabulary is constructed from the training data and typically contains 800--1200 unique composite tags for UD English EWT.
Knowledge distillation
The student model is trained using a combined loss:
KL divergence on temperature-scaled teacher logits
Soft labels are generated per-task by running the trained teacher over the full training set. The student learns from both signals for all four task heads simultaneously.
Human-corrected annotations, mapped to 18-type scheme
GMB's 8 entity types are mapped to the 18-type scheme: per->PERSON, org->ORG, gpe->GPE, geo->LOC, tim->DATE, art->PRODUCT, eve->EVENT, nat->EVENT.
This model does not use CoNLL-2003 data.
Training configuration
Hyperparameter
Value
Optimizer
AdamW
Learning rate
3e-5
Warmup ratio
0.1
Weight decay
0.01
Max grad norm
1.0
Batch size
16
Epochs
10 (with early stopping, patience=3)
Dropout
0.1
NER/POS/Dep loss weight
1.0
CLS loss weight
0.5
Intended use
This model is designed for edge and embedded NLP as part of the uniko cognitive memory system. It provides the core linguistic analysis pipeline -- entity recognition, part-of-speech tagging, syntactic parsing, and sentence classification -- in a single efficient forward pass.
Primary use cases:
On-device NLP for privacy-sensitive applications
Real-time text analysis in resource-constrained environments
Linguistic feature extraction for downstream cognitive memory operations
Out-of-scope uses:
High-stakes decision-making without human review
Languages other than English
Documents exceeding 128 tokens without chunking
Usage with ONNX Runtime
Rust (ort crate)
rust
1useort::{Session,Value};2usetokenizers::Tokenizer;34// Load model and tokenizer5let session =Session::builder()?6.with_model_from_file("model-int8.onnx")?;7let tokenizer =Tokenizer::from_file("tokenizer.json")?;89// Tokenize10let encoding = tokenizer.encode("Caroline went to the hospital.",true)?;11let input_ids:Vec<i64>= encoding.get_ids().iter().map(|&x| x asi64).collect();12let attention_mask:Vec<i64>= encoding.get_attention_mask().iter().map(|&x| x asi64).collect();1314// Run inference -- single forward pass, four outputs15let outputs = session.run(ort::inputs![input_ids, attention_mask]?)?;16let ner_logits = outputs["ner_logits"].extract_tensor::<f32>()?;17let pos_logits = outputs["pos_logits"].extract_tensor::<f32>()?;18let dep_logits = outputs["dep_logits"].extract_tensor::<f32>()?;19let cls_logits = outputs["cls_logits"].extract_tensor::<f32>()?;2021// Argmax over last dimension to get predicted label indices
Python (onnxruntime)
python
1import onnxruntime as ort
2from transformers import AutoTokenizer
3import numpy as np
45session = ort.InferenceSession("model-int8.onnx")6tokenizer = AutoTokenizer.from_pretrained("dragonscale-ai/kniv-deberta-v3-nlp-en")78encoding = tokenizer(9"Caroline went to the hospital.",10 max_length=128, padding="max_length", truncation=True,11 return_tensors="np",12)1314outputs = session.run(None,{15"input_ids": encoding["input_ids"],16"attention_mask": encoding["attention_mask"],17})1819ner_logits, pos_logits, dep_logits, cls_logits = outputs
20ner_preds = np.argmax(ner_logits, axis=-1)21pos_preds = np.argmax(pos_logits, axis=-1)22dep_preds = np.argmax(dep_logits, axis=-1)23cls_pred = np.argmax(cls_logits, axis=-1)
Important: Use This Model's Tokenizer
Always load the tokenizer from this repo, not from microsoft/deberta-v3-small. The upstream HuggingFace tokenizer may omit BOS/EOS special tokens, shifting all positions and producing incorrect results.
python
1# Correct2tokenizer = AutoTokenizer.from_pretrained("dragonscale-ai/kniv-deberta-v3-nlp-en")34# WRONG — may omit special tokens5tokenizer = AutoTokenizer.from_pretrained("microsoft/deberta-v3-small")
Limitations
English only. No multilingual support.
128-token context window. Longer documents require sentence-level chunking before inference.
NER coverage. Entity types are limited to the 18 spaCy categories. Domain-specific entities (e.g., biomedical, legal terminology) are not covered.
CLS labels are GPT-classified. Dialog act labels are generated by GPT-5.4-nano, not human-annotated. Macro F1 reflects imbalanced rare labels (correction, filler).
dep2label decoding errors. The rel-pos encoding can fail to reconstruct a valid tree if the predicted head POS does not exist in the expected direction. Such tokens receive a fallback head of -1.
Quantization trade-off. INT8 quantization reduces model size and latency but may degrade accuracy by up to 0.5% on individual tasks.
If you use this model, please cite the dep2label encoding:
bibtex
1@inproceedings{strzyz-etal-2019-viable,
2 title = "Viable Dependency Parsing as Sequence Labeling",
3 author = "Strzyz, Michalina and Vilares, David and G{\'o}mez-Rodr{\'\i}guez, Carlos",
4 booktitle = "Proceedings of the 2019 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies",
5 year = "2019",
6 publisher = "Association for Computational Linguistics",
7 url = "https://aclanthology.org/N19-1077",
8}
The DeBERTa-v3 base model:
bibtex
1@inproceedings{he2021debertav3,
2 title = "{D}e{BERT}a{V}3: Improving {D}e{BERT}a using {ELECTRA}-Style Pre-Training with Gradient-Disentangled Embedding Sharing",
3 author = "He, Pengcheng and Gao, Jianfeng and Chen, Weizhu",
4 booktitle = "International Conference on Learning Representations",
5 year = "2023",
6 url = "https://openreview.net/forum?id=sE7-XhLxHA",
7}
Knowledge distillation approach:
bibtex
1@article{hinton2015distilling,
2 title = "Distilling the Knowledge in a Neural Network",
3 author = "Hinton, Geoffrey and Vinyals, Oriol and Dean, Jeff",
4 journal = "arXiv preprint arXiv:1503.02531",
5 year = "2015",
6}