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

Liquid AI released LFM2.5-Encoder-230M and LFM2.5-Encoder-350M, general-purpose encoder models built from the LFM2.5 decoder backbones. The models use bidirectional attention, non-causal short convolutions, and a 30% masked-language modeling objective. They are trained in two stages: a short-context (1,024 tokens) masked-language objective on a large web corpus, followed by a long-context (8,192 tokens) adaptation phase on the full data mix.

The encoders match or beat larger models on GLUE, SuperGLUE, and multilingual classification benchmarks. LFM2.5-Encoder-350M ranks fourth of 14 models, with the three ahead all being larger (including a 3.5B model nearly 10 times its size). LFM2.5-Encoder-230M beats ModernBERT-base and every EuroBERT model despite being smaller. Both score well above the LFM2.5-Retrievers.

Inference speed measurements show the biggest edge on CPU. LFM2.5-Encoder-230M is fastest at every sequence length, including shorter inputs, compared to ModernBERT. At 8,192 tokens, ModernBERT-base takes over 90 seconds per forward pass versus about 28 seconds for LFM2.5-Encoder-230M, roughly 3.7× faster. On GPU, ModernBERT-base leads below ~1K tokens on Apple hardware, but the Liquid encoders take the lead from about 2K tokens.

Use cases include intent routers, policy linters, PII detectors, text classifiers, and spell checking. The blog provides CPU-only Hugging Face demo spaces for zero-shot prompt routing, policy linting, spell checking, and PII detection. The models are open-weight on Hugging Face. A fine-tuning tutorial covers adapting the encoder for long legal documents with an 8K context. Load the models with transformers and run masked-token prediction directly, or attach a custom head for classification or token-level tasks.

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

View Original