Back to feed
News Story
APriority72
Hugging Face Blog
1 sources

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

The article introduces LFM2.5-Encoders, a new model designed for efficient long-context inference on CPUs. It aims to improve speed and performance for processing lengthy sequences without relying on specialized hardware.

SynthePulse Insight · AI deep reading

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

Version 1 · 1 source

Liquid AI releases LFM2.5-Encoder-230M and 350M, achieving approximately 3.7x faster long-context inference than ModernBERT-base while matching the performance of larger models.

  • LFM2.5-Encoder-230M and 350M support 8192 token context, with CPU inference speed about 3.7x that of ModernBERT-base.
  • On GLUE, SuperGLUE, and multilingual tasks, the 350M model ranks fourth, with the top three being larger models (including a 3.5B model).
  • The 230M model surpasses ModernBERT-base and all EuroBERT models on most benchmarks.
  • Models are initialized from LFM2.5 decoders and transformed into encoders via bidirectional attention masks and non-causal convolutions.
  • Training is conducted in two stages: short-context (1024 tokens) for general language ability, then long-context (8192 tokens) adaptation.
  • CPU demos are provided for zero-shot prompt routing, policy checking, spell checking, PII detection, etc.
Open section navigationModel Architecture and Training

Model Architecture and Training

LFM2.5-Encoders are initialized from LFM2.5 decoder backbones (230M and 350M) and transformed into bidirectional encoders through three modifications: bidirectional attention masks (each token can see tokens on both sides), non-causal short convolutions (symmetric padding to mix adjacent tokens), and masked language modeling with 30% token masking.

Training proceeds in two stages: first, short-context masked language modeling on web corpora with 1024 token context to acquire general language ability; then, long-context adaptation on the full data mixture with 8192 token context to strengthen factual, legal, and multilingual capabilities.

Performance Benchmarks

On 17 tasks from GLUE, SuperGLUE, and multilingual classification, 14 models were fully fine-tuned and average scores over five independent seeds were reported. LFM2.5-Encoder-350M ranks fourth, with the top three being larger models, including a 3.5B model nearly 10 times its size. LFM2.5-Encoder-230M outperforms ModernBERT-base and all EuroBERT models, and both significantly surpass Liquid AI's own LFM2.5-Retrievers.

Inference Speed: CPU vs. GPU

On CPU, LFM2.5-Encoder-230M is fastest across all sequence lengths, even faster than the smaller ModernBERT-base on short inputs. As input length increases, ModernBERT's throughput drops sharply, while LFM2.5-Encoders first rise then plateau. At 8192 tokens, ModernBERT-base takes over 90 seconds per forward pass, while LFM2.5-Encoder-230M takes about 28 seconds, a speedup of approximately 3.7x.

On GPU, ModernBERT-base leads below about 1K tokens, while LFM2.5-Encoders take the lead from about 2K tokens onward, indicating faster performance for long inputs.

Application Demos and Usage Guide

Liquid AI provides CPU demos based on fine-tuned LFM2.5-Encoders, including zero-shot prompt routing, zero-shot policy checking, spell checking, PII detection (covering 40 types of personal information in 16 languages), and masked diffusion text generation.

Users can load models via the Hugging Face transformers library, with support for Flash Attention 2 acceleration. The models have open weights and fine-tuning tutorials are provided.

Credibility boundary

This article's information comes from Liquid AI's official release on the Hugging Face blog, a first-party source. All performance data are self-reported by the company and have not been independently verified.

Insight takeaway

LFM2.5-Encoders achieve significant speed improvements in long-context CPU inference while maintaining competitive performance with larger models, offering a practical choice for high-throughput, low-cost NLP applications.

Primary report

Hugging Face Blog

Primary source