Instructions to use Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8
- SGLang
How to use Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8 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 "Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8" \ --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": "Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8", "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 "Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8" \ --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": "Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8 with Docker Model Runner:
docker model run hf.co/Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8
LFM2.5-1.2B-Thinking-ToMoE-INT8
Weight-only INT8 quantization of the real ToMoE MoE — Nichonauta/LFM2.5-1.2B-Thinking-ToMoE (derived from LiquidAI/LFM2.5-1.2B-Thinking).
Unlike the GGUF companions (which are dense-equivalents because llama.cpp cannot represent the channel-MoE), this repository stores the actual pruned MoE weights quantized in safetensors format:
LinearINT8replaces the MLP/attention/conv Linear layers (per-channel symmetric for INT8; per-group of 64 with zero-point for INT4), packed 2-nibbles-per-byte for INT4.- The routers, embeddings and norms stay fp32 (tiny and sensitive); weights dequantize lazily in the forward pass.
- Same custom model definition (
modeling_lfm2_moe_final.py,trust_remote_code), plus thequantizationflag inconfig.json.
Metrics vs the fp32 MoE
| Metric | fp32 MoE | INT8 | INT4 |
|---|---|---|---|
| PPL wikitext-2 (raw, 1810 tok) | 504 | 504 | 504 |
| PPL chat-formatted (prompt+answer) | 712 | 709 | 723 |
model.safetensors size |
4230 MB | 1376 MB | — |
The 1.2B MoE is robust to weight-only quantization: INT8 and INT4 are within measurement noise of the fp32 MoE (raw PPL identical, chat within ~1.5%).
Usage (transformers, trust_remote_code)
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
device_map="cuda:0",
attn_implementation="eager",
)
tokenizer = AutoTokenizer.from_pretrained("Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8")
The quantization field in config.json makes the custom modeling file build the quantized Linear layers automatically.
Files
model.safetensors— INT8 weights + fp32 scales/zero-points + fp32 routers/embeddings/buffersmodeling_lfm2_moe_final.py— custom model definition withLinearINT8support (trust_remote_code)config.json— model configuration (quantization: "int8",auto_map)tokenizer.json,tokenizer_config.json,chat_template.jinja,generation_config.json,LICENSE
License
Derivative of LiquidAI/LFM2.5-1.2B-Thinking — released under the LFM Open License v1.0 (see LICENSE).
- Downloads last month
- 32
Model tree for Nichonauta/LFM2.5-1.2B-Thinking-ToMoE-INT8
Base model
LiquidAI/LFM2.5-1.2B-Base