A full fine-tune of
LFM2.5-Encoder-350M
as a masked-diffusion instruction model that generates text by iteratively unmasking tokens instead of decoding left to right.
The model was SFT-trained on
mlabonne/open-perfectblend
, a dataset of roughly 1.39M conversations, for 3 epochs.
Masked diffusion is a natural extension of masked-language modeling: the model starts from masked answer tokens, repeatedly predicts all masked positions, fills the most confident tokens, and continues until the answer is complete.
Find more details about our encoders in our
blog post
.
💻
Demos
: Try this fine-tuned model running in a CPU-only Hugging Face space:
Masked-diffusion text generation
— run the encoder as a chatbot that generates text by iteratively unmasking instead of left to right.
Usage
Install the required packages:
pip install torch transformers
Run masked-diffusion text generation:
import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer
model_id = "LiquidAI/LFM2.5-Encoder-350M-Diffusion"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForMaskedLM.from_pretrained(model_id, trust_remote_code=True).eval()
messages = [{"role": "user", "content": "Give one short tip for writing clearer code."}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt")
num_new_tokens = 12
mask_id = tokenizer.mask_token_id
input_ids = torch.cat(
[inputs.input_ids, torch.full((1, num_new_tokens), mask_id, dtype=torch.long)],
dim=1,
)
attention_mask = torch.ones_like(input_ids)
with torch.no_grad():
for _ inrange(num_new_tokens):
mask_positions = (input_ids[0] == mask_id).nonzero(as_tuple=True)[0]
iflen(mask_positions) == 0:
break
logits = model(input_ids=input_ids, attention_mask=attention_mask).logits[0, mask_positions]
logits[:, len(tokenizer):] = -torch.inf
for token_id in tokenizer.all_special_ids:
if token_id != tokenizer.eos_token_id:
logits[:, token_id] = -torch.inf
probs = logits.softmax(dim=-1)
confidence, token_ids = probs.max(dim=-1)
best = confidence.argmax()
input_ids[0, mask_positions[best]] = token_ids[best]
generated = input_ids[0, inputs.input_ids.shape[1]:]
text = tokenizer.decode(generated, skip_special_tokens=True).split("[/Answer]")[0]
print(text.strip())
If you are interested in custom solutions with edge deployment, please contact
our sales team
.
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},
}
Runs of LiquidAI LFM2.5-Encoder-350M-Diffusion on huggingface.co
1.4K
Total runs
0
24-hour runs
79
3-day runs
165
7-day runs
263
30-day runs
More Information About LFM2.5-Encoder-350M-Diffusion huggingface.co Model
More LFM2.5-Encoder-350M-Diffusion license Visit here:
LFM2.5-Encoder-350M-Diffusion huggingface.co is an AI model on huggingface.co that provides LFM2.5-Encoder-350M-Diffusion's model effect (), which can be used instantly with this LiquidAI LFM2.5-Encoder-350M-Diffusion model. huggingface.co supports a free trial of the LFM2.5-Encoder-350M-Diffusion model, and also provides paid use of the LFM2.5-Encoder-350M-Diffusion. Support call LFM2.5-Encoder-350M-Diffusion model through api, including Node.js, Python, http.
LFM2.5-Encoder-350M-Diffusion huggingface.co is an online trial and call api platform, which integrates LFM2.5-Encoder-350M-Diffusion's modeling effects, including api services, and provides a free online trial of LFM2.5-Encoder-350M-Diffusion, you can try LFM2.5-Encoder-350M-Diffusion online for free by clicking the link below.
LiquidAI LFM2.5-Encoder-350M-Diffusion online free url in huggingface.co:
LFM2.5-Encoder-350M-Diffusion is an open source model from GitHub that offers a free installation service, and any user can find LFM2.5-Encoder-350M-Diffusion on GitHub to install. At the same time, huggingface.co provides the effect of LFM2.5-Encoder-350M-Diffusion install, users can directly use LFM2.5-Encoder-350M-Diffusion installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
LFM2.5-Encoder-350M-Diffusion install url in huggingface.co: