FUTO Keyboard — French Transformer Language Model (fr)
A French (fr) next-word-prediction + autocorrect transformer model for
FUTO Keyboard, trained locally on a consumer GPU (NVIDIA RTX 2080).
The pipeline adapts the most advanced existing community implementation —
jblechert/keyboard-lm-de (German,
full data pipeline + XBU autocorrect generation) — to French, and matches the
official FUTO English model (ml4) exactly in architecture, tokenizer
format and GGUF metadata, verified against
futo-org/android-keyboard native loader code and the official
ml4_1_f16_meta_fixed.gguf (see reference/).
Model spec (identical to official FUTO English model)
| Property | Value |
|---|---|
| Architecture | LlamaForCausalLM, 8 layers, hidden 512, 8 heads (head_dim 64), FFN 1024 SwiGLU, RoPE base 10000, RMSNorm eps 1e-6 |
| Parameters | 36.3M |
| Context | 2048 (trained at 256) |
| Tokenizer | SentencePiece unigram, vocab 15008, byte_fallback, treat_whitespace_as_suffix=true ("inverted space"), add_dummy_prefix=false, meta tokens <pad>=0 <s>=1 </s>=2 <unk>=3 |
| Control tokens | <FUTO0..23> <XBU> <XBC> <XEC> <XC0..4> <CHAR_A..Z> (consecutive, as required by the runtime) |
| GGUF features | base_v1 inverted_space xbu_char_autocorrect_v1 xc0_swipe_typing_v1 char_embed_mixing_v1 lora_finetunable_v1 |
keyboardlm.languages | fr |
Install on the phone
- Copy one of
output/fr_keyboard_*.ggufto the Android device. - FUTO Keyboard → Settings → Predictive Text → Transformer Models → Import from file → pick the
.gguf. - Add French under Languages & Models, then select the model for
fr.
| File | Size | Note |
|---|---|---|
fr_keyboard_Q8_0.gguf | 39 MB | near-lossless, start here |
fr_keyboard_Q6_K.gguf | 31 MB | same size class as the official ml4_q6_k.gguf (30.7 MB), best for phones |
fr_keyboard_Q4_K_M.gguf | 24 MB | older/slower devices |
fr_keyboard_f16.gguf | 74 MB | unquantized reference |
Compute time (configuration: NVIDIA RTX 2080 8 GB, 16 CPU cores, 31 GB RAM, Ubuntu)
| Step | Measured time |
|---|---|
| 01 — corpus download (Tatoeba, OpenSubtitles, FineWeb2 ~8 GB, French Wikipedia) | ~30 min |
| 02 — cleaning + dedup (193 M raw lines → 45 M train lines) | ~50 min |
| 03 — SentencePiece tokenizer (8 M sampled lines) | ~5 min |
| 04 — XBU data generation (5 M sentences → 19.9 M lines) | ~18 min |
| 05 — LLaMA 36 M pretraining (80,000 steps, 655 M tokens, ~66 k tok/s) | 2 h 45 |
| 09 — XBU LoRA round 1 (15,000 steps) + round 2 (20,000 steps) | ~20 min + ~27 min |
| 06 — GGUF F16 export + Q8_0/Q6_K/Q4_K_M quantization | ~2 min |
| 08 — benchmark (PPL + top-k + XBU) per checkpoint | ~2 min |
| Total | ≈ 4 h 40 |
Measured quality (local training run, RTX 2080)
| Model | conversational PPL | next-word top-1 / top-5 | XBU autocorrect exact (greedy) |
|---|---|---|---|
final (models/fr_keyboard_merged2 → output/) | 27.4 | 40.2% / 61.7% | 29.3% |
plain LM before LoRA (fr_keyboard_v1_final_backup) | 22.1 | 40.9% / 63.0% | 0% |
(For reference: naively mixing XBU lines into pretraining at ~5% of tokens degraded the plain LM to PPL ~319 while reaching only 42% XBU — hence the pretrain-then-LoRA strategy, same as the German pipeline.)
Pipeline (scripts/)
01_download_data.py Tatoeba FR (CC BY) + OpenSubtitles v2018 FR + FineWeb2 fra_Latn (ODC-By) + Wikipedia FR (CC BY-SA)
02_clean_data.py normalize, French-heuristic filter, dedupe, train/eval split
03_train_tokenizer.py SentencePiece unigram 15008, FUTO special tokens, inverted-space format
04_generate_xbu_data.py AZERTY-aware typo generation, XBU/CHAR autocorrect format (+ accent-restore: "cafe" -> "café")
05_train_model.py trains the 36M LLaMA on the RTX 2080 (~70k tok/s)
06_export_gguf.py F16 GGUF with official keyboardlm metadata + llama-quantize to Q8_0/Q6_K/Q4_K_M
07_evaluate.py perplexity / top-k / XBU autocorrect eval (HF or GGUF)
08_benchmark.py conversational PPL/top-k + XBU exact-match, compare checkpoints
09_lora_finetune.py LoRA-finetunes the plain LM on XBU data (preserves LM quality), --merge-only merges
check_gguf.py replicates FUTO's native loader checks against the final .gguf
Full run used here:
python3 scripts/05_train_model.py --steps 80000 --batch 32 --lr 6e-4 --warmup 2000 \
--xbu-weight 0.10 --out models/fr_keyboard_v1 # NOTE: XBU in pretraining hurts; keep weight ~0 or omit
# better: pretrain on plain text only, then:
python3 scripts/09_lora_finetune.py --base models/fr_keyboard_v1_final_backup --steps 15000 --out models/fr_keyboard_lora
python3 scripts/09_lora_finetune.py --base models/fr_keyboard_v1_final_backup --resume-lora models/fr_keyboard_lora \
--steps 20000 --lr 3e-4 --xbu-weight 0.75 --out models/fr_keyboard_lora2
python3 scripts/09_lora_finetune.py --merge-only --lora models/fr_keyboard_lora2 \
--base models/fr_keyboard_v1_final_backup --merged-out models/fr_keyboard_merged2
python3 scripts/06_export_gguf.py --model-dir models/fr_keyboard_merged2 --out output/fr_keyboard_f16.gguf
python3 scripts/check_gguf.py output/fr_keyboard_Q6_K.gguf
Run end-to-end:
pip install torch --index-url https://download.pytorch.org/whl/cu124
pip install "transformers>=4.49,<5" datasets sentencepiece gguf protobuf
python3 scripts/01_download_data.py
python3 scripts/02_clean_data.py
python3 scripts/03_train_tokenizer.py
python3 scripts/04_generate_xbu_data.py
python3 scripts/05_train_model.py --steps 25000 --batch 32
python3 scripts/06_export_gguf.py
python3 scripts/check_gguf.py output/fr_keyboard_Q6_K.gguf
Training data licenses
Tatoeba CC BY 2.0 · OpenSubtitles CC BY · FineWeb2 ODC-By · Wikipedia CC BY-SA 3.0. Check the licenses of the sources before redistributing the trained weights.
License
- Code (
scripts/): MIT — seeLICENSE. - Model weights (
output/*.gguf): CC BY-SA 4.0 (chosen), because the training data includes Wikipedia content under CC BY-SA; the other sources (Tatoeba CC BY 2.0, OpenSubtitles CC BY, FineWeb2 ODC-By) require attribution. Any redistribution of the weights must keep this license and credit the sources listed above. reference/: FUTO's official English model, for local validation only — do not redistribute; re-download from https://huggingface.co/breadlicker45/futo-keyboard-lm.
References
- FUTO Keyboard source: https://github.com/futo-org/android-keyboard (
native/jni/src/ggml/ModelMeta.*,org_futo_inputmethod_latin_xlm_LanguageModel.cpp,java/.../xlm/TrainingDataGenerator.kt) - Official English model (reference):
reference/ml4_1_f16_meta_fixed.gguf(frombreadlicker45/futo-keyboard-lmon Hugging Face) - German pipeline this is adapted from: https://github.com/jblechert/keyboard-lm-de
- Greek pipeline matching the official 36M spec: https://github.com/stamchry/greek-keyboard-lm
- llama.cpp (quantize/inference): https://github.com/ggml-org/llama.cpp