Instructions to use yasserrmd/LFM2.5-350M-JSON-NoFence with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yasserrmd/LFM2.5-350M-JSON-NoFence with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yasserrmd/LFM2.5-350M-JSON-NoFence") 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("yasserrmd/LFM2.5-350M-JSON-NoFence") model = AutoModelForCausalLM.from_pretrained("yasserrmd/LFM2.5-350M-JSON-NoFence", 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 yasserrmd/LFM2.5-350M-JSON-NoFence with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yasserrmd/LFM2.5-350M-JSON-NoFence" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yasserrmd/LFM2.5-350M-JSON-NoFence", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yasserrmd/LFM2.5-350M-JSON-NoFence
- SGLang
How to use yasserrmd/LFM2.5-350M-JSON-NoFence 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 "yasserrmd/LFM2.5-350M-JSON-NoFence" \ --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": "yasserrmd/LFM2.5-350M-JSON-NoFence", "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 "yasserrmd/LFM2.5-350M-JSON-NoFence" \ --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": "yasserrmd/LFM2.5-350M-JSON-NoFence", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yasserrmd/LFM2.5-350M-JSON-NoFence with Docker Model Runner:
docker model run hf.co/yasserrmd/LFM2.5-350M-JSON-NoFence
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