初始化项目,由ModelHub XC社区提供模型
Model: yasserrmd/GLM4.7-Distill-LFM2.5-1.2B Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
logo_model.png filter=lfs diff=lfs merge=lfs -text
|
||||
235
README.md
Normal file
235
README.md
Normal file
@@ -0,0 +1,235 @@
|
||||
---
|
||||
base_model: LiquidAI/LFM2.5-1.2B-Instruct
|
||||
|
||||
model_type: causal-lm
|
||||
architecture: LFM2
|
||||
|
||||
tags:
|
||||
- text-generation
|
||||
- text-generation-inference
|
||||
- instruction-tuned
|
||||
- distilled
|
||||
- synthetic-data
|
||||
- transformers
|
||||
- unsloth
|
||||
- lfm2
|
||||
- glm
|
||||
- agentic
|
||||
- edge
|
||||
- efficient
|
||||
|
||||
license: apache-2.0
|
||||
|
||||
language:
|
||||
- en
|
||||
|
||||
datasets:
|
||||
- Open-Orca/FLAN
|
||||
- databricks/databricks-dolly-15k
|
||||
- OpenAssistant/oasst1
|
||||
- BAAI/Infinity-Instruct
|
||||
- sahil2801/CodeAlpaca-20k
|
||||
- TIGER-Lab/MathInstruct
|
||||
|
||||
pipeline_tag: text-generation
|
||||
|
||||
|
||||
---
|
||||
|
||||
# GLM4.7-Distill-LFM2.5-1.2B
|
||||
|
||||
<img src="logo_model.png" width="100%" />
|
||||
|
||||
## Model Overview
|
||||
|
||||
**GLM4.7-Distill-LFM2.5-1.2B** is a 1.2B-parameter instruction-following language model obtained via **offline distillation** from **GLM-4.7** into the **Liquid AI LFM2** architecture.
|
||||
|
||||
The model is designed to be:
|
||||
|
||||
* concise and non-verbose
|
||||
* strong at instruction following
|
||||
* efficient for local and edge deployments
|
||||
* suitable for assistant, agentic, and system-integration use cases
|
||||
|
||||
This model does **not** include chain-of-thought reasoning and is optimized for **final-answer quality** rather than verbose explanations.
|
||||
|
||||
---
|
||||
|
||||
## Key Characteristics
|
||||
|
||||
* **Base architecture**: Liquid AI LFM2
|
||||
* **Model size**: 1.2B parameters
|
||||
* **Training method**: Offline supervised distillation (SFT with LoRA)
|
||||
* **Teacher model**: GLM-4.7 (used only for data generation)
|
||||
* **Inference dependency on teacher**: None
|
||||
* **Reasoning traces**: Not included
|
||||
* **Target behavior**: Clear, grounded, instruction-aligned responses
|
||||
|
||||
---
|
||||
|
||||
## Training Details
|
||||
|
||||
### Distillation Approach
|
||||
|
||||
This model was trained using **offline distillation**, where instruction-response pairs generated by **GLM-4.7** were combined with high-quality public instruction datasets.
|
||||
|
||||
The teacher model was **not used during training or inference**, and no teacher weights or logits are included.
|
||||
|
||||
Training focused on:
|
||||
|
||||
* instruction adherence
|
||||
* response clarity
|
||||
* reduced verbosity
|
||||
* stable decision boundaries
|
||||
|
||||
### Datasets Used (Approx. 13K Samples)
|
||||
|
||||
The following datasets were sampled and combined:
|
||||
|
||||
* Open-Orca / FLAN
|
||||
* Databricks Dolly 15K
|
||||
* OpenAssistant OASST1
|
||||
* BAAI Infinity-Instruct
|
||||
* CodeAlpaca
|
||||
* TIGER-Lab MathInstruct
|
||||
|
||||
These were augmented with **GLM-4.7–generated instruction responses**, with explicit avoidance of chain-of-thought reasoning.
|
||||
|
||||
---
|
||||
|
||||
## Intended Use
|
||||
|
||||
This model is well suited for:
|
||||
|
||||
* general-purpose assistants
|
||||
* planning and task decomposition
|
||||
* summarization and explanation
|
||||
* lightweight coding assistance
|
||||
* agentic workflows
|
||||
* system integration and automation
|
||||
* on-device or edge inference scenarios
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
Like other compact distilled models, this model may:
|
||||
|
||||
* hallucinate when given insufficient or false premises
|
||||
* struggle with adversarial logical inference (NLI-style tasks)
|
||||
* lack temporal awareness of recent events
|
||||
* provide confident answers where explicit uncertainty is required
|
||||
|
||||
For critical reasoning, verification layers or external tools are recommended.
|
||||
|
||||
---
|
||||
|
||||
## Ethical & Responsible Use
|
||||
|
||||
* This model was trained on a mixture of public datasets and synthetic data.
|
||||
* It does not contain personal data by design.
|
||||
* Outputs should not be treated as authoritative in medical, legal, or safety-critical contexts.
|
||||
|
||||
---
|
||||
|
||||
## Citation & Acknowledgements
|
||||
|
||||
If you use this model in research or applications, please acknowledge:
|
||||
|
||||
* **GLM-4.7** for teacher-generated distillation data
|
||||
* **Liquid AI** for the LFM2 architecture
|
||||
* The creators of the public instruction datasets listed above
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
||||
|
||||
model_id = "yasserrmd/GLM4.7-Distill-LFM2.5-1.2B"
|
||||
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_id,
|
||||
device_map="auto",
|
||||
dtype="bfloat16",
|
||||
# attn_implementation="flash_attention_2" # uncomment on compatible GPU
|
||||
)
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
||||
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
||||
|
||||
prompt = "Implement QuickSort algorithm with complexity analysis"
|
||||
|
||||
input_ids = tokenizer.apply_chat_template(
|
||||
[{"role": "user", "content": prompt}],
|
||||
add_generation_prompt=True,
|
||||
return_tensors="pt",
|
||||
tokenize=True,
|
||||
).to(model.device)
|
||||
|
||||
output = model.generate(
|
||||
input_ids,
|
||||
do_sample=True,
|
||||
temperature=0.1,
|
||||
top_k=50,
|
||||
top_p=0.1,
|
||||
repetition_penalty=1.05,
|
||||
max_new_tokens=512,
|
||||
streamer=streamer,
|
||||
)
|
||||
```
|
||||
|
||||
## With vLLM (Production)
|
||||
|
||||
```python
|
||||
from vllm import LLM, SamplingParams
|
||||
|
||||
llm = LLM(model="yasserrmd/GLM4.7-Distill-LFM2.5-1.2B")
|
||||
|
||||
sampling_params = SamplingParams(
|
||||
temperature=0.1,
|
||||
top_k=50,
|
||||
top_p=0.1,
|
||||
repetition_penalty=1.05,
|
||||
max_tokens=512
|
||||
)
|
||||
|
||||
prompts = [
|
||||
"Implement QuickSort algorithm",
|
||||
"Solve the Longest Common Subsequence problem",
|
||||
"Design a hash table with collision handling"
|
||||
]
|
||||
|
||||
outputs = llm.generate(prompts, sampling_params)
|
||||
|
||||
for output in outputs:
|
||||
print(output.outputs[0].text)
|
||||
```
|
||||
|
||||
## Recommended Use
|
||||
|
||||
- Technical interviews
|
||||
- Algorithm learning
|
||||
- Code generation
|
||||
- Problem-solving
|
||||
- Code refactoring
|
||||
- Educational tutoring
|
||||
|
||||
## Not Recommended For
|
||||
|
||||
- Current events or recent information
|
||||
- Factual knowledge queries
|
||||
- Legal, medical, or safety-critical code
|
||||
- Highly specialized domain problems
|
||||
- Real-time critical systems without human review
|
||||
|
||||
## License
|
||||
|
||||
Please refer to the licenses of:
|
||||
|
||||
* the base LFM2 model
|
||||
* the individual datasets used for training
|
||||
|
||||
This repository follows the same usage constraints as the upstream components.
|
||||
|
||||
45
chat_template.jinja
Normal file
45
chat_template.jinja
Normal file
@@ -0,0 +1,45 @@
|
||||
{{- bos_token -}}
|
||||
{%- set keep_past_thinking = keep_past_thinking | default(false) -%}
|
||||
{%- set ns = namespace(system_prompt="") -%}
|
||||
{%- if messages[0]["role"] == "system" -%}
|
||||
{%- set ns.system_prompt = messages[0]["content"] -%}
|
||||
{%- set messages = messages[1:] -%}
|
||||
{%- endif -%}
|
||||
{%- if tools -%}
|
||||
{%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
|
||||
{%- for tool in tools -%}
|
||||
{%- if tool is not string -%}
|
||||
{%- set tool = tool | tojson -%}
|
||||
{%- endif -%}
|
||||
{%- set ns.system_prompt = ns.system_prompt + tool -%}
|
||||
{%- if not loop.last -%}
|
||||
{%- set ns.system_prompt = ns.system_prompt + ", " -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- set ns.system_prompt = ns.system_prompt + "]" -%}
|
||||
{%- endif -%}
|
||||
{%- if ns.system_prompt -%}
|
||||
{{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
|
||||
{%- endif -%}
|
||||
{%- set ns.last_assistant_index = -1 -%}
|
||||
{%- for message in messages -%}
|
||||
{%- if message["role"] == "assistant" -%}
|
||||
{%- set ns.last_assistant_index = loop.index0 -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- for message in messages -%}
|
||||
{{- "<|im_start|>" + message["role"] + "\n" -}}
|
||||
{%- set content = message["content"] -%}
|
||||
{%- if content is not string -%}
|
||||
{%- set content = content | tojson -%}
|
||||
{%- endif -%}
|
||||
{%- if message["role"] == "assistant" and not keep_past_thinking and loop.index0 != ns.last_assistant_index -%}
|
||||
{%- if "</think>" in content -%}
|
||||
{%- set content = content.split("</think>")[-1] | trim -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{{- content + "<|im_end|>\n" -}}
|
||||
{%- endfor -%}
|
||||
{%- if add_generation_prompt -%}
|
||||
{{- "<|im_start|>assistant\n" -}}
|
||||
{%- endif -%}
|
||||
58
config.json
Normal file
58
config.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"architectures": [
|
||||
"Lfm2ForCausalLM"
|
||||
],
|
||||
"block_auto_adjust_ff_dim": true,
|
||||
"block_dim": 2048,
|
||||
"block_ff_dim": 12288,
|
||||
"block_ffn_dim_multiplier": 1.0,
|
||||
"block_mlp_init_scale": 1.0,
|
||||
"block_multiple_of": 256,
|
||||
"block_norm_eps": 1e-05,
|
||||
"block_out_init_scale": 1.0,
|
||||
"block_use_swiglu": true,
|
||||
"block_use_xavier_init": true,
|
||||
"bos_token_id": 1,
|
||||
"conv_L_cache": 3,
|
||||
"conv_bias": false,
|
||||
"conv_dim": 2048,
|
||||
"conv_use_xavier_init": true,
|
||||
"torch_dtype": "bfloat16",
|
||||
"eos_token_id": 7,
|
||||
"hidden_size": 2048,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 12288,
|
||||
"layer_types": [
|
||||
"conv",
|
||||
"conv",
|
||||
"full_attention",
|
||||
"conv",
|
||||
"conv",
|
||||
"full_attention",
|
||||
"conv",
|
||||
"conv",
|
||||
"full_attention",
|
||||
"conv",
|
||||
"full_attention",
|
||||
"conv",
|
||||
"full_attention",
|
||||
"conv",
|
||||
"full_attention",
|
||||
"conv"
|
||||
],
|
||||
"max_position_embeddings": 128000,
|
||||
"model_type": "lfm2",
|
||||
"norm_eps": 1e-05,
|
||||
"num_attention_heads": 32,
|
||||
"num_heads": 32,
|
||||
"num_hidden_layers": 16,
|
||||
"num_key_value_heads": 8,
|
||||
"pad_token_id": 0,
|
||||
"rope_theta": 1000000.0,
|
||||
"tie_embedding": true,
|
||||
"transformers_version": "4.57.3",
|
||||
"unsloth_version": "2026.1.4",
|
||||
"use_cache": true,
|
||||
"use_pos_enc": true,
|
||||
"vocab_size": 65536
|
||||
}
|
||||
3
logo_model.png
Normal file
3
logo_model.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e8861cb76bc89417f151c8ec1eec4ee8b3af884dd0fe5ac839d1d9ca182794da
|
||||
size 1154244
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a0e4745c3c0b988eb7b3936a91062ee3a6d11fb1d3a76139ea3684142bafe305
|
||||
size 2340697936
|
||||
23
special_tokens_map.json
Normal file
23
special_tokens_map.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"bos_token": {
|
||||
"content": "<|startoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|im_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
323830
tokenizer.json
Normal file
323830
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
4096
tokenizer_config.json
Normal file
4096
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user