初始化项目,由ModelHub XC社区提供模型

Model: applegrew/support-125M-slm-sft
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-09-29 17:45:18 +08:00
commit ccd0337d25
8 changed files with 81245 additions and 0 deletions

35
.gitattributes vendored Normal file
View File

@@ -0,0 +1,35 @@
*.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

122
README.md Normal file
View File

@@ -0,0 +1,122 @@
---
language: en
license: mit
tags:
- slm
- llama
- from-scratch
- it-support
- call-centre
- instruction-tuned
- sft
- raft
- retrieval-augmented
datasets:
- applegrew/support-125M-slm-base
pipeline_tag: text-generation
library_name: transformers
---
# Support 125M SLM - SFT (Instruction-Tuned + RAFT)
A **125M parameter Llama-style language model** trained from scratch on ~2.6B tokens of IT support data, then instruction-tuned on ~17K examples including **RAFT (Retrieval-Augmented Fine-Tuning)** data.
Built from the pretrained base model ([applegrew/support-125M-slm-base](https://huggingface.co/applegrew/support-125M-slm-base)).
## Capabilities
| Capability | Example |
|-----------|---------|
| IT troubleshooting | "My VPN keeps disconnecting" → step-by-step help |
| Casual chat | "Hi" → "Hello! How can I help you today?" |
| Follow-ups | "That didn't work" → "Let's try another approach" |
| **Grounded answers (RAFT)** | Given a KB article, answers only from it |
| **Refusals (RAFT)** | "Not in the context" → "I don't have enough information to answer" |
## Training Data (17,002 records)
| Source | Pairs | Method | Cost |
|--------|-------|--------|------|
| StackExchange (filtered IT) | 10,372 | Direct extraction | $0 |
| Ubuntu IRC + Gemini | 2,821 | Teacher distillation | $1.50 |
| Casual interactions | 732 | Seed + Gemini expansion | $0.04 |
| **RAFT dataset** | **3,077** | Gemini 3.5 Flash-Lite | $0.40 |
| **Total** | **17,002** | | **~$1.94** |
### RAFT Pairs Breakdown
| Type | Count | Behavior taught |
|------|-------|-----------------|
| Answerable (grounded) | 2,306 | Answer strictly from provided context |
| Unanswerable (refusal) | 771 | Say "not enough information" |
## Training Details
| Setting | Value |
|---------|-------|
| Epochs | 3 |
| Learning rate | 2e-4 (cosine decay) |
| Batch size | 8 |
| Loss masking | Assistant tokens only |
| Hardware | 1x H100 |
| **Best val loss** | **2.099** |
| **Val perplexity** | **8.83** |
| **Total SFT cost** | **~$2.20** |
## Usage
### Plain chat
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("applegrew/support-125M-slm-sft")
tokenizer = AutoTokenizer.from_pretrained("applegrew/support-125M-slm-sft")
chat = "<|bos|><|system|>\nYou are a helpful IT support technician.<|eos|>\n<|user|>\nMy VPN keeps disconnecting every 5 minutes<|eos|>\n<|assistant|>\n"
inputs = tokenizer(chat, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=100, temperature=0.7, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=False))
```
### RAG / Grounded (RAFT) style
```python
context = "WiFi drops on Ubuntu 22.04. Run 'iwconfig', check Power Management, disable with 'sudo iwconfig wlan0 power off'."
question = "Why does my wifi keep dropping?"
chat = (
"<|bos|><|system|>\nYou are a helpful IT support technician. Answer using ONLY the "
"provided context. If the answer is not in the context, say you do not have enough "
"information to answer.<|eos|>\n"
f"<|user|>\n\n{context}\n\n\nQuestion: {question}<|eos|>\n<|assistant|>\n"
)
```
## Chat Template
```
<|bos|><|system|>
{system_prompt}<|eos|>
<|user|>
{question}<|eos|>
<|assistant|>
{answer}<|eos|>
```
Only the assistant's answer contributes to the loss during training.
## Web Demo
Try it live: [https://vercel-liart-xi.vercel.app](https://vercel-liart-xi.vercel.app)
## Project Summary
| Phase | Cost | Description |
|-------|------|-------------|
| Data pipeline | $0 | Clean → dedup → tokenize 2.6B IT tokens |
| Tokenizer | $0 | 16K BPE trained on corpus |
| Pretraining (6 epochs) | $31 | 125M Llama, 8x H100 |
| SFT data | ~$1.94 | Gemini distillation + filtering + RAFT |
| SFT training (3 rounds) | ~$2.20 | 1x H100 |
| **Total** | **~$35** | |

30
config.json Normal file
View File

@@ -0,0 +1,30 @@
{
"_name_or_path": "/root/data/checkpoints/sft",
"architectures": [
"LlamaForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": 1,
"eos_token_id": 2,
"head_dim": 64,
"hidden_act": "silu",
"hidden_size": 768,
"initializer_range": 0.02,
"intermediate_size": 3072,
"max_position_embeddings": 1024,
"mlp_bias": false,
"model_type": "llama",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"num_key_value_heads": 12,
"pretraining_tp": 1,
"rms_norm_eps": 1e-05,
"rope_scaling": null,
"rope_theta": 10000.0,
"tie_word_embeddings": true,
"torch_dtype": "bfloat16",
"transformers_version": "4.46.3",
"use_cache": true,
"vocab_size": 16384
}

6
generation_config.json Normal file
View File

@@ -0,0 +1,6 @@
{
"_from_model_config": true,
"bos_token_id": 1,
"eos_token_id": 2,
"transformers_version": "4.46.3"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:44d28e56916807a0f654ddcc6983d34afa6a8d1c73b678ac12e689c1a6b831ee
size 251708904

11
special_tokens_map.json Normal file
View File

@@ -0,0 +1,11 @@
{
"additional_special_tokens": [
"<|user|>",
"<|assistant|>",
"<|system|>"
],
"bos_token": "<|bos|>",
"eos_token": "<|eos|>",
"pad_token": "<|pad|>",
"unk_token": "<|unk|>"
}

80966
tokenizer.json Normal file

File diff suppressed because it is too large Load Diff

72
tokenizer_config.json Normal file
View File

@@ -0,0 +1,72 @@
{
"added_tokens_decoder": {
"0": {
"content": "<|bos|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"1": {
"content": "<|eos|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"2": {
"content": "<|pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"3": {
"content": "<|unk|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"4": {
"content": "<|user|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"5": {
"content": "<|assistant|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"6": {
"content": "<|system|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
}
},
"additional_special_tokens": [
"<|user|>",
"<|assistant|>",
"<|system|>"
],
"bos_token": "<|bos|>",
"clean_up_tokenization_spaces": false,
"eos_token": "<|eos|>",
"model_max_length": 1000000000000000019884624838656,
"pad_token": "<|pad|>",
"tokenizer_class": "PreTrainedTokenizerFast",
"unk_token": "<|unk|>"
}