Instructions to use telecomadm1145/NanoSakura-2.2-0.2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use telecomadm1145/NanoSakura-2.2-0.2B with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="telecomadm1145/NanoSakura-2.2-0.2B", trust_remote_code=True)# Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("telecomadm1145/NanoSakura-2.2-0.2B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
🌸 NanoSakura-2.2-0.2B
Japanese → Chinese Translation, Hybrid Transformer–Mamba2 Seq2Seq
▶️ Live Demo Space — try it in your browser, no setup required.
Overview
NanoSakura-2.2-0.2B is a highly efficient, custom-built Hybrid Sequence-to-Sequence (Seq2Seq) model for Japanese → Chinese translation. It pairs the deep contextual understanding of a Transformer Encoder with the fast, memory-efficient generation of a Mamba2 (State Space Model) Decoder.
With only ~188M parameters, it reaches translation quality competitive with — and on in-domain ACG text, well beyond — general-purpose LLMs nearly 10× its size, while keeping a hardware footprint small enough for edge deployment or high-throughput API serving.
💡 Which checkpoint should I use? This is the recommended, best-balanced checkpoint in the NanoSakura-2.x line. A later checkpoint (2.3) trades in-domain (ACG) quality for a small bump on general-domain benchmarks — see Evaluation for details.
Highlights
- 🏗️ Hybrid architecture — Transformer encoder + Mamba2 decoder with cross-attention, giving constant-memory per-step generation ($O(1)$ state update per token) instead of the usual growing KV-cache.
- 🎯 Domain specialist — trained on ACG (anime/comic/game)-domain distillation data; substantially outperforms general LLMs on in-domain translation (see
shard_00134results below). - ⚖️ Balanced generalist — unlike later checkpoints, retains strong general-domain (FLORES-200) performance without sacrificing in-domain quality.
- 🪶 Tiny footprint — ~188M parameters, no "thinking"/CoT overhead required to hit its scores, unlike some LLM baselines.
Model Details
Model Description
Traditional Seq2Seq models (like T5 or BART) rely entirely on Transformers. While powerful, the self-attention mechanism in the decoder leads to an $O(N^2)$ computational bottleneck and high KV-cache memory usage during text generation.
This model solves that with a Hybrid Architecture:
- Encoder (Transformer): Self-Attention + RoPE + SwiGLU, fully capturing the global context of the source Japanese text in parallel.
- Decoder (Mamba2 + Cross-Attention): Replaces decoder self-attention with Mamba2's State Space Model (SSM), enabling constant-memory generation — each decoding step is an $O(1)$ state update with no growing KV cache — while retaining Cross-Attention to accurately "look back" at the encoder's features and prevent hallucination.
| Developed by | telecomadm1145 |
| Model type | Hybrid Transformer–Mamba2 Seq2Seq |
| Language(s) | Japanese (ja) → Chinese (zh) |
| License | MIT |
| Parameters | ~188M |
| Base model | NanoSakura-2-0.2B |
🚀 Try it instantly
The fastest way to try the model is the hosted Space — no installation needed:
How to Get Started with the Model
Because this model uses a custom architecture, you must use trust_remote_code=True when loading it with the transformers library. The custom modeling_mamba2_s2s.py handles the $O(1)$ Mamba2 cache generation automatically.
ℹ️ Note: This model expects the source text to be manually terminated with an explicit
<eos>token before encoding, as shown below.
import torch
from transformers import AutoModelForSeq2SeqLM, PreTrainedTokenizerFast
repo_id = "telecomadm1145/NanoSakura-2.2-0.2B"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = PreTrainedTokenizerFast.from_pretrained(repo_id)
model = AutoModelForSeq2SeqLM.from_pretrained(
repo_id,
trust_remote_code=True,
torch_dtype=torch.float32,
)
model.to(device)
text = "おはようございます、今日の天気はいいですね!"
input_ids = tokenizer.encode(text + "<eos>")
input_tensor = torch.tensor([input_ids]).to(device)
output_ids = model.generate(
input_tensor,
max_new_tokens=256,
)
result = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(f"Translation: {result}")
# Output: 早安,今天的天气真好呢!
Evaluation
We evaluated on the FLORES-200 benchmark (ja-zh) for general-domain quality, and on an in-domain ACG testset (shard_00134) for domain-specific quality. We report both lexical-overlap (SacreBLEU) and semantic-similarity (COMET) metrics. All results use greedy decoding.
⚠️ Metric details — please read before comparing:
- BLEU: All BLEU scores are computed with SacreBLEU using
tokenize=zh(character-level tokenization), not spBLEU. Scores are internally consistent across every model and dataset in this table (all baselines were re-run under the same setup), but are not directly comparable to spBLEU numbers reported elsewhere (e.g., on the FLORES-200 leaderboard). Underzhtokenization, BLEU values are systematically higher than spBLEU.- COMET: computed with
Unbabel/wmt22-comet-da.
| Metric | opus-mt-ja-zh (~73M) | NanoSakura-2-0.2B | NanoSakura-2.2-0.2B | NanoSakura-2.3-0.2B | NanoSakura-0.3B | nllb-200-1.3B | Qwen3-0.6B | Qwen3-0.6B (thinking) | Qwen3-1.7B | Qwen3-1.7B (thinking) |
|---|---|---|---|---|---|---|---|---|---|---|
| FLORES-200 BLEU | 25.67 | 23.27 | 26.55 | 28.67 | 22.36 | 20.87 | 12.58 | 21.13 | 27.12 | 27.56 |
| FLORES-200 COMET | 0.8371 | 0.8380 | 0.8494 | 0.8563 | 0.8307 | 0.7805 | 0.8020 | 0.8220 | 0.8561 | 0.8571 |
| shard_00134 BLEU | 8.07 | 58.13 | 57.55 | 49.32 | 58.71 | 5.73 | 6.89 | 14.57 | 23.37 | 24.60 |
| shard_00134 COMET | 0.4493 | 0.8615 | 0.8608 | 0.8558 | 0.8654 | 0.5181 | 0.6930 | 0.7414 | 0.8158 | 0.8182 |
Reading the table:
- On in-domain ACG translation (
shard_00134), NanoSakura-2.2 (0.8608 COMET) massively outperforms even Qwen3-1.7B-thinking (0.8182 COMET) — a model ~8.5× larger — despite the latter's extra chain-of-thought overhead. (The high absolute BLEU here reflects the combination of thezhtokenizer and the model's strong in-domain fit; compare across columns, not against external spBLEU numbers.) - On general-domain translation (FLORES-200), 2.2 stays competitive with models several times its size, trailing Qwen3-1.7B by only ~0.007 COMET.
Recommended Use Cases
- ✅ ACG (anime/manga/game) text translation — visual novels, subtitles, in-game text, fan translation pipelines
- ✅ General-purpose ja→zh translation where a small, fast, edge-deployable model is preferred
- ✅ High-throughput API serving where Mamba2's constant-memory generation matters
- ⚠️ Not recommended for domains far outside ACG/general web text without further fine-tuning
License
Released under the MIT License.
- Downloads last month
- 201
Model tree for telecomadm1145/NanoSakura-2.2-0.2B
Base model
telecomadm1145/NanoSakura-2-0.2B