Instructions to use experimentalmachines/LFM2.5-1.2B-Instruct-heretic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use experimentalmachines/LFM2.5-1.2B-Instruct-heretic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="experimentalmachines/LFM2.5-1.2B-Instruct-heretic") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("experimentalmachines/LFM2.5-1.2B-Instruct-heretic") model = AutoModelForCausalLM.from_pretrained("experimentalmachines/LFM2.5-1.2B-Instruct-heretic", 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 experimentalmachines/LFM2.5-1.2B-Instruct-heretic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "experimentalmachines/LFM2.5-1.2B-Instruct-heretic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "experimentalmachines/LFM2.5-1.2B-Instruct-heretic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/experimentalmachines/LFM2.5-1.2B-Instruct-heretic
- SGLang
How to use experimentalmachines/LFM2.5-1.2B-Instruct-heretic 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 "experimentalmachines/LFM2.5-1.2B-Instruct-heretic" \ --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": "experimentalmachines/LFM2.5-1.2B-Instruct-heretic", "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 "experimentalmachines/LFM2.5-1.2B-Instruct-heretic" \ --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": "experimentalmachines/LFM2.5-1.2B-Instruct-heretic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use experimentalmachines/LFM2.5-1.2B-Instruct-heretic with Docker Model Runner:
docker model run hf.co/experimentalmachines/LFM2.5-1.2B-Instruct-heretic
experimentalmachines/LFM2.5-1.2B-Instruct-heretic
Abliterated ("uncensored") version of LiquidAI/LFM2.5-1.2B-Instruct, produced with
heretic: directional ablation of the refusal direction in the residual
stream, with a TPE search over per-layer ablation weights that minimises both the refusal rate and the
KL divergence from the original model. Weights are merged, so this loads as a plain Lfm2ForCausalLM.
Chat template, tool-calling tokens and everything else are unchanged from the base model.
heretic Pareto front for this run
study: ./checkpoints/LiquidAI--LFM2--5-1--2B-Instruct.jsonl
completed trials: 200 / 200
idx trial refusals KL direction_index
0 133 0.06 0.0527 10.198270144464333
1 150 0.07 0.0402 10.32046799180982
2 157 0.11 0.0344 10.352822192960996
3 170 0.17 0.0316 10.690289415212908
4 169 0.18 0.0283 10.969840642119093
5 195 0.41 0.0232 9.737856473201463
6 63 0.43 0.0227 None
7 143 0.46 0.0217 11.294404725756008
8 158 0.49 0.0174 11.119204885113456
9 186 0.53 0.0170 10.5853942209232
10 191 0.63 0.0157 11.178660347171663
11 72 0.66 0.0124 11.153256538028568
12 161 0.79 0.0102 10.51671121861693
13 102 0.84 0.0097 11.205828382998588
14 59 0.87 0.0093 10.78726439886388
15 76 0.90 0.0061 None
16 164 0.91 0.0058 10.51819047303982
17 182 0.96 0.0028 None
18 26 0.98 0.0006 None
selected pareto index: 0
ExecuTorch (CPU, KleidiAI on Arm)
| file | max context (tokens) | size |
|---|---|---|
executorch/lfm2_5_1_2b_heretic_8da4w_32k.pte |
32,768 | 0.83 GB |
Each is an ExecuTorch 1.4.1 program for the XNNPACK backend built with ExecuTorch's own LFM2 recipe: every linear
layer is quantised to 8-bit dynamic per-token activations and 4-bit grouped weights with group size 32 (8da4w,
the layout Arm's KleidiAI int4 kernels are written for), int8 embedding table, static KV cache, fused SDPA,
2048-token prefill chunk (longer prompts are prefilled in chunks; the context window is the figure in the table).
XNNPACK dispatches these matmuls to KleidiAI on every Arm CPU
(Apple Silicon, Snapdragon, Dimensity, Tensor, Graviton) in the stock ExecuTorch build; on x86 it falls back to AVX
kernels. The program is the same file on every platform.
The KV cache for the full window is allocated when the program loads (fp32, about 0.8 GB for 1.2B and 1.1 GB for
2.6B); the runtime attends over filled positions only, so the window costs memory, not speed. Run it with llama_main from ExecuTorch (examples/models/llama)
or the python runner, with this repo's tokenizer.json and the prompt format
<|startoftext|><|im_start|>user\n...<|im_end|>\n<|im_start|>assistant\n.
Pipeline
Reproducible end to end from https://github.com/ (see the repository this was built with):
make setup abliterate pareto, make save TRIAL=<idx>, make export, make publish.
Use responsibly; the safety training of the base model has been removed on purpose.
- Downloads last month
- 424
Model tree for experimentalmachines/LFM2.5-1.2B-Instruct-heretic
Base model
LiquidAI/LFM2.5-1.2B-Base