Back to News Feed
Hugging Face Blog35d ago

LFM2.5-Encoders for Fast Long-Context Inference on CPU

Liquid AI has officially expanded its model ecosystem with the release of two high-performance encoder models: LFM2.5-Encoder-230M and LFM2.5-Encoder-350M. These new additions to the Hugging Face library are engineered to deliver the precision of significantly larger models while maintaining exceptional speed, even as input sequences grow. By optimizing for long-context efficiency, these models enable developers to run document-scale processing tasks on standard hardware, including commodity CPUs.

Why General-Purpose Encoders Matter

Following the recent launch of the LFM2.5-Retrievers—specialized tools for multilingual search—Liquid AI has pivoted toward a more versatile architecture. While retrievers are excellent for search, the new LFM2.5-Encoders are designed as general-purpose workhorses. Pre-trained using a masked-language objective, they are highly adaptable for a wide array of production NLP tasks, including:

  • Intent Routing: Directing user queries to the appropriate service or department.
  • Policy Linting: Ensuring text compliance against specific organizational guidelines.
  • PII Detection: Identifying and scrubbing sensitive personal information across 16 languages.
  • Text Classification: Categorizing long-form content with high accuracy.

The industry has long relied on the BERT architecture for these tasks, with recent iterations like ModernBERT pushing the boundaries of speed and context. The LFM2.5-Encoders represent the next evolutionary step, utilizing the LFM2 architecture to ensure that computational costs scale gracefully as input lengths increase.

Architectural Innovations

The LFM2.5-Encoders are derived from the LFM2 decoder backbones (230M and 350M parameters). To transform these causal decoders into robust bidirectional encoders, the team implemented several critical modifications:

1. Bidirectional Attention Masks: Unlike decoders that only look backward, these encoders allow each token to attend to its neighbors on both sides. 2. Non-Causal Short Convolutions: By applying symmetric padding, the model ensures that local context is integrated effectively from both directions. 3. Masked Language Modeling (MLM): During training, 30% of tokens are masked, forcing the model to develop a deep understanding of linguistic structure.

The training process occurs in two distinct phases. First, the models undergo a "General Language Competence" phase using a 1,024-token context on a massive web corpus. This is followed by a "Long-Context Adaptation" phase, which extends the window to 8,192 tokens, significantly enhancing the model's factual, legal, and multilingual reasoning capabilities.

Benchmark Performance

Liquid AI conducted a rigorous evaluation against 17 tasks sourced from GLUE, SuperGLUE, and various multilingual classification benchmarks. Across 14 different models, the results are compelling:

  • LFM2.5-Encoder-350M secured the fourth position, trailing only models that are significantly larger—including one 3.5B parameter model nearly ten times its size.
  • LFM2.5-Encoder-230M consistently outperformed ModernBERT-base and the entire EuroBERT family, despite having a smaller parameter footprint.

"LFM2.5-Encoders match or beat larger encoders on GLUE, SuperGLUE, and multilingual tasks, all while maintaining an 8,192-token context with latency that grows slowly as inputs get longer."

Unrivaled Inference Speed

The most significant advantage of the LFM2.5-Encoders is their performance on CPU hardware. When compared to ModernBERT-base at an 8,192-token context, the LFM2.5-Encoder-230M is approximately 3.7× faster.

While ModernBERT-base throughput drops sharply as input length increases—taking over 90 seconds for a full forward pass at 8,192 tokens—the LFM2.5-Encoder-230M completes the same task in roughly 28 seconds. This efficiency allows developers to process full legal contracts, lengthy transcripts, or complex support threads on standard laptop CPUs without needing expensive GPU clusters. On GPU hardware, the LFM2.5-Encoders also take the lead once the input length exceeds approximately 2,000 tokens, proving their superiority for long-context applications.

Practical Applications and Demos

Liquid AI has provided several live demos in CPU-only Hugging Face spaces to showcase the models' capabilities:

  • Zero-shot Prompt Routing: Defining custom routing lanes in plain text and scoring prompts against them in a single pass.
  • Zero-shot Policy Linting: Checking text against company rules with high-speed token-level scoring.
  • PII Detection: Identifying 40 types of sensitive data across 16 languages.
  • Masked-Diffusion Text Generation: A novel approach where the encoder acts as a chatbot, generating text through iterative unmasking.

Getting Started

For developers looking to integrate these models, the process is straightforward via the transformers library.

Loading the model:

from transformers import AutoModelForMaskedLM, AutoTokenizer
import torch

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

Whether you choose the 350M model for maximum accuracy or the 230M model for higher throughput and tighter hardware constraints, these encoders offer a cost-effective alternative to heavy generative LLMs for high-volume understanding tasks.

Conclusion

The release of the LFM2.5-Encoders marks a significant milestone for developers who require high-performance NLP without the overhead of massive generative models. By prioritizing CPU efficiency and long-context scalability, Liquid AI is making advanced document analysis accessible to a wider range of production environments.

For those interested in implementation, the full framework is open-sourced, and comprehensive tutorials on fine-tuning for specific tasks are available on the Liquid AI website.

*

Citation: Liquid AI (2026). LFM2.5-Encoders: Fast at Long Context, Even on CPU. Liquid AI Blog.