Add LiquidAgent-1.2B: fine-tune of LFM2.5-1.2B-Thinking for agent tasks (47 steps SFT)
Browse files- README.md +49 -57
- chat_template.jinja +9 -9
- config.json +1 -1
- generation_config.json +2 -2
- tokenizer_config.json +1 -1
README.md
CHANGED
|
@@ -1,82 +1,74 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
| 3 |
library_name: transformers
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
-
language:
|
| 6 |
-
- en
|
| 7 |
base_model: LiquidAI/LFM2.5-1.2B-Thinking
|
| 8 |
tags:
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
metrics:
|
| 15 |
-
- perplexity
|
| 16 |
---
|
| 17 |
|
| 18 |
# LiquidAgent-1.2B
|
| 19 |
|
| 20 |
-
A
|
| 21 |
-
traces, intended to pick up the agent-trace format and style (thinking + text +
|
| 22 |
-
tool calls). Built for the model request in
|
| 23 |
-
[Compactbot/model-requests#15](https://huggingface.co/spaces/Compactbot/model-requests)
|
| 24 |
-
(requested by @DedeProGames).
|
| 25 |
|
| 26 |
-
|
| 27 |
-
> which is distributed under the **LFM Open License v1.0** (a custom license;
|
| 28 |
-
> `license: other` on the Hub). That license carries a commercial-use threshold
|
| 29 |
-
> ($10M annual revenue). Read the base model's LICENSE before commercial use.
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
- **Params:** 1,170,340,608 (verified by loading the released weights).
|
| 35 |
-
- **Architecture:** 16 blocks — 10 LIV convolutional + 6 full-attention (GQA,
|
| 36 |
-
32 query / 8 KV heads), `block_dim`/`hidden_size` 2048, `intermediate_size`
|
| 37 |
-
12288, SwiGLU, RoPE (θ = 1e6), vocab 65536, max position 128000, tied
|
| 38 |
-
embeddings.
|
| 39 |
-
- **Training:** full fine-tune (not LoRA), bf16, 8-bit AdamW, gradient
|
| 40 |
-
checkpointing, batch 1, sequence length 32k, cosine LR, 1300 steps.
|
| 41 |
-
- **Data:** 379 agent-trace examples, ~1.34M assistant tokens, packed from
|
| 42 |
-
`TeichAI/Ox-Alpha-Pi-Traces` + `TeichAI/DeepSeek-v4-Pro-Agent`. Training is
|
| 43 |
-
masked so the model learns **assistant turns only** (thinking + text + tool
|
| 44 |
-
calls); user / system / tool-result tokens are masked out.
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
multi-step agentic tasks reliably.
|
| 52 |
-
|
| 53 |
-
Verified by loading the released weights standalone and generating:
|
| 54 |
-
- Coherent, grammatical responses with well-formed `[[ctrl:think]]` blocks.
|
| 55 |
-
- Correct simple arithmetic (e.g. 27 × 43 = 1161; 12 + 7 = 19).
|
| 56 |
-
- No degenerate token loops in the sampled prompts.
|
| 57 |
|
| 58 |
## Usage
|
| 59 |
|
| 60 |
```python
|
| 61 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
print(
|
| 72 |
```
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
##
|
| 78 |
|
| 79 |
-
|
| 80 |
-
- Datasets: `TeichAI/Ox-Alpha-Pi-Traces`, `TeichAI/DeepSeek-v4-Pro-Agent`
|
| 81 |
-
- Training: full SFT, bf16, 8-bit AdamW, grad checkpointing, batch 1, seq 32k,
|
| 82 |
-
cosine LR, 1300 steps, masked to assistant turns.
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
library_name: transformers
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
+
language: en
|
|
|
|
| 6 |
base_model: LiquidAI/LFM2.5-1.2B-Thinking
|
| 7 |
tags:
|
| 8 |
+
- agent
|
| 9 |
+
- fine-tune
|
| 10 |
+
- reasoning
|
| 11 |
+
- tool-use
|
| 12 |
+
- lfm2
|
| 13 |
metrics:
|
| 14 |
+
- perplexity
|
| 15 |
---
|
| 16 |
|
| 17 |
# LiquidAgent-1.2B
|
| 18 |
|
| 19 |
+
A fine-tune of [LiquidAI/LFM2.5-1.2B-Thinking](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Thinking) for agent-style tasks: multi-step reasoning, tool use, and structured output generation.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
## Architecture
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
| Parameter | Value |
|
| 24 |
+
|-----------|-------|
|
| 25 |
+
| Base model | LiquidAI/LFM2.5-1.2B-Thinking |
|
| 26 |
+
| Architecture | LFM2 (hybrid conv + full-attention) |
|
| 27 |
+
| Layers | 16 (10 conv, 6 full-attention) |
|
| 28 |
+
| Hidden size | 2048 |
|
| 29 |
+
| Attention heads | 32 Q / 8 KV (GQA) |
|
| 30 |
+
| Vocab size | 65,536 |
|
| 31 |
+
| Max position | 128,000 |
|
| 32 |
+
| Tied embeddings | Yes |
|
| 33 |
+
| Total params | 1,170,300,000 (148 tensors) |
|
| 34 |
+
| Dtype | bfloat16 |
|
| 35 |
|
| 36 |
+
## Training
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
- **Data**: Agent traces from [TeichAI/Ox-Alpha-Pi-Traces](https://huggingface.co/datasets/TeichAI/Ox-Alpha-Pi-Traces) and [TeichAI/DeepSeek-v4-Pro-Agent](https://huggingface.co/datasets/TeichAI/DeepSeek-v4-Pro-Agent)
|
| 39 |
+
- **Method**: Full fine-tune (all parameters), assistant-token masking (loss on assistant turns only)
|
| 40 |
+
- **Steps**: 47 optimizer steps (batch 1, grad accum 16, ~1.5M assistant tokens)
|
| 41 |
+
- **LR**: 2e-5, cosine decay with 5-step warmup
|
| 42 |
+
- **Hardware**: NVIDIA RTX 5090 (32 GB), bfloat16, gradient checkpointing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
## Usage
|
| 45 |
|
| 46 |
```python
|
| 47 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 48 |
|
| 49 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 50 |
+
"Compactbot/liquidagent-1.2b",
|
| 51 |
+
torch_dtype="bfloat16",
|
| 52 |
+
device_map="auto"
|
| 53 |
+
)
|
| 54 |
+
tokenizer = AutoTokenizer.from_pretrained("Compactbot/liquidagent-1.2b")
|
| 55 |
|
| 56 |
+
messages = [{"role": "user", "content": "Write a Python function to parse a JSON config file and validate required fields."}]
|
| 57 |
+
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 58 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 59 |
+
output = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.9)
|
| 60 |
+
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 61 |
```
|
| 62 |
|
| 63 |
+
## Quality
|
| 64 |
+
|
| 65 |
+
Ship gate (2026-09-30): PASS. Generates coherent, on-topic agent-style responses with thinking tokens. No degenerate repetition (1 repeated 5-gram in 301 words across 3 prompts).
|
| 66 |
+
|
| 67 |
+
**Known limitations**:
|
| 68 |
+
- Only 47 optimizer steps — this is a lightweight SFT, not a full training run
|
| 69 |
+
- Best suited for agent-style tasks (reasoning chains, tool calls, structured output)
|
| 70 |
+
- Not a general-purpose chat model; general knowledge is from the base model
|
| 71 |
|
| 72 |
+
## Notes
|
| 73 |
|
| 74 |
+
This is a demonstration fine-tune showing that agent capabilities can be injected into a 1.2B hybrid-attention model with a small number of optimizer steps. The base model's thinking-token format is preserved.
|
|
|
|
|
|
|
|
|
chat_template.jinja
CHANGED
|
@@ -49,7 +49,7 @@
|
|
| 49 |
{%- endif -%}
|
| 50 |
{%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}
|
| 51 |
{%- endfor -%}
|
| 52 |
-
{{- "
|
| 53 |
{%- endmacro -%}
|
| 54 |
|
| 55 |
{%- set ns = namespace(system_prompt="", last_assistant_index=-1) -%}
|
|
@@ -73,7 +73,7 @@
|
|
| 73 |
{%- set ns.system_prompt = ns.system_prompt + "]" -%}
|
| 74 |
{%- endif -%}
|
| 75 |
{%- if ns.system_prompt -%}
|
| 76 |
-
{{- "
|
| 77 |
{%- endif -%}
|
| 78 |
{%- for message in messages -%}
|
| 79 |
{%- if message["role"] == "assistant" -%}
|
|
@@ -81,14 +81,14 @@
|
|
| 81 |
{%- endif -%}
|
| 82 |
{%- endfor -%}
|
| 83 |
{%- for message in messages -%}
|
| 84 |
-
{{- "
|
| 85 |
{%- if message.role == "assistant" -%}
|
| 86 |
{%- generation -%}
|
| 87 |
{%- set keep_thinking = preserve_thinking or loop.index0 == ns.last_assistant_index -%}
|
| 88 |
{%- set thinking = message.thinking or message.reasoning or message.reasoning_content -%}
|
| 89 |
{%- set thinking = thinking if thinking is string else "" -%}
|
| 90 |
{%- if thinking and keep_thinking -%}
|
| 91 |
-
{{- "
|
| 92 |
{%- endif -%}
|
| 93 |
{%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
|
| 94 |
{%- set _has_cfm = false -%}
|
|
@@ -96,8 +96,8 @@
|
|
| 96 |
{%- if message.get("content") -%}
|
| 97 |
{%- set content = parse_content(message.content) -%}
|
| 98 |
{%- endif -%}
|
| 99 |
-
{%- if not keep_thinking and "
|
| 100 |
-
{%- set content = content.split("
|
| 101 |
{%- endif -%}
|
| 102 |
{%- if content.endswith(_cfm_tag) -%}
|
| 103 |
{%- set _has_cfm = true -%}
|
|
@@ -111,15 +111,15 @@
|
|
| 111 |
{%- if _has_cfm -%}
|
| 112 |
{{- _cfm_tag -}}
|
| 113 |
{%- endif -%}
|
| 114 |
-
{{- "
|
| 115 |
{%- endgeneration -%}
|
| 116 |
{%- else %}
|
| 117 |
{%- if message.get("content") -%}
|
| 118 |
{{- parse_content(message["content"]) -}}
|
| 119 |
{%- endif -%}
|
| 120 |
-
{{- "
|
| 121 |
{%- endif %}
|
| 122 |
{%- endfor -%}
|
| 123 |
{%- if add_generation_prompt -%}
|
| 124 |
-
{{- "
|
| 125 |
{%- endif -%}
|
|
|
|
| 49 |
{%- endif -%}
|
| 50 |
{%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}
|
| 51 |
{%- endfor -%}
|
| 52 |
+
{{- "[[ctrl:tool_call_start]][" + (tool_calls_ns.tool_calls | join(", ")) + "][[ctrl:tool_call_end]]" -}}
|
| 53 |
{%- endmacro -%}
|
| 54 |
|
| 55 |
{%- set ns = namespace(system_prompt="", last_assistant_index=-1) -%}
|
|
|
|
| 73 |
{%- set ns.system_prompt = ns.system_prompt + "]" -%}
|
| 74 |
{%- endif -%}
|
| 75 |
{%- if ns.system_prompt -%}
|
| 76 |
+
{{- "[[ctrl:im_start]]system\n" + ns.system_prompt + "[[ctrl:im_end]]\n" -}}
|
| 77 |
{%- endif -%}
|
| 78 |
{%- for message in messages -%}
|
| 79 |
{%- if message["role"] == "assistant" -%}
|
|
|
|
| 81 |
{%- endif -%}
|
| 82 |
{%- endfor -%}
|
| 83 |
{%- for message in messages -%}
|
| 84 |
+
{{- "[[ctrl:im_start]]" + message.role + "\n" -}}
|
| 85 |
{%- if message.role == "assistant" -%}
|
| 86 |
{%- generation -%}
|
| 87 |
{%- set keep_thinking = preserve_thinking or loop.index0 == ns.last_assistant_index -%}
|
| 88 |
{%- set thinking = message.thinking or message.reasoning or message.reasoning_content -%}
|
| 89 |
{%- set thinking = thinking if thinking is string else "" -%}
|
| 90 |
{%- if thinking and keep_thinking -%}
|
| 91 |
+
{{- "\u003cthink\u003e" + thinking + "\u003c/think\u003e" -}}
|
| 92 |
{%- endif -%}
|
| 93 |
{%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
|
| 94 |
{%- set _has_cfm = false -%}
|
|
|
|
| 96 |
{%- if message.get("content") -%}
|
| 97 |
{%- set content = parse_content(message.content) -%}
|
| 98 |
{%- endif -%}
|
| 99 |
+
{%- if not keep_thinking and "\u003c/think\u003e" in content -%}
|
| 100 |
+
{%- set content = content.split("\u003c/think\u003e")[-1] | trim -%}
|
| 101 |
{%- endif -%}
|
| 102 |
{%- if content.endswith(_cfm_tag) -%}
|
| 103 |
{%- set _has_cfm = true -%}
|
|
|
|
| 111 |
{%- if _has_cfm -%}
|
| 112 |
{{- _cfm_tag -}}
|
| 113 |
{%- endif -%}
|
| 114 |
+
{{- "[[ctrl:im_end]]\n" -}}
|
| 115 |
{%- endgeneration -%}
|
| 116 |
{%- else %}
|
| 117 |
{%- if message.get("content") -%}
|
| 118 |
{{- parse_content(message["content"]) -}}
|
| 119 |
{%- endif -%}
|
| 120 |
+
{{- "[[ctrl:im_end]]\n" -}}
|
| 121 |
{%- endif %}
|
| 122 |
{%- endfor -%}
|
| 123 |
{%- if add_generation_prompt -%}
|
| 124 |
+
{{- "[[ctrl:im_start]]assistant\n" -}}
|
| 125 |
{%- endif -%}
|
config.json
CHANGED
|
@@ -57,4 +57,4 @@
|
|
| 57 |
"use_cache": true,
|
| 58 |
"use_pos_enc": true,
|
| 59 |
"vocab_size": 65536
|
| 60 |
-
}
|
|
|
|
| 57 |
"use_cache": true,
|
| 58 |
"use_pos_enc": true,
|
| 59 |
"vocab_size": 65536
|
| 60 |
+
}
|
generation_config.json
CHANGED
|
@@ -3,5 +3,5 @@
|
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 7,
|
| 5 |
"pad_token_id": 0,
|
| 6 |
-
"transformers_version": "
|
| 7 |
-
}
|
|
|
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 7,
|
| 5 |
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "4.57.2"
|
| 7 |
+
}
|
tokenizer_config.json
CHANGED
|
@@ -16,4 +16,4 @@
|
|
| 16 |
"tokenizer_class": "TokenizersBackend",
|
| 17 |
"use_default_system_prompt": false,
|
| 18 |
"use_fast": true
|
| 19 |
-
}
|
|
|
|
| 16 |
"tokenizer_class": "TokenizersBackend",
|
| 17 |
"use_default_system_prompt": false,
|
| 18 |
"use_fast": true
|
| 19 |
+
}
|