CoolFace
Modelpublic

telecomadm1145/NanoSakura-0.3B

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes69downloads
Model Card

Model Card for NanoSakura-0.3B (Ja -> Zh)

This model is a highly efficient, custom-built Hybrid Sequence-to-Sequence (Seq2Seq) model designed for Japanese to Chinese translation. It combines the deep understanding capabilities of a Transformer Encoder with the blazing-fast, memory-efficient generation of a Mamba2 (State Space Model) Decoder.

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 by introducing a Hybrid Architecture:

  1. 1.Encoder (Transformer): Uses Self-Attention + RoPE + SwiGLU to fully capture the global context of the source Japanese text in parallel.
  2. 2.Decoder (Mamba2 + Cross-Attention): Replaces self-attention with Mamba2's State Space Model (SSM). This allows for $O(1)$ state-updating generation (no growing KV cache), while retaining Cross-Attention to accurately "look back" at the encoder's features to prevent hallucination.

With only ~287 Million parameters, it achieves excellent translation quality while maintaining an extremely low hardware footprint, making it ideal for edge deployment or high-throughput API services.

  • Developed by: telecomadm1145
  • Model type: Hybrid Transformer-Mamba2 Seq2Seq
  • Language(s) (NLP): Japanese (ja), Chinese (zh)
  • License: MIT
  • Parameters: ~287M

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 will handle the $O(1)$ Mamba2 cache generation automatically.

Use the code below to get started:

python
import torch
from transformers import AutoModelForSeq2SeqLM, PreTrainedTokenizerFast

repo_id = "telecomadm1145/NanoSakura-0.3B"
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, 
    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,
    bos_token_id=1, 
    eos_token_id=2
)
result = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(f"Translation: {result}")
# Output: 早安,今天的天气真好呢!

Evaluation

We evaluated the model on the FLORES-200 benchmark (Japanese to Chinese, ja-zh) and a testset(shard_00134). To provide a comprehensive assessment, we report both lexical-overlap metrics (SacreBLEU) and semantic-similarity neural metrics (COMET).

Metrics

Metricopus-mt-ja-zh(~73M)NanoSakura-0.3Bnllb-200-1.3BQwen3-0.6B(fp16)Qwen3-0.6B(fp16,thinking)Qwen3-1.7B(fp16)Qwen3-1.7B(fp16,thinking)
FLORES-200 BLEU25.6722.3620.8712.5821.1327.1227.56
FLORES-200 COMET0.83710.83070.78050.80200.82200.85610.8571
shard_00134 BLEU8.0758.715.736.8914.5723.3724.60
shard_00134 COMET0.44930.86540.51810.69300.74140.81580.8182

All evaluated using greedy decoding.