LFM2.5-Encoders: Fast at Long Context, Even on CPU
Today, we release two new encoder models: LFM2.5-Encoder-230M and LFM2.5-Encoder-350M. Both are bidirectional encoders built on the LFM2 hybrid architecture. They are designed to be fine-tuned for classification, natural language understanding, and token-level tasks. On these, they match the quality of larger encoders while scaling much more gently with input length up to a context length of 8,192 tokens. This keeps document-scale workloads fast on the hardware you already have, including CPU-only environments.
The LFM2.5-Encoder-230M and LFM2.5-Encoder-350M models are available today on Hugging Face. Check out our docs on how to run and fine-tune them locally.
Why a general-purpose encoder?
Last month, we released LFM2.5-Retrievers, a pair of models built for multilingual retrieval tasks. LFM2.5-Encoders are close relatives from the same LFM family, but they are built for a broader purpose. The earlier LFM2.5-Retrievers were trained for retrieval tasks, while the LFM2.5-Encoders are pre-trained with a masked-language objective, so they can be adapted to a range of downstream tasks, including classification, token-level tasks, and retrieval. Because retrieval is only a subset of what encoders enable, we chose to build a general-purpose encoder rather than adapt the existing retrievers to a new task.
Classifiers, intent routers, and safety filters are all built on encoders. They run constantly, often on CPUs rather than GPUs, and increasingly on longer inputs. Originally, BERT [1] established this pattern, and more recent releases such as ModernBERT [2] have shown how much potential there is to improve accuracy, speed, and context length. LFM2.5-Encoders continue that line of work on the LFM2 architecture, whose cost grows slowly as inputs get longer. The result is document-scale understanding that stays fast even without a GPU.
Architecture
The encoders build on the LFM2 hybrid backbone and are initialized from LFM2.5-230M and LFM2.5-350M, respectively. We adapt this causal decoder into a bidirectional encoder with a small set of changes:
- We replace the causal attention mask with a bidirectional one, so every token attends to both its left and right context.
- We make the LFM2 short convolutions non-causal by using symmetric center padding, so they mix local information around each token. In practice, this means each token's short convolution now reads from its neighbors on both sides, rather than only the tokens that came before it.
- We train with a masked language modeling objective, masking 30% of tokens. That is denser than BERT's 15%, following evidence that a higher mask rate helps at this scale [3].
Both models are trained in a two-phase process: Phase 1 establishes general language competence with a short-context masked-language objective on a large, packed web corpus, at a 1,024-token context. Phase 2 is a long-context adaptation phase, extending the context to 8,192 tokens on the full data mix, which strengthens the encoder's factual, legal, and multilingual competence.
Benchmarks
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.
We select the learning rate per task on held-out seeds, then report the mean across five fresh seeds that never participated in selection, so the numbers are stable from run to run. The full framework, per-task launchers, and raw results are open-sourced.
LFM2.5-Encoder-350M ranks fourth of the 14 models, behind only three larger ones, including a 3.5B model nearly 10 times its size. LFM2.5-Encoder-230M beats ModernBERT-base and every EuroBERT [4] while being smaller than most of them. Both LFM2.5-Encoders also score well above our own LFM2.5-Retrievers on these tasks, which is why we built a general-purpose encoder rather than reusing the retrievers.
Inference
The LFM2 backbone was built for fast inference, which our encoders inherit. For an encoder, speed comes down to how quickly it turns an input into a result, which depends on the input length. Since LFM2.5-Encoders and ModernBERT both natively support an 8,192-token context, we can measure that speed across the full supported range.
Our encoders show their biggest edge on CPU. Here, LFM2.5-Encoder-230M is the fastest model from 1K tokens up, and the gap widens with length. Both ModernBERT models’ throughput drops steeply with length, while our LFM2.5-Encoders climb to a peak in the mid-range before tapering, so they pull ahead and stay there. The gap widens with increasing input lengths: At 8,192 tokens, ModernBERT-base takes over a minute and a half per forward pass versus about 28 seconds for LFM2.5-Encoder-230M, which is about 3.7x faster.
A similar pattern holds on GPU, with a smaller margin: On the Apple GPU, ModernBERT-base is ahead below ~1K tokens. The LFM2.5-Encoders take the lead from about 2K, and the gap grows with context length.
For production-grade enterprise deployments, we have also developed an internal GPU inference stack that delivers extremely low-latency serving. Across all concurrency levels, LFM2.5-Encoders achieve considerably low end-to-end latency.
The takeaway is the same on both CPU and GPU: for long inputs, LFM2.5-Encoders are the faster choice, and on CPU, dramatically so. That is what makes them practical in the places encoders are hardest to run.
See it in action
The performance and latency results show that LFM2.5-Encoders are strongest for use cases with long inputs, especially on CPU. This combination matters most in three kinds of settings:
- Edge and embedded devices. A car's onboard compute, an industrial controller, or a consumer device rarely has a spare GPU, and often cannot afford a round trip to the cloud. A compact encoder handles intent routing, command classification, and content filtering directly on the CPU that is already there.
- Regulated and on-premise systems. In finance, healthcare, and legal work, documents are long and sensitive, and frequently cannot leave in-house infrastructure. An 8,192-token context is roughly 13 to 15 pages, so a single forward pass with LFM2.5-Encoders can classify a full contract, extract fields from a record, or route a case on the CPU in that environment, keeping the whole pipeline private.
- High-volume, cost-sensitive pipelines. A small encoder makes an inexpensive first pass in front of a larger model, filtering or triaging requests so the expensive model runs only when it is actually needed. On a CPU at scale, that saving adds up quickly.
A base encoder produces general-purpose representations, not task outputs, so you fine-tune it for each of these. Our fine-tuning tutorial shows you an example of how you can fine-tune our encoders on long legal documents with an 8k context configuration.
To show what that looks like, we built the demos below from fine-tuned LFM2.5-Encoders. Each runs on a CPU-only Hugging Face space, so you can try them on your own text right now.
Zero-shot prompt routing
Zero-shot prompt routing demo lets you define the routing lanes as free text. The model reads the whole prompt in one forward pass and scores it against every lane, GLiNER-style and whole-sentence. There is no fixed taxonomy, so you type your own categories, and it routes.
Zero-shot policy linting
Zero-shot policy linter demo checks text against your company's rules, which are free text. Add a rule like "Flag mentions of competitor companies," and the encoder scores every token against every rule in a single pass.
Spell checking
Spell checker demo checks your text against spelling or grammatical errors, such as wrong verb forms, repetition, or incorrect use of pronouns.
PII detection
The PII detection demo can spot and remove 40 kinds of personal information across 16 languages.
Bonus: Masked-diffusion text generation
As a bonus, masked diffusion chat demo runs the bidirectional MLM encoder as a masked-diffusion chatbot. The answer denoises from masks. It generates text by iteratively unmasking rather than predicting left-to-right. It is an unexpected use of an encoder, and a demonstration of what bidirectional MLM makes possible.
Get started with LFM2.5-Encoders
Both models are available on Hugging Face: LFM2.5-Encoder-230M and LFM2.5-Encoder-350M. Choose the 350M when accuracy matters most, and the 230M for tighter hardware or higher throughput. Both are built to be fine-tuned on your own data.
Every LFM2.5-Encoder model ships the same way.
- Open-weight. Download, fine-tune, and deploy without restrictions.
- Reproducible. The full sweep harness, per-cell launchers, raw result JSONs, and table scripts are open-sourced at github.com/Liquid4All/encoder_eval.
- A family. Two sizes let you trade accuracy for footprint as your deployment demands.
The edge AI future is here. We can't wait to see what you build.
Citation
Liquid AI, "LFM2.5-Encoders: Fast at Long Context, Even on CPU", Liquid AI Blog, Jul 2026
@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},
}References
[1] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. (2019). BERT: Pre-training of deep bidirectional transformers for language understanding. NAACL. https://aclanthology.org/N19-1423/
[2] Benjamin Warner, Antoine Chaffin, Benjamin Clavié, Orion Weller, Oskar Hallström, Said Taghadouini, Alexis Gallagher, Raja Biswas, Faisal Ladhak, Tom Aarsen, Nathan Cooper, Griffin Adams, Jeremy Howard, and Iacopo Poli. (2024). Smarter, better, faster, longer: A modern bidirectional encoder for fast, memory efficient, and long context finetuning and inference. ACL. https://aclanthology.org/2025.acl-long.127/
[3] Alexander Wettig, Tianyu Gao, Zexuan Zhong, and Danqi Chen. (2023). Should you mask 15% in masked language modeling? EACL. https://aclanthology.org/2023.eacl-main.217/
[4] Nicolas Boizard, Hippolyte Gisserot-Boukhlef, Duarte M. Alves, André Martins, Ayoub Hammal, Caio Corro, Céline Hudelot, Emmanuel Malherbe, Etienne Malaboeuf, Fanny Jourdan, Gabriel Hautreux, João Alves, Kevin El-Haddad, Manuel Faysse, Maxime Peyrard, Nuno M. Guerreiro, Patrick Fernandes, Ricardo Rei, and Pierre Colombo. (2025). EuroBERT: Scaling multilingual encoders for European languages. COLM. https://openreview.net/forum?id=jdOC24msVq
