mlboydaisuke's picture
LFM2.5-Encoder-350M-Spellchecker LiteRT: int8 (iPhone-verified bit-exact) + fp16, task-level parity verified
c4b5ad0 verified
|
Raw
History Blame Contribute Delete
2.89 kB
metadata
license: other
license_name: lfm1.0
license_link: LICENSE
base_model: LiquidAI/LFM2.5-Encoder-350M-Spellchecker
pipeline_tag: token-classification
library_name: litert
tags:
  - litert
  - tflite
  - on-device
  - edge
  - encoder
  - spellcheck
  - grammar
  - gec
  - liquid
  - lfm2
  - lfm2.5

LFM2.5-Encoder-350M-Spellchecker — LiteRT

LiquidAI/LFM2.5-Encoder-350M-Spellchecker converted to LiteRT (.tflite) for on-device inference. A GECToR-style two-head tagger that corrects misspellings and grammar token by token, fully offline (demo Space).

File Recipe Size
LFM2.5-Encoder-350M-Spellchecker_wi8fc.tflite int8 dynamic-range (linears + embedding + tied vocab heads, convs float) 429 MB mobile + desktop (iPhone-verified bit-exact, 64 ms)
LFM2.5-Encoder-350M-Spellchecker_fp16.tflite fp16 weights, float compute 847 MB desktop — phone memory limits (XNNPACK per-signature fp32 unpacking)

Signature

gec_128 (S = 128, batch 1, right-padded; the base model's own decode uses max_len 128): input_ids int32 [1, 128] (prepend the tokenizer BOS as the sentence anchor), attention_mask int32 [1, 128] → two outputs, both zeroed at padded positions:

Output Shape Meaning
label_logits float32 [1, 128, 128802] per-token edit tag: 0 $KEEP, 1 $DELETE, 2..2+V $REPLACE_<piece>, 2+V.. $APPEND_<piece> (V = 64400 BPE pieces)
detect_logits float32 [1, 128, 2] P(token is part of an error) gate

Host-side decode is the base repo's algorithm: argmax the tags, gate by softmax(detect)[1] >= min_error_prob, apply the edits, and iterate (≤3 passes) until the text stops changing. The base repo also bundles an optional PyTorch reranker for its published maximum-precision operating point — that stays host-side/desktop; this artifact covers the tagger (a fully supported mode of the base model's .correct()).

Verification

Task-level parity vs the PyTorch reference ("She go to school every day ." → single $REPLACE on "go"): fp32, fp16 and int8 all produce the identical edit (same position, same replacement piece, detect head agreeing). On an iPhone 17 Pro the int8 file reproduces the desktop outputs bit-exactly on both heads — including the full [1, 128, 128802] label tensor — (cosine 1.000000, max diff 0.0) at 64 ms per pass (6 threads, XNNPACK).

License

LFM Open License v1.0 (see LICENSE, unchanged from the base model). Note the license's commercial-use threshold (Section 5). This repository redistributes converted Derivative Works of LiquidAI/LFM2.5-Encoder-350M-Spellchecker with modification notices per Section 4; all credit for the model to Liquid AI.