Instructions to use summerAIO/Diffusion-LFM3-1.7B-pre with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use summerAIO/Diffusion-LFM3-1.7B-pre with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="summerAIO/Diffusion-LFM3-1.7B-pre", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("summerAIO/Diffusion-LFM3-1.7B-pre", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("summerAIO/Diffusion-LFM3-1.7B-pre", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use summerAIO/Diffusion-LFM3-1.7B-pre with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "summerAIO/Diffusion-LFM3-1.7B-pre" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "summerAIO/Diffusion-LFM3-1.7B-pre", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/summerAIO/Diffusion-LFM3-1.7B-pre
- SGLang
How to use summerAIO/Diffusion-LFM3-1.7B-pre with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "summerAIO/Diffusion-LFM3-1.7B-pre" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "summerAIO/Diffusion-LFM3-1.7B-pre", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "summerAIO/Diffusion-LFM3-1.7B-pre" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "summerAIO/Diffusion-LFM3-1.7B-pre", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use summerAIO/Diffusion-LFM3-1.7B-pre with Docker Model Runner:
docker model run hf.co/summerAIO/Diffusion-LFM3-1.7B-pre
Diffusion-LFM3-1.7B
An experimental block-diffusion language model fine-tuned from LiquidAI/LFM3-1.7B-Base (by Liquid AI).
Text is generated block by block (block length 32): blocks are produced autoregressively, and tokens inside each block are produced by iterative masked-diffusion denoising with confidence-threshold parallel decoding.
โ ๏ธ This is a research preview trained for only 377 optimizer steps. Outputs may contain repeated words, truncated words, and factual errors. Not suitable for production use.
Modifications from the base model
This repository contains a modified version of LiquidAI/LFM3-1.7B-Base:
- Added the special token
<|mdm_mask|>and resized the tied embeddings. - Fine-tuned all weights with a block-diffusion objective (clean context blocks + one noised block, 1/t-weighted cross-entropy, complementary masking, Dream-style logit shift).
- At load time,
blockdiff_inference.pypatches the attention mask to block-causal (bidirectional within a block, causal across blocks; sliding-window layers keep a symmetric window) and replaces the causal short convolutions with centered ones. The original modeling code files are included unmodified.
Loading this model with plain generate() will not work correctly; use the script below.
Usage
# pip install -U "transformers>=5.12" huggingface_hub
from huggingface_hub import hf_hub_download
import importlib.util, sys
path = hf_hub_download("summerAIO/Diffusion-LFM3-1.7B", "blockdiff_inference.py")
spec = importlib.util.spec_from_file_location("blockdiff_inference", path)
bd = importlib.util.module_from_spec(spec); spec.loader.exec_module(bd)
model, tok, mask_id = bd.load("summerAIO/Diffusion-LFM3-1.7B")
print(bd.generate(model, tok, mask_id, "The capital of France is", gen_len=128, tau=0.9))
tau controls parallelism: lower = more tokens per forward pass (faster), higher = better quality.
Training
- Base:
LiquidAI/LFM3-1.7B-Base - Data: HuggingFaceFW/fineweb-edu (
sample-10BT) - Block length 32, context up to 15 blocks, lr 2e-05, AdamW, bf16
- 377 optimizer steps
License
This model is a derivative of LiquidAI/LFM3-1.7B-Base and is distributed under the
LFM Open License v1.0 โ see LICENSE and NOTICE.
- Commercial use is permitted only for individuals/legal entities with annual revenue under US$10 million (see Section 5 of the license). Qualified non-profits may use it for non-commercial or research purposes regardless of that threshold.
- Any redistribution must include the license, retain attribution notices, and state modifications.
- This project is not affiliated with or endorsed by Liquid AI. "LFM" and "Liquid AI" are used only to identify the origin of the base model.
Attribution
Base model: LiquidAI/LFM3-1.7B-Base ยฉ Liquid AI.
- Downloads last month
- -
Model tree for summerAIO/Diffusion-LFM3-1.7B-pre
Base model
LiquidAI/LFM3-1.7B-Base