0c-ja-reranker-extra

Japanese homophone reranker for the 0C input method. Given the tokens around an anchor and a set of dictionary candidates that share the reading, it scores each candidate surface in context. The model is a D512, 8-layer, 8-head transformer encoder with a scalar head on the candidate slot (33,864,193 parameters).

This is the CC BY-SA 4.0 shipping candidate: public-core initial weights plus 2,000 finetune steps on the CC BY-SA experimental corpus, exported at the deployment context of 60 tokens per side (sequence 124).

Quality

Combined P2-23F test set, 16,000 groups (8,000 public-core + 8,000 CC BY-SA), top-1 / MRR:

model top-1 MRR public top-1 extra top-1
this model, full rerank 85.36 0.9187 82.60 88.11
this model, top-3 gating 86.45 0.9242 83.98 88.93
trigram-left baseline 85.76 0.9188 84.76 86.75
same checkpoint, 240-token context 85.92 0.9222 83.40 88.45

Authored style probe, 400 short sentences:

genre this model top-3 gating trigram-left
conversation 69.29 72.86 55.71
business 75.38 73.08 62.31
web 80.00 79.23 63.08
overall 74.75 75.00 60.25

Top-3 gating scores only the three statistically-best candidates. On the combined set its top-1 coverage ceiling is 98.21 %; on the style probe it is 92.00 %, so gated top-1 cannot exceed those numbers. Full details, paired tests and the gating quality cost are in the 0C training report docs/reports/P2-25C-extra-export.md.

Deployment layout (important)

The checkpoint was trained with 120 tokens per side and learned absolute positions. The deployment graph keeps those positions while shortening the sequence to 124:

slot    0     1 ........................ 60   61   62        63   64 ................ 123
        <bos> left context (60 tokens)     <eos> candidate <eos> right context (60)
pos     0     61 ...................... 120   121  122       123  124 ............... 183

The nearest left token stays at position 120, the candidate at 122 and the nearest right token at 124. The position ids are baked into the ONNX graph. Left context is right-aligned in its 60 slots, right context is left-aligned; pad unused slots with id 0 and mask them with attention_mask=0. Feeding the compact layout with default arange positions loses about 9 top-1 points.

Sequences shorter than 124 are accepted because the sequence axis is dynamic, but they only reproduce the trained positions for the prefix; pad to 124 in production.

Tensor contract

name dtype shape
input_ids int64 [batch, seq]
attention_mask int64 [batch, seq] (1 real, 0 padding)
scores float32 [batch]

Special ids: pad=0, unk=1, bos=2, eos=3. The vocabulary is the public-core SentencePiece model (32,768 pieces); vocab.json lists the id-to-piece mapping. Scores are raw logits: compare them within one candidate group, higher is better.

import json

import numpy as np
import onnxruntime as ort
import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file="vocab.model")  # same 32k model
session = ort.InferenceSession(
    "model.int8.onnx", providers=["CPUExecutionProvider"]
)
PAD, BOS, EOS = 0, 2, 3
SIDE, SEQ = 60, 124


def layout(left_ids, right_ids, candidate_id):
    ids = np.full(SEQ, PAD, dtype=np.int64)
    mask = np.zeros(SEQ, dtype=np.int64)
    ids[0] = BOS
    mask[0] = 1
    left = left_ids[-SIDE:]
    ids[1 + SIDE - len(left) : 1 + SIDE] = left
    mask[1 + SIDE - len(left) : 1 + SIDE] = 1
    ids[SIDE + 1] = EOS
    ids[SIDE + 2] = candidate_id
    ids[SIDE + 3] = EOS
    mask[SIDE + 1 : SIDE + 4] = 1
    right = right_ids[:SIDE]
    ids[SIDE + 4 : SIDE + 4 + len(right)] = right
    mask[SIDE + 4 : SIDE + 4 + len(right)] = 1
    return ids, mask


rows = [layout(left, right, sp.piece_to_id(surface)) for surface in candidates]
ids = np.stack([row[0] for row in rows])
mask = np.stack([row[1] for row in rows])
scores = session.run(None, {"input_ids": ids, "attention_mask": mask})[0]
best = candidates[int(np.argmax(scores))]

Latency (int8 is the shipping file)

ONNX Runtime CPU, 8 intra-op threads, batch-1 and batch-5 measurements on the export host (NVIDIA GB10, CPU EP), sequence 124, median / p95 per group:

metric median p95
model.int8.onnx, batch 1 per group (3-8 candidates) 21.52 ms 32.08 ms
model.int8.onnx, batch 5 per group (one forward) 23.16 ms 23.36 ms
batch 1 per candidate 5.35 ms 5.42 ms

Cold start in a fresh process (session create + first inference, warm page cache): 86.47 ms (session create 76.90 ms, first inference 9.57 ms). RSS: 51.04 MB before load, 108.16 MB after load, 113.16 MB after inference; model delta 62.11 MB, peak 113.16 MB. The RSS includes the Python and onnxruntime baseline, so the model-attributable delta is the 62 MB figure.

The fp32 file is not shipped. Its batch-5 median is 39.57 ms for reference. Batch-1 per-group latency sums one forward per candidate; the host was shared with other jobs (load average 6.2 at measurement), so the absolute numbers are conservative. int8 dynamic quantisation has no calibration set.

Parity is checked for both files. fp32 ONNX vs PyTorch matches within 2.98e-5; int8 is informational: max score difference 0.241 with the same top-1 and a 0.0007 MRR difference on the parity groups, so int8 is not claimed as numerically parity-exact.

Parity

fp32 ONNX vs PyTorch, 240 combined-test groups at seq 124 (1,091 candidate rows): identical token ids, max absolute score difference 2.98e-5 (threshold 1e-4), identical argmax and ranking.

Training data and licence

  • Initial weights: 0C public-core reranker pilot, trained on the public-core corpus only (CC BY 4.0 and public domain; UniDic BSD-3-Clause and IPADic terms for the lexicon).
  • Finetune: 2,000 steps on the CC BY-SA experimental corpus: Japanese Wikipedia via LLM-jp Corpus v4 ja_wiki (CC BY-SA 3.0), the jawiki-20261101 dump (CC BY-SA 4.0), and the 2024-04-02 Stack Exchange dump for ja.stackoverflow.com / japanese.stackexchange.com (per-post CC BY-SA 2.5 / 3.0 / 4.0).
  • Released weights: CC BY-SA 4.0. See NOTICE for the per-source attribution, modification statement and the Stack Exchange per-post sidecar. Wikimedia, LLM-jp/NII, Stack Exchange and NINJAL do not endorse this model.
  • Japanese Wikipedia text is also available under GFDL; the GFDL statement is retained in NOTICE.

Files

file size note
model.onnx 135,613,420 B fp32, dynamic batch/seq
model.int8.onnx 34,268,510 B dynamic qint8, no calibration
vocab.json see manifest SentencePiece id-to-piece mapping
manifest.json see manifest full tensor contract, SHAs, quality, latency, licence
LICENSE CC BY-SA 4.0 full text
NOTICE attribution and modification statement

Pin a Hugging Face revision and verify every file against the SHA-256 values in manifest.json; the model is not safe to load by floating tag.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support