Skip to main content
An efficient bidirectional translation system powered by Liquid AI’s LFM2 1.2B model fine-tuned for Korean-English translation. This project demonstrates how domain-specific fine-tuning can achieve superior performance compared to models 3x larger.

What it does

This example provides a high-quality translation CLI with:
  • Automatic language detection - Intelligently detects input language and translates accordingly
  • Superior performance - CHrF++ 34.61 / BLEU 13.21 on Flores-200 benchmark, outperforming Google’s Gemma-3 4B and Alibaba’s Qwen3 4B
  • Efficient inference - Runs on modest hardware with merged adapters for speed
  • Easy-to-use CLI - Simple command-line interface powered by Fire
This project was built and released by Kiwoong Yeom with the support of Maxime Labone. View the original announcement on LinkedIn.

Performance benchmarks

Tested on Flores-200 benchmark (1,012 samples):
ModelParametersCHrF++BLEU
LFM2-KoEn-v8-rl1.2B34.6113.21
Gemma-3-4B4B32.8311.36
Qwen3-4B4B25.627.46
The 1.2B parameter model outperforms models 3x larger, demonstrating that specialized training matters more than raw parameter count.

Quick start

1

Clone the repository

git clone https://github.com/Liquid4All/cookbook.git
cd cookbook/examples/lfm2-english-to-korean
2

Install dependencies

uv sync
3

Run translation example

uv run python main.py --text "$(cat linkedin_post.txt)" --max-new-tokens 1024

Understanding the architecture

The system uses a two-stage training approach:
  1. Supervised fine-tuning (SFT): 280K high-quality Korean-English parallel datasets establish the translation foundation
  2. Reinforcement learning (RL): GRPO optimization with 10K additional samples refines translation quality

Model components

  • Base model: gyung/lfm2-1.2b-koen-mt-v6.4-merged - SFT fine-tuned LFM2 1.2B
  • Adapter: gyung/lfm2-1.2b-koen-mt-v8-rl-10k-adapter - LoRA adapter trained with GRPO
  • Automatic detection: Regular expression pattern matching for Korean text (Hangul syllables, Jamo)
The system automatically detects the input language and applies the appropriate translation direction, supporting both English→Korean and Korean→English translation.

CLI usage

uv run python main.py [OPTIONS]

Options:
  --text TEXT                    Text to translate (required)
  --model-name TEXT             Base model name (default: gyung/lfm2-1.2b-koen-mt-v6.4-merged)
  --adapter-name TEXT           Adapter name (default: gyung/lfm2-1.2b-koen-mt-v8-rl-10k-adapter)
  --max-new-tokens INTEGER     Maximum tokens to generate (default: 256)
  --temperature FLOAT          Sampling temperature (default: 0.3)
  --min-p FLOAT               Minimum probability threshold (default: 0.15)
  --repetition-penalty FLOAT   Repetition penalty (default: 1.05)

Example usage

uv run python main.py --text "Hello, how are you today?"

Further improvements

Next steps for enhanced performance and efficiency:
  • Speed optimization with quantization techniques (GGUF, AWQ, GPTQ)
  • llama.cpp integration for faster CPU inference
  • Full parameter RL training with expanded compute resources
  • Length normalization removal based on recent Qwen team findings
  • Extended dataset training with 200K SFT + 25K RL samples

Performance optimization

The current implementation uses adapter merging for faster inference. Future improvements include:
  • Quantized model variants for resource-constrained environments
  • Streaming inference for real-time translation
  • Batch processing for large document translation

Source code

View the complete source code on GitHub.

Build docs developers (and LLMs) love