Text Generation
Transformers
Safetensors
lfm3
liquid
edge
conversational
custom-code
weight-edited
custom_code
Instructions to use cbert33/LFM3-1.7B-UtilityModel-edited-weights with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cbert33/LFM3-1.7B-UtilityModel-edited-weights with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cbert33/LFM3-1.7B-UtilityModel-edited-weights", trust_remote_code=True) 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("cbert33/LFM3-1.7B-UtilityModel-edited-weights", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("cbert33/LFM3-1.7B-UtilityModel-edited-weights", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cbert33/LFM3-1.7B-UtilityModel-edited-weights with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cbert33/LFM3-1.7B-UtilityModel-edited-weights" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cbert33/LFM3-1.7B-UtilityModel-edited-weights", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cbert33/LFM3-1.7B-UtilityModel-edited-weights
- SGLang
How to use cbert33/LFM3-1.7B-UtilityModel-edited-weights 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 "cbert33/LFM3-1.7B-UtilityModel-edited-weights" \ --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": "cbert33/LFM3-1.7B-UtilityModel-edited-weights", "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 "cbert33/LFM3-1.7B-UtilityModel-edited-weights" \ --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": "cbert33/LFM3-1.7B-UtilityModel-edited-weights", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cbert33/LFM3-1.7B-UtilityModel-edited-weights with Docker Model Runner:
docker model run hf.co/cbert33/LFM3-1.7B-UtilityModel-edited-weights
Update model card and weights to the final version (JSON validity and narration loop)
Browse files- README.md +23 -14
- WRITE-MANIFEST.json +13 -41
- model.safetensors +1 -1
README.md
CHANGED
|
@@ -9,8 +9,9 @@ tags:
|
|
| 9 |
- lfm3
|
| 10 |
- edge
|
| 11 |
- conversational
|
| 12 |
-
-
|
| 13 |
- weight-edited
|
|
|
|
| 14 |
language:
|
| 15 |
- en
|
| 16 |
- ar
|
|
@@ -33,21 +34,23 @@ base_model: LiquidAI/LFM3-1.7B
|
|
| 33 |
|
| 34 |
# LFM3-1.7B-UtilityModel-edited-weights
|
| 35 |
|
| 36 |
-
This is a weight-edited version of [LiquidAI/LFM3-1.7B](https://huggingface.co/LiquidAI/LFM3-1.7B), specialized for utility-agent use: JSON tool calls and less narration looping before the call. No training, no LoRA, no fine-tuning. Two static edits to the output head, derived from captured hidden states and applied to `lm_head` rows.
|
|
|
|
|
|
|
| 37 |
|
| 38 |
## JSON tool call improvement
|
| 39 |
|
| 40 |
-
**Stated goal:**
|
| 41 |
|
| 42 |
**How the weights were edited:**
|
| 43 |
- Untied the `lm_head` from the input embeddings (`tie_word_embeddings: false`); `embed_tokens` left byte-identical.
|
| 44 |
-
- Measured 59 antml decision states (the states that emit `<tool_call>`), and computed the mean final hidden state there
|
| 45 |
-
- Row 99 (`{`) shifted by +0.00453
|
| 46 |
-
- The 16 newline-family rows (207, 8, 469, 318, 604, 920, 833, 514, 703, 473, 64466, 64952, 96460, 95504, 3103, 13124) shifted by -0.00227
|
| 47 |
- All other tensors byte-identical (286/286 source tensors verified).
|
| 48 |
- Mechanism: at antml decision states the newline token `C-dot` (row 207) wins by ~29 logits over both `{` and `<`. Suppressing the newline family along the antml-state direction releases the brace gate; the readout is linear, so the push is exact.
|
| 49 |
|
| 50 |
-
**Before / after** (base = LiquidAI/LFM3-1.7B, edited =
|
| 51 |
|
| 52 |
| Metric | Base | Edited | Delta |
|
| 53 |
|---|---:|---:|---:|
|
|
@@ -61,32 +64,38 @@ This is a weight-edited version of [LiquidAI/LFM3-1.7B](https://huggingface.co/L
|
|
| 61 |
| prompts with >=1 parseable | 84% | 98% | +14 pts |
|
| 62 |
| prompts with all 3 parseable | 26/50 | 38/50 | +12 |
|
| 63 |
|
|
|
|
|
|
|
| 64 |
## Looping behavior
|
| 65 |
|
| 66 |
**Stated goal:** reduce the narration ramble the model writes before the tool call, without breaking JSON validity or output length.
|
| 67 |
|
| 68 |
**How the weights were edited:**
|
| 69 |
-
- Captured the sentence/newline decision states where the model keeps narrating: 12,415 boundary states from 100
|
| 70 |
- At continue boundaries the brace `{` sits at rank ~1,156 and ~18.9 logits below the actual next token; at commit boundaries it is rank ~4 and ~5.8 below. The structural decision is a ~14-logit swing.
|
| 71 |
-
- Computed the mean final hidden state at the 12,289 continue boundaries
|
| 72 |
-
- 33 JSON opener rows shifted by +0.0035
|
| 73 |
-
- All other tensors byte-identical. The
|
| 74 |
|
| 75 |
-
**Before / after** (base =
|
| 76 |
|
| 77 |
| Metric | Base | Edited | Delta |
|
| 78 |
|---|---:|---:|---:|
|
| 79 |
| ramble rate | 72.0% | 60.0% | -12 pts |
|
| 80 |
| pure JSON | 86.0% | 88.0% | +2 pts |
|
| 81 |
| parseable | 88.0% | 88.0% | 0 |
|
|
|
|
| 82 |
| mean gen tokens | 2238 | 1786 | -20% |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
## Files and reproducibility
|
| 86 |
|
| 87 |
- `model.safetensors` - the edited weights (bf16, 3.98 GB).
|
| 88 |
- `config.json` - `tie_word_embeddings: false`.
|
| 89 |
-
-
|
| 90 |
- Base model: LiquidAI/LFM3-1.7B. The edits are static `lm_head` row shifts, not training.
|
| 91 |
|
| 92 |
---
|
|
@@ -666,4 +675,4 @@ At 1,024 concurrent requests, LFM3-1.7B can produce 3.6 billion tokens/day on on
|
|
| 666 |
}
|
| 667 |
```
|
| 668 |
|
| 669 |
-
For questions and feedback, join [Discord](https://discord.com/invite/liquid-ai). For custom deployment and fine-tuning support, [contact Liquid AI](https://www.liquid.ai/connect?utm_source=huggingface&utm_medium=referral&utm_campaign=huggingface).
|
|
|
|
| 9 |
- lfm3
|
| 10 |
- edge
|
| 11 |
- conversational
|
| 12 |
+
- custom_code
|
| 13 |
- weight-edited
|
| 14 |
+
- abliterated
|
| 15 |
language:
|
| 16 |
- en
|
| 17 |
- ar
|
|
|
|
| 34 |
|
| 35 |
# LFM3-1.7B-UtilityModel-edited-weights
|
| 36 |
|
| 37 |
+
This is a weight-edited version of [LiquidAI/LFM3-1.7B](https://huggingface.co/LiquidAI/LFM3-1.7B), specialized for utility-agent use: JSON tool calls instead of XML, and less narration looping before the call. No training, no LoRA, no fine-tuning. Two static edits to the output head, derived from captured hidden states and applied to `lm_head` rows.
|
| 38 |
+
|
| 39 |
+
The edits stack. RC1 is the JSON-format edit; RC2 adds the looping edit on top.
|
| 40 |
|
| 41 |
## JSON tool call improvement
|
| 42 |
|
| 43 |
+
**Stated goal:** emit a JSON tool call (`{"name": ..., "arguments": ...}`) instead of the XML `<tool_call><function=...>` format, at the model card's standard sampling settings (temperature 0.1, top_k 50, repetition_penalty 1.1).
|
| 44 |
|
| 45 |
**How the weights were edited:**
|
| 46 |
- Untied the `lm_head` from the input embeddings (`tie_word_embeddings: false`); `embed_tokens` left byte-identical.
|
| 47 |
+
- Measured 59 antml decision states (the states that emit `<tool_call>`), and computed `hbar_a`, the mean final hidden state there (L2 norm 73.21).
|
| 48 |
+
- Row 99 (`{`) shifted by `+0.00453 * hbar_a`.
|
| 49 |
+
- The 16 newline-family rows (207, 8, 469, 318, 604, 920, 833, 514, 703, 473, 64466, 64952, 96460, 95504, 3103, 13124) shifted by `-0.00227 * hbar_a`.
|
| 50 |
- All other tensors byte-identical (286/286 source tensors verified).
|
| 51 |
- Mechanism: at antml decision states the newline token `C-dot` (row 207) wins by ~29 logits over both `{` and `<`. Suppressing the newline family along the antml-state direction releases the brace gate; the readout is linear, so the push is exact.
|
| 52 |
|
| 53 |
+
**Before / after** (base = LiquidAI/LFM3-1.7B, edited = RC1; seed-11 slice, 50 prompts x 3 samples = 150 per arm, standard sampling):
|
| 54 |
|
| 55 |
| Metric | Base | Edited | Delta |
|
| 56 |
|---|---:|---:|---:|
|
|
|
|
| 64 |
| prompts with >=1 parseable | 84% | 98% | +14 pts |
|
| 65 |
| prompts with all 3 parseable | 26/50 | 38/50 | +12 |
|
| 66 |
|
| 67 |
+
**Final version:** the JSON-format edit above, plus the opener boost and the embedding edit. Final JSON validity at standard sampling: 88.0% pure JSON and 88.0% parseable on the seed-14 slice (50 prompts, 12.0% malformed); 100.0% pure JSON and 100.0% parseable on the held-out seed-15 slice (20 prompts, 0.0% malformed).
|
| 68 |
+
|
| 69 |
## Looping behavior
|
| 70 |
|
| 71 |
**Stated goal:** reduce the narration ramble the model writes before the tool call, without breaking JSON validity or output length.
|
| 72 |
|
| 73 |
**How the weights were edited:**
|
| 74 |
+
- Captured the sentence/newline decision states where the model keeps narrating: 12,415 boundary states from 100 seed-13 outputs (12,289 continue, 126 commit).
|
| 75 |
- At continue boundaries the brace `{` sits at rank ~1,156 and ~18.9 logits below the actual next token; at commit boundaries it is rank ~4 and ~5.8 below. The structural decision is a ~14-logit swing.
|
| 76 |
+
- Computed `hbar_con`, the mean final hidden state at the 12,289 continue boundaries (L2 norm 40.86).
|
| 77 |
+
- 33 JSON opener rows shifted by `+0.0035 * hbar_con`. The rows are opener tokens only (`{C-dot`, `{"`, `{`, `{\"`, `{'`, `{C-dotC-dot`, `{\`, `{ex`, `[{"`, ...), excluding every `}` and every LaTeX brace token.
|
| 78 |
+
- All other tensors byte-identical. The 3a rows (row 99 and the newline family) are unchanged except row 99, which is also an opener row and carries both deltas.
|
| 79 |
|
| 80 |
+
**Before / after** (base = RC1, edited = RC2; seed-14 fresh slice, 50 prompts x 1 sample per arm, standard sampling):
|
| 81 |
|
| 82 |
| Metric | Base | Edited | Delta |
|
| 83 |
|---|---:|---:|---:|
|
| 84 |
| ramble rate | 72.0% | 60.0% | -12 pts |
|
| 85 |
| pure JSON | 86.0% | 88.0% | +2 pts |
|
| 86 |
| parseable | 88.0% | 88.0% | 0 |
|
| 87 |
+
| malformed | 10.0% | 12.0% | +2 pts |
|
| 88 |
| mean gen tokens | 2238 | 1786 | -20% |
|
| 89 |
|
| 90 |
+
The 6 malformed samples are prose answers ("No further action required"), not brace loops; the prompt explicitly allows a short answer when the task is complete.
|
| 91 |
+
|
| 92 |
+
**Final version:** adds a token-embedding edit on rows 22 (`.`) and 39 (`?`), `+0.10 * d`, where `d` is the boundary brace-logit gradient minus the prose and post-brace states. Final ramble at standard sampling: 64.0% on the seed-14 slice (50 prompts, from 74.0% before the embedding edit), median narration 508 words (from 693), mean tokens 1951. Held-out seed-15 (20 prompts): 75.0% ramble vs the prior version 70.0%, calls 35% usable in both.
|
| 93 |
|
| 94 |
## Files and reproducibility
|
| 95 |
|
| 96 |
- `model.safetensors` - the edited weights (bf16, 3.98 GB).
|
| 97 |
- `config.json` - `tie_word_embeddings: false`.
|
| 98 |
+
- `WRITE-MANIFEST.json` - exact row ids, beta values, direction norms, verification flags.
|
| 99 |
- Base model: LiquidAI/LFM3-1.7B. The edits are static `lm_head` row shifts, not training.
|
| 100 |
|
| 101 |
---
|
|
|
|
| 675 |
}
|
| 676 |
```
|
| 677 |
|
| 678 |
+
For questions and feedback, join [Discord](https://discord.com/invite/liquid-ai). For custom deployment and fine-tuning support, [contact Liquid AI](https://www.liquid.ai/connect?utm_source=huggingface&utm_medium=referral&utm_campaign=huggingface).
|
WRITE-MANIFEST.json
CHANGED
|
@@ -1,42 +1,14 @@
|
|
| 1 |
-
{
|
| 2 |
-
"
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
87907,
|
| 15 |
-
91613,
|
| 16 |
-
10259,
|
| 17 |
-
65912,
|
| 18 |
-
63933,
|
| 19 |
-
9042,
|
| 20 |
-
14485,
|
| 21 |
-
827,
|
| 22 |
-
2025,
|
| 23 |
-
105938,
|
| 24 |
-
17315,
|
| 25 |
-
29973,
|
| 26 |
-
6601,
|
| 27 |
-
98331,
|
| 28 |
-
36813,
|
| 29 |
-
48989,
|
| 30 |
-
14475,
|
| 31 |
-
22481,
|
| 32 |
-
20677,
|
| 33 |
-
104900,
|
| 34 |
-
33565,
|
| 35 |
-
25856,
|
| 36 |
-
10445,
|
| 37 |
-
18976
|
| 38 |
-
],
|
| 39 |
-
"arithmetic": "bf16 add",
|
| 40 |
-
"json_edit_rows_unchanged": true,
|
| 41 |
-
"untouched_rows_identical": true
|
| 42 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"beta_push": 0.1,
|
| 3 |
+
"variant": "rc6-embed-dotq",
|
| 4 |
+
"edited_ids": [
|
| 5 |
+
22,
|
| 6 |
+
39
|
| 7 |
+
],
|
| 8 |
+
"direction_norm": 11.436189651489258,
|
| 9 |
+
"source": "D:\\projects\\model edit\\lfm-weight-edit\\edited\\LFM3-1.7B-RC3",
|
| 10 |
+
"key": "model.embed_tokens.weight",
|
| 11 |
+
"arithmetic": "fp32 add then bf16 cast on embed_tokens rows",
|
| 12 |
+
"untouched_rows_identical": true,
|
| 13 |
+
"verified_at": "2026-11-12 21:39:11"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 3981923520
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:271c4f16b818a8b9323adebb1d42a4d7ec2f6d9c356f56053eeeed50fe08ce91
|
| 3 |
size 3981923520
|