Liquid AI
Try LFM β€’ Docs β€’ LEAP β€’ Discord

LFM2.5-Encoder-350M

LFM2.5-Encoder is a family of multilingual bidirectional encoders built on the LFM2 architecture, available in two sizes:

  • LFM2.5-Encoder-230M β€” a lightweight encoder for tight latency and memory budgets, punching above its size class.
  • LFM2.5-Encoder-350M (this model) β€” a larger sibling for maximum downstream quality.

Both are masked language models with full bidirectional attention, designed to be fine-tuned into task-specific models (classification, token classification, retrieval, reranking, and semantic similarity) across 15 languages, and to run efficiently on-device.

Find more details about our encoders in our blog post.

Key highlights:

  • Top quality for its size. Ahead of every model its size or smaller, and ~5 points above our own retrieval siblings.
  • General-purpose. 8k context, strong across NLI, paraphrase, sentiment, and multilingual tasks.
  • Fast and on-device. Matches or beats ModernBERT throughput, with a long-context edge on CPU.

πŸ’» Demos: We built the demos below from fine-tuned LFM2.5-Encoders. Each one runs in a CPU-only Hugging Face space:

  • Zero-shot prompt routing β€” define your own routing lanes as free text. The model scores the whole prompt against every lane in one pass.
  • Zero-shot policy linting β€” check text against your company's rules, written as free text. It scores every token against every rule in one pass.
  • Spell checking β€” correct misspellings token by token.
  • PII detection β€” spot and remove 40 kinds of personal information across 16 languages.
  • Masked-diffusion text generation β€” bonus: run the encoder as a chatbot that generates text by iteratively unmasking instead of left to right.

πŸ“„ Model details

Property LFM2.5-Encoder-230M LFM2.5-Encoder-350M
Type Bidirectional encoder (masked language model) Bidirectional encoder (masked language model)
Backbone LFM2 LFM2
Total parameters ~229.7M ~354.5M
Hidden size 1024 1024
Vocabulary size 65,536 65,536
Context length 8,192 tokens 8,192 tokens
License LFM Open License v1.0 LFM Open License v1.0

Supported languages: English, German, Spanish, French, Italian, Dutch, Polish, Portuguese, Arabic, Hindi, Japanese, Russian, Turkish, Vietnamese, Chinese (15).

Architecture. LFM2.5-Encoder is built on the LFM2 hybrid backbone, which interleaves gated short-convolution blocks with grouped-query attention. For encoder use, the causal mask is replaced with full bidirectional (non-causal) attention and the model is trained with a masked language modeling head. The encoder body is exposed as Lfm2BidirectionalModel; masked-LM loading uses Lfm2BidirectionalForMaskedLM. Both are wired through auto_map and require trust_remote_code=True.

Lfm2BidirectionalForMaskedLM(
  (lfm2): Lfm2BidirectionalModel
  (lm_head): Linear(in_features=1024, out_features=65536, bias=False)
)

Training. LFM2.5-Encoder-350M is adapted from the LFM2 base and trained with a masked language modeling objective on a large multilingual corpus. Pre-training uses a two-stage schedule that extends the context window to up to 8,192 tokens.

We recommend fine-tuning LFM2.5-Encoder-350M for a range of downstream tasks, such as:

  • Text classification: sentiment, topic, intent/routing, moderation, and business-text linting.
  • Token classification: named-entity recognition, span extraction, and sequence labeling.
  • Retrieval and reranking: a backbone for dense embedding or late-interaction (ColBERT-style) retrievers.
  • Semantic similarity: STS, paraphrase, and duplicate detection.
  • Natural language inference and extractive QA: sentence-pair reasoning and answer-span extraction.

πŸƒ How to run

Install the latest version of transformers:

pip install -U transformers

Run masked-token prediction:

from transformers import AutoModelForMaskedLM, AutoTokenizer
import torch

tok = AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-Encoder-350M", trust_remote_code=True)
mlm = AutoModelForMaskedLM.from_pretrained("LiquidAI/LFM2.5-Encoder-350M", trust_remote_code=True)

text = f"The capital of France is {tok.mask_token}."
enc = tok(text, return_tensors="pt")
with torch.no_grad():
    logits = mlm(**enc).logits
pos = (enc["input_ids"][0] == tok.mask_token_id).nonzero()[0].item()
print([tok.decode([t]).strip() for t in logits[0, pos].topk(5).indices.tolist()])
# -> ['Paris', 'Strasbourg', 'Paris', 'Lyon', 'Versailles']

For downstream tasks, load the encoder body and attach your own head (classification, token classification, regression, retrieval):

from transformers import AutoModel
body = AutoModel.from_pretrained("LiquidAI/LFM2.5-Encoder-350M", trust_remote_code=True)

If your GPU supports it, we recommend using LFM2.5-Encoder-350M with Flash Attention 2 to reach the highest efficiency. To do so, install Flash Attention as follows, then use the model as normal:

pip install flash-attn

πŸ“Š Performance

For each benchmark task, we run a full supervised fine-tune and report that fine-tuned model's score. The results below span 14 models across 17 tasks from GLUE, SuperGLUE, and multilingual classification tasks. The full evaluation harness is open-sourced in the eurobert-repro repository.

benchmark_ranking

17-task results (avg@5 fresh seeds Β± std)

Rank Model Params 17-task mean Β± std
1 XLM-R XL (3.5B) 3.5B 83.06 Β±1.16
2 ModernBERT-large (395M) 395M 81.68 Β±2.49
3 XLM-R large (560M) 560M 81.34 Β±1.66
4 LFM2.5-Encoder-350M (ours) 350M 81.02 Β±1.00
5 mDeBERTa-v3 (280M) 280M 80.37 Β±1.06
6 LFM2.5-Encoder-230M (ours) 230M 79.29 Β±1.02
7 ModernBERT-base (149M) 149M 78.19 Β±1.39
8 XLM-R base (280M) 280M 77.46 Β±1.63
9 EuroBERT-210M 210M 76.87 Β±2.00
10 mGTE-MLM (305M) 305M 76.53 Β±1.85
11 LFM2.5-ColBERT-350M 350M 76.18 Β±1.25
12 EuroBERT-610M 610M 75.87 Β±2.03
13 LFM2.5-Embedding-350M 350M 75.68 Β±0.83
14 EuroBERT-2.1B 2.1B 72.19 Β±5.59
Click to expand per-task results β€” all 17 tasks (avg@5 fresh seeds Β± std) ### Per-task results β€” all 17 tasks (avg@5 fresh seeds Β± std)
Model XNLI PAWS-X Amazon MASSIVE SeaHorse CoLA* SST-2* MRPC* STS-B* QQP* MNLI* QNLI* RTE* BoolQ* CB* WiC* WSC* ALL
XLM-R XL (3.5B) 87.12Β±0.45 93.30Β±0.41 62.29Β±0.05 88.21Β±0.32 59.51Β±3.52 84.58Β±1.18 95.69Β±0.30 87.65Β±1.69 90.20Β±0.93 91.72Β±0.07 90.09Β±0.11 94.47Β±0.28 82.38Β±3.51 83.70Β±0.24 89.88Β±3.72 66.55Β±1.37 64.62Β±1.58 83.06
ModernBERT-large (395M) 81.76Β±0.38 92.46Β±0.18 60.42Β±0.15 85.65Β±0.94 40.20Β±17.18 83.37Β±0.20 96.10Β±0.53 88.14Β±1.79 92.16Β±0.24 91.81Β±0.13 90.65Β±0.18 94.36Β±0.10 81.59Β±4.92 81.68Β±2.34 88.21Β±3.24 70.16Β±2.57 69.81Β±7.18 81.68
XLM-R large (560M) 84.69Β±0.59 93.23Β±0.78 61.58Β±0.13 88.50Β±0.17 56.12Β±2.31 83.34Β±1.75 93.83Β±1.04 88.77Β±2.15 91.35Β±0.23 90.48Β±0.23 88.29Β±0.07 93.08Β±0.23 80.79Β±3.14 80.54Β±0.79 78.21Β±8.69 66.24Β±5.41 63.65Β±0.43 81.34
LFM2.5-Encoder-350M (ours) 79.82Β±0.29 91.53Β±0.73 60.57Β±0.09 85.70Β±0.13 54.96Β±0.41 84.43Β±0.81 95.11Β±0.26 87.21Β±1.86 91.59Β±0.05 92.08Β±0.10 89.03Β±0.17 93.97Β±0.23 75.23Β±3.84 81.52Β±0.69 83.21Β±2.04 69.66Β±2.23 61.73Β±3.15 81.02
mDeBERTa-v3 (280M) 83.01Β±0.47 92.59Β±0.39 60.62Β±0.31 87.64Β±0.51 54.97Β±2.04 83.91Β±1.03 92.41Β±0.96 85.39Β±2.59 89.87Β±0.22 90.23Β±0.15 86.30Β±0.18 91.99Β±0.35 69.75Β±2.03 78.29Β±1.39 88.21Β±2.40 67.71Β±3.05 63.46Β±0.00 80.37
LFM2.5-Encoder-230M (ours) 77.63Β±0.31 90.86Β±0.24 59.97Β±0.21 85.52Β±0.69 54.61Β±0.62 81.42Β±1.56 94.08Β±0.37 80.20Β±2.66 90.99Β±0.12 91.71Β±0.07 87.98Β±0.22 92.96Β±0.37 67.29Β±1.97 76.54Β±1.01 83.21Β±4.48 70.31Β±1.34 62.69Β±1.05 79.29
ModernBERT-base (149M) 76.64Β±0.31 92.17Β±0.15 58.98Β±0.11 85.32Β±0.21 45.19Β±1.72 83.07Β±1.93 94.79Β±0.52 84.46Β±2.70 90.75Β±0.14 91.23Β±0.11 88.68Β±0.17 93.04Β±0.36 58.70Β±1.94 74.78Β±4.10 81.07Β±6.75 66.90Β±2.39 63.46Β±0.00 78.19
XLM-R base (280M) 78.20Β±0.80 91.36Β±0.41 60.01Β±0.12 87.47Β±0.49 51.08Β±3.75 81.17Β±1.07 91.97Β±0.18 86.47Β±0.76 88.27Β±0.36 89.21Β±0.04 83.07Β±0.21 90.17Β±0.32 62.60Β±7.03 71.43Β±1.64 79.64Β±7.53 61.25Β±3.00 63.46Β±0.00 77.46
EuroBERT-210M 80.83Β±0.35 91.94Β±0.31 59.94Β±0.16 86.36Β±0.67 45.16Β±16.60 72.75Β±1.30 90.64Β±0.92 80.74Β±2.99 89.29Β±0.23 90.75Β±0.09 85.63Β±0.28 91.49Β±0.27 54.95Β±2.56 71.68Β±2.35 86.79Β±2.40 64.64Β±2.01 63.27Β±0.43 76.87
mGTE-MLM (305M) 80.32Β±0.20 91.73Β±0.26 60.26Β±0.10 87.79Β±0.20 51.58Β±1.31 75.44Β±4.66 91.19Β±1.00 86.32Β±1.48 87.77Β±0.64 89.82Β±0.09 84.14Β±0.15 90.94Β±0.40 58.34Β±3.09 69.32Β±3.72 73.21Β±6.80 59.34Β±7.41 63.46Β±0.00 76.53
LFM2.5-ColBERT-350M 78.77Β±0.47 89.74Β±0.44 59.92Β±0.13 86.65Β±0.17 47.95Β±1.13 71.06Β±1.06 90.94Β±0.78 73.43Β±7.22 89.38Β±0.28 91.11Β±0.14 84.70Β±0.23 90.66Β±0.18 59.13Β±2.30 74.25Β±1.61 81.79Β±2.93 62.04Β±2.12 63.46Β±0.00 76.18
EuroBERT-610M 84.61Β±0.34 91.84Β±0.94 60.64Β±0.08 86.03Β±0.99 12.91Β±8.05 70.60Β±2.12 92.52Β±0.66 85.20Β±1.34 89.82Β±0.22 91.13Β±0.09 87.95Β±0.19 92.57Β±0.36 59.28Β±7.93 76.86Β±1.55 85.71Β±4.37 58.71Β±5.30 63.46Β±0.00 75.87
LFM2.5-Embedding-350M 78.59Β±0.11 89.13Β±0.63 60.47Β±0.13 87.03Β±0.21 50.19Β±0.90 72.54Β±0.68 91.70Β±0.69 77.45Β±1.31 89.38Β±0.09 91.14Β±0.13 84.70Β±0.12 90.62Β±0.50 55.38Β±1.74 70.17Β±1.99 71.43Β±3.57 63.10Β±1.28 63.46Β±0.00 75.68
EuroBERT-2.1B 70.52Β±14.22 92.34Β±0.19 60.45Β±0.70 85.40Β±1.36 6.84Β±6.81 68.99Β±0.67 92.50Β±1.03 82.94Β±3.10 66.44Β±32.36 91.03Β±0.29 81.56Β±16.62 93.56Β±0.25 53.29Β±0.79 77.23Β±6.77 82.86Β±5.14 57.90Β±4.75 63.46Β±0.00 72.19

* = dev split (GLUE/SuperGLUE test labels hidden). The 5 multilingual columns are labeled test. SeaHorse & STS-B are SpearmanΓ—100. All other tasks are accuracy.

Inference speed

The LFM2 backbone was built for fast inference, and the encoders inherit it. While ModernBERT-base is faster at short sequences in Apple GPU inputs, LFM2.5-Encoders overtake it as inputs grow. At long input sequences of 8k on CPU, the encoders run 3.3Γ— faster than ModernBERT-base.

inference_perf_cpu

inference_perf_gpu

πŸ”§ Fine-tuning

LFM2.5-Encoder-350M follows standard BERT-style fine-tuning. Attach a task head to the encoder body and train end-to-end. Suggested starting points (tune per task):

Hyperparameter Suggested range
Learning rate 1e-5 – 5e-5
Warmup ratio 0.1
Weight decay 0.1
Epochs 3 – 20 (early stopping, patience 3)
Precision bf16 autocast (fp32 master weights)

πŸ“¬ Contact

Citation

@article{liquidAI2026Encoders,
  author = {Liquid AI},
  title = {LFM2.5-Encoders: Fast at Long Context, Even on CPU},
  journal = {Liquid AI Blog},
  year = {2026},
  note = {www.liquid.ai/blog/lfm2-5-encoders},
}
Downloads last month
6,190
Safetensors
Model size
0.4B params
Tensor type
F32
Β·

Model tree for LiquidAI/LFM2.5-Encoder-350M

Finetuned
(16)
this model
Finetunes
20 models
Quantizations
1 model

Space using LiquidAI/LFM2.5-Encoder-350M 1

Collection including LiquidAI/LFM2.5-Encoder-350M

Article mentioning LiquidAI/LFM2.5-Encoder-350M