--- license: apache-2.0 base_model: Ismantic/Summer-0.5B-S1 language: - zh - en pipeline_tag: translation tags: - translation - zh-en - en-zh - piece-tokenizer - sft - cpo - grpo --- # Interpreter-Summer-0.5B A 0.52B Chinese↔English translation model, trained **SFT → CPO → GRPO**. This model is one half of an A/B pair. The two differ in **exactly two things** — the base checkpoint and the tokenizer — and share the same data, hyperparameters, losses and rewards. The other half is [``](https://huggingface.co/). | | this model | |---|---| | Tokenizer | custom *piece* tokenizer (81903) | | Chat format | `……` | | Pipeline | SFT → CPO → GRPO | ## Results (WMT23) | direction | BLEU / COMET | |---|---| | zh→en | 15.10 / 0.7415 | | en→zh | 33.59 / 0.7966 | ### How to read these numbers WMT23 is the primary test set — **WMT22 is excluded**, roughly 17.5% of it leaked into the ALMA SFT data. COMET is `Unbabel/wmt22-comet-da`, which is *also* the GRPO reward, so gains were cross-checked on WMT23/24 + Flores-200 with BLEU and chrF to rule out reward hacking. vLLM greedy decoding is not bit-reproducible; BLEU varies by ~0.1 between runs. Differences at that scale are noise. ## Usage > **Not a plug-and-play HF model.** The weights are standard Qwen3, but the > tokenizer is a compiled C++ extension plus sidecar files — > `AutoTokenizer.from_pretrained` does **not** work. > > This repo is self-contained: it ships `model.py`, `checkpoint.py` and > `tokenizer.py`, so **you need neither `transformers` nor `safetensors`** — > just `torch` and the tokenizer extension. ```bash huggingface-cli download Ismantic/Interpreter-Summer-0.5B --local-dir Interpreter-ReTok pip install git+https://github.com/Ismantic/PieceTokenizer cd Interpreter-ReTok && pip install -r requirements.txt && python example_load.py ``` ```python import torch from model import Qwen3ForCausalLM # bundled, torch-only from tokenizer import PieceTokenizerWrapper # bundled tok = PieceTokenizerWrapper(".") model = Qwen3ForCausalLM.from_pretrained(".", device="cuda", dtype=torch.bfloat16) instr = ("Translate the following text from Chinese to English.\n" "Chinese: 人工智能正在深刻改变我们的生活方式。\nEnglish:") ids = tok.apply_chat_template([{"role": "user", "content": instr}], tokenize=True, add_generation_prompt=True) # greedy loop in example_load.py; batch inference in example_vllm.py ``` Loading the weights through `transformers` works too (the state dict uses standard HF names) — but the tokenizer still has to be the bundled one. **Chat format is `{prompt}{response}`, not ChatML.** `` (id 2) is the stop token. The prompt template above is character-identical to training — changing it degrades quality silently. `vllm serve` does **not** work out of the box: piece is not an HF tokenizer, so vLLM must be started with `skip_tokenizer_init=True` and fed `TokensPrompt(prompt_token_ids=...)`. See `example_vllm.py`. ## Files | | | |---|---| | `model.safetensors` `config.json` | weights, standard Qwen3 layout | | `Summer-Tokenizer.pt` | the 81,903-piece vocabulary — same file as in [PieceTokenizer](https://github.com/Ismantic/PieceTokenizer)'s `save/` | | `Summer-Tokenizer.dict.txt` | Chinese segmentation dictionary — **not optional**, see below | | `token_mapping.json` | pad / bos / eos / role-marker ids | | `model.py` `checkpoint.py` `tokenizer.py` | pure-torch inference code | | `example_load.py` `example_vllm.py` | runnable examples | > **Keep `Summer-Tokenizer.dict.txt` next to `Summer-Tokenizer.pt`.** Without it > Chinese token ids change — not just slower, *different* — while round-trip > decoding still looks correct, so nothing appears to be wrong. ## Training Three stages, all on a single RTX 4090: - **SFT** — full fine-tune on ~36.8K zh↔en pairs (ALMA + X-ALMA human parallel, WMT22/23 leakage removed), loss on the response only. - **CPO** — LoRA preference training, `-log σ(β·(logπ_w − logπ_l)) + λ·NLL(y_w)`, on ~44K **self-generated** preference pairs (5 candidates sampled from the SFT model, best/worst picked by COMET). LoRA only — full-parameter CPO collapses the model. - **GRPO** — full-parameter RL. Reward = reference-based `wmt22-comet-da` COMET (1.0) + a 4-gram repetition penalty (0.3), over WMT17–21 source prompts. Training code, data provenance and the negative results (what was tried and rejected, with numbers) are in the [Interpreter repo](https://github.com/Ismantic/Interpreter). ## License & attribution Apache-2.0, following the base model. Training data derives from the ALMA / X-ALMA parallel corpora and WMT news test sets. Please respect the licenses of those upstream models and datasets.