CoolFace
Modelpublic

lopentu/ckiplab-bert-base-chinese-DottedWSD-onnx

sourceHugging Faceapache-2.0updated 20d agoView on Hugging Face
0likes144downloads
Model Card

DottedWSD (ckiplab-bert-base-chinese) — ONNX export for the browser

ONNX conversion of `lopentu/ckiplab-bert-base-chinese-DottedWSD`, the encoder-based word sense disambiguation model from Balancing Accuracy and Efficiency: Evaluating Encoder- and Decoder-Based Models for Word Sense Disambiguation and Regular Polysemy Detection (Chen, Lian & Hsieh, 2026; code: lopentu/dotted-wsd-public). Made so the model can run inside a web page with transformers.js; first used by the Sense River 語意河道 demo (https://lopentu.github.io/sindia/ciwn/sense-river/).

filesizenote
onnx/model.onnx409 MBfp32, exported with torch.onnx.export (opset 17, eager attention); logits identical to PyTorch
onnx/model_quantized.onnx103 MBdynamic int8, per-channel, QInt8 weights; on 6 test sentences × 13 candidates the max abs. probability error vs fp32 was 0.045 (mean 0.021), argmax unchanged

Input format

Sequence-pair classification, exactly as in dotted-wsd:

text      = context with the target wrapped in angle brackets, e.g. 忽然看見江<心>浮現一團黑影。
text_pair = "{word},{CWN definition},{first CWN example}"   one pair per candidate sense

Take the positive-class logit (logits[:, 1]) of each candidate and softmax across the candidates of one token.

js
import { AutoTokenizer, AutoModelForSequenceClassification } from '@huggingface/transformers';
const repo = 'lopentu/ckiplab-bert-base-chinese-DottedWSD-onnx';
const tokenizer = await AutoTokenizer.from_pretrained(repo);
const model = await AutoModelForSequenceClassification.from_pretrained(repo, { dtype: 'q8' });
const inputs = tokenizer(probes, { text_pair: glosses, padding: true, truncation: true, max_length: 320 });
const { logits } = await model(inputs);   // [n_candidates, 2]

Candidate senses come from Chinese Wordnet (CWN) via CwnGraph. Trained on contemporary Taiwan Mandarin; expect domain shift on classical or Buddhist Chinese.