LFM2.5-350M JSON no-fence edit (weight-space programming)

This is a modified version of LiquidAI/LFM2.5-350M (commit 9921cd4d82c0e3986887aa4b376f9446729ef8a3). It is not an official Liquid AI release. The original model card is kept in README_LiquidAI_original.md and the original license in LICENSE.

What was changed

Only model.safetensors was modified, by a direct, gradient-free weight edit (no training, fine-tuning, LoRA, backpropagation or optimizer). 125,566 entries (0.0354% of 354,483,968 parameters) changed in two tensors:

tensor edit columns entries changed
model.layers.14.feed_forward.w2.weight rank-1 projection removing one direction 64 of 4608 63,374
model.layers.15.conv.out_proj.weight rank-1 projection removing one direction 64 of 1024 62,192

The removed direction is the final-norm-scaled difference between the output embeddings of the code-fence token and the {" token, applied to the columns with the largest measured push toward the fence. The exact sparse patch (original and new values for every changed entry) is in patch/chosen_patch.safetensors + .json, so the edit can be audited or reverted bitwise. All other files are unchanged copies of the base repository.

Why

When told to reply with JSON only, the base model almost always wraps the JSON in a markdown fence (```json ... ```), which breaks strict parsers. The edit targets that formatting habit.

Results (held-out prompts, RTX 3060, BF16)

12 unseen prompts, each decoded greedily and with 3 sampled seeds (T=0.7, top-p 0.95, top-k 50) = 48 replies.

base this model 3 matched random edits
strict JSON-only success 1/48 28/48 1/48 each
reply starts with a code fence 41/48 0/48 40 to 41 / 48
general sanity prompts 12/12 12/12 12/12
plain-text perplexity 44.54 44.58 44.52 to 44.70

Paired comparison with the base: 27 replies fixed, 0 broken (exact McNemar p = 1.5e-8). A request for a Python code block still produces a fenced code block.

Known limitations

  • Top-level JSON arrays regress: the model now tends to open with {, returning {"result": [...]} instead of a bare array (0/16 array replies correct).
  • One validation reply from a closely related candidate degenerated into repeated " characters.
  • This repairs a formatting habit; it adds no capability (content errors such as sorting or letter counting remain).
  • Small evaluation (12 held-out prompts per category, English, one prompt style). Not a reproduction of the Qwen3.5 weight-space programming result.

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "yasserrmd/LFM2.5-350M-JSON-NoFence"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype="bfloat16", device_map="auto")
msgs = [{"role": "user", "content": 'Convert to JSON with keys "name" and "age". Reply with JSON only.\nText: Tariq is 41.'}]
inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

License

Distributed under the LFM Open License v1.0 (see LICENSE), including its commercial-use threshold (Section 5). Modifications by Mohamed Yasser, November 2026.

Downloads last month
24
Safetensors
Model size
0.4B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for yasserrmd/LFM2.5-350M-JSON-NoFence

Finetuned
(92)
this model
Quantizations
1 model