LFM3-1.7B-Heretic-NX
By the author of MLXL3, a free, open-source app to run EXL3 models locally on Apple Silicon and Windows GPUs. If my work helps you, a ⭐ on GitHub is appreciated.
A conditional weight edit of LiquidAI/LFM3-1.7B, built with Heretic NX. The BF16 checkpoint has 4/104 lexical refusal markers versus 95/104 for the original, with mean full-vocabulary first-token KL(base || NX) = 0.045014. The target set includes harmful requests; this experiment is not limited to false refusals. These counts are a lexical proxy, not semantic task success or a guarantee of zero refusals on arbitrary prompts.
Files
| Format | File | Size |
|---|---|---|
| BF16 | model.safetensors | 3,457,635,448 bytes |
| GGUF Q8_0 | LFM3-1.7B-Heretic-NX-Q8_0.gguf | 1,846,237,824 bytes |
Both formats represent the same selected weight edit. The Q8 artifact is converted from the final BF16 checkpoint and evaluated separately. Custom LFM3 Python model code, tokenizer, original license, modification NOTICE, build records, compact evaluation reports and fitted rank-one factors are included. Raw target generations and activation caches are not distributed.
Measured results
Evaluation uses thinking disabled, greedy generation, a maximum of 96 new tokens, the original chat template, no prompt truncation, and pinned dataset revisions. KL averages only the first generated-token distribution on 104 benign prompts over all 128,000 vocabulary entries. It is not sequence KL.
| BF16 evaluation | Original | Heretic NX |
|---|---|---|
| Target lexical refusal markers / 104 | 95 | 4 |
| Safe lexical refusal markers / 104 | 3 | 2 |
| Empty responses on either 104-row set | 0 | 0 |
| Mean first-token KL to original | 0 | 0.045014 |
| Paired MCQ slice / 241 | 128 (53.11%) | 128 (53.11%) |
| Expanded MCQ slice / 854 | 450 (52.69%) | 446 (52.22%) |
The expanded MCQ difference is -0.47 percentage point; the paired bootstrap interval at alpha 0.025 is [-3.12, +2.19] points. The predeclared three-point noninferiority gate remains inconclusive. Equal scores on the 241-row slice do not establish broad capability equivalence.
| Matched native Q8_0 evaluation | Original Q8_0 | Heretic NX Q8_0 |
|---|---|---|
| Target lexical refusal markers / 104 | 96 | 3 |
| Safe lexical refusal markers / 104 | 3 | 1 |
| Empty responses on either 104-row set | 0 | 0 |
| Mean first-token KL to original Q8_0 | 0 | 0.046333 |
| Expanded MCQ slice / 854 | 438 (51.29%) | 438 (51.29%) |
Native Q8_0 uses llama.cpp b12088-d1044bc82 on the same Apple M5, context 4096, one slot, full GPU offload and F16 KV cache. Both arms use the same quantizer recipe and exact HF prompt token IDs. All full-vocabulary native probabilities are checked and normalized in float64 before KL. MCQ uses greedy single-letter selection, checked against the raw A/B/C/D argmax on three rows per arm. The Q8 MCQ difference is 0.00 point with a nominal alpha-0.025 interval of [-3.18, +3.18] points; the three-point noninferiority gate is also inconclusive. These results measure the Q8 artifact itself and are not transferred from BF16.
The 104-row retest was reused to choose between two frozen frontier checkpoints. It is not an untouched holdout. Detector fitting uses separate hash-partitioned training geometry data, and development search uses another training partition. Reports pin revisions, row hashes and the exact selected weights. No external semantic judge has certified the final checkpoint.
French prose and exact-JSON smoke checks passed for BF16. The arithmetic
smoke test 37 × 19 failed in both the original and the edit; the correct
answer is 703. For Q8, the edited model produced the correct value 703 but added an equation
and repeated the answer, failing the exact-output constraint; the original Q8
returned 3983. This model can still generate incorrect or malformed output.
Use with Transformers
The full checkpoint was tested with Python 3.12, PyTorch 2.15.0 and Transformers 5.22.2 on Apple M5 / 24 GiB, using MPS and BF16. Full-checkpoint CPU and CUDA execution has not been tested.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "0xzknw/LFM3-1.7B-Heretic-NX"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
repo, trust_remote_code=True, dtype=torch.bfloat16,
).to("mps") # choose a device supported by your environment
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "À quoi sert une sauvegarde de fichiers ?"},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=False,
)
inputs = tokenizer(text, add_special_tokens=False, return_tensors="pt").to(model.device)
with torch.inference_mode():
outputs = model.generate(**inputs, do_sample=False, max_new_tokens=96)
print(tokenizer.decode(outputs[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))
Use with llama.cpp
The GGUF was converted, quantized and tested with llama.cpp b12088, commit d1044bc82, which supports LFM3. Other runtime versions have not been validated. Download with the existing Hugging Face CLI:
hf download 0xzknw/LFM3-1.7B-Heretic-NX \
LFM3-1.7B-Heretic-NX-Q8_0.gguf --local-dir ./lfm3-nx
llama-server -m ./lfm3-nx/LFM3-1.7B-Heretic-NX-Q8_0.gguf \
-ngl 99 -c 4096 --parallel 1 --cache-type-k f16 --cache-type-v f16 \
--temp 0 --chat-template-kwargs '{"enable_thinking":false}'
Native validation supplies pretokenized IDs from the same HF chat template,
with exactly one BOS and enable_thinking=False, to /completion. A server
frontend's default thinking/template settings may differ from this protocol.
The documented server settings were smoke-tested: native and HF template text
and token IDs match, exactly one BOS is present, and the OpenAI-compatible
chat endpoint returns the requested exact French JSON.
Build and provenance
- Base revision:
1da06bec6a819da10b54c67e5c90972b46d81871. - Base safetensors SHA-256:
135922caef64e81e52af88ede8b7c3ddaa9d6da220a9737fb3065275dbfb4330. - Final safetensors SHA-256:
875e4722c380b7b8b916fdc97c83ed1dd518db5df6ad12d9c029b18d5c6d5e40. - Final Q8_0 SHA-256:
5c979a09b41acb8e225a9f66c7c006ef732cf84e5571dd87a855d30048eb187a.
The implementation is pinned to Heretic NX commit 6869bf2. A stronger NX residual-stream edit serves as the frozen teacher. From 1,024 benign prompt-boundary states and 1,024 sampled target-trajectory states per site, the conditional method fits rank-one output axes and input detectors with a benign covariance penalty. The selected penalty is 10 and delta scale 1.5. Static additive deltas are merged into 40 output projections in blocks 4–23, including FFN, convolution and attention outputs. No runtime hooks or extra inference network are required. All other model tensors are bit-identical to the original; shapes and dtypes are preserved.
This conditional profile does not restore row norms; maximum measured relative drift is 5.81%. Its conjugate-gradient fits stop at the 40-iteration bound without reaching the 1e-5 tolerance. They are approximate fits, not certified optima. Development selection requires zero markers over 24 prompts and KL ≤ 0.05, then minimizes KL. The chosen development KL is 0.026208.
HERETIC_NX_BUILD.json records selection, source files, factors and data
manifests. HERETIC_NX_VALIDATION.json, HERETIC_NX_CAPABILITY_854.json,
HERETIC_NX_WEIGHT_AUDIT.json, HERETIC_NX_GGUF_BUILD.json and
HERETIC_NX_GGUF_VALIDATION.json contain compact measured evidence.
HERETIC_NX_GGUF_WEIGHT_AUDIT.json also verifies exactly 40 changed native
projection tensors and unchanged bytes for all remaining tensors.
heretic_nx/factors.safetensors contains the fitted factors; heretic_nx/fit.json
contains numerical diagnostics. See VERIFICATION.md for regression checks,
symbolic search scope and remaining verification gaps.
License and credits
The original LFM Open License v1.0 is preserved in LICENSE. See NOTICE for modification attribution. Thanks to Liquid AI for the base model and custom architecture implementation, @0xZKnw for Heretic NX, and the llama.cpp contributors for the native runtime and GGUF tools. This is a community derivative, not an official Liquid AI release.