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

Model: eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-06-26 00:06:24 +08:00
commit bcb40866c1
17 changed files with 151958 additions and 0 deletions

40
.gitattributes vendored Normal file
View File

@@ -0,0 +1,40 @@
*.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
tokenizer.json filter=lfs diff=lfs merge=lfs -text
unsloth.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
unsloth.F16.gguf filter=lfs diff=lfs merge=lfs -text
unsloth.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
unsloth.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text

197
README.md Normal file
View File

@@ -0,0 +1,197 @@
---
library_name: transformers
tags:
- unsloth
- trl
- grpo
license: mit
datasets:
- eagle0504/augmented_codealpaca-20k-using-together-ai-deepseek-v1
language:
- en
base_model:
- Qwen/Qwen2.5-1.5B-Instruct
---
# Qwen2.5-1.5B-Instruct Fine-Tuned on CodeAlpaca-20K with DeepSeek Augmentation
## Model Overview
This model is a fine-tuned version of **Qwen2.5-1.5B-Instruct**, designed for **instruction-following and structured reasoning**. It is trained on an **enhanced CodeAlpaca-20K dataset**, incorporating **Chain-of-Thought (CoT) reasoning** augmented by **DeepSeek AI**.
### Key Features
- **Base Model:** Qwen2.5-1.5B-Instruct
- **Fine-Tuned On:** CodeAlpaca-20K enhanced with DeepSeek-V3
- **Optimized for:** Instruction-following, structured reasoning, and problem-solving
- **Fine-tuning method:** LoRA (Low-Rank Adaptation)
- **Inference-ready:** Available on **Hugging Face** and compatible with `llama.cpp`
- **Supports GGUF:** Optimized versions for **Q4_K_M, Q8_0, Q5_K_M, and FP16**
## Model Details
- **Developed by:** [Yiqiao Yin](https://www.y-yin.io/)
- **Model Type:** Causal Language Model (Text Generation)
- **Languages:** English (`en`)
- **License:** MIT License
- **Fine-tuned from:** `Qwen/Qwen2.5-1.5B-Instruct`
- **Training Library:** `transformers` + `unsloth` + `trl`
- **Quantization:** GGUF (`Q4_K_M, Q8_0, Q5_K_M, f16`)
🔗 **Hugging Face Repository:**
👉 [Fine-tuned Qwen2.5-1.5B-Instruct](https://huggingface.co/eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1)
## How to Use the Model
### Using `transformers` in Python
You may need to install `bitsandbytes` by using
```bash
! pip install -U bitsandbytes
```
Then you can use the following code to run inference.
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model_name = "eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Move model to GPU if available
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
# Example inference
question = "How do I implement a binary search algorithm in Python?"
inputs = tokenizer(question, return_tensors="pt").to(device)
output = model.generate(**inputs, max_length=200)
# Decode response
print(tokenizer.decode(output[0], skip_special_tokens=True))
```
## Running the Model with `llama.cpp`
### Step 1: Install `llama.cpp`
```sh
brew install llama.cpp
```
### Step 2: Download the Model
```sh
mkdir -p ~/llama_models && cd ~/llama_models
wget https://huggingface.co/eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1/resolve/main/q8_0.gguf
```
### Step 3: Run the Model
```sh
llama-cli -m ~/llama_models/q8_0.gguf --interactive
```
Or you can use the following:
```sh
llama-cli -hf eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1:Q8_0
```
### Step 4: Test with a Prompt
```sh
llama-cli -m ~/llama_models/q8_0.gguf -p "Explain the differences between breadth-first search and depth-first search."
```
## Training Details
### Custom Reward
```python
def count_xml(text: str) -> float:
"""
Calculates a reward based on the occurrence of certain XML tags and subtracts penalties for content after closing tags.
Args:
text (str): The text string to analyze for XML tag consistency.
Returns:
float: Total reward score based on XML tag occurrence and penalties.
"""
count = 0.0
if text.count("<think>\n") == 1:
count += 0.125
if text.count("\n</think>\n") == 1:
count += 0.125
if text.count("\n<answer>\n") == 1:
count += 0.125
count -= len(text.split("\n</answer>\n")[-1])*0.001
if text.count("\n</answer>") == 1:
count += 0.125
count -= (len(text.split("\n</answer>")[-1]) - 1)*0.001
# Ensure `<think>` and `</think>` exist
if "<think>" in text and "</think>" in text:
count += 1.0 # Higher weight to ensure reasoning consistency
else:
count -= 1.0 # Penalize if missing
return count
```
Each component contributes to the total reward **if conditions are met**:
| Condition | Reward |
|-----------|--------|
| `"<think>\n"` appears exactly **once** | **+0.125** |
| `"\n</think>\n"` appears exactly **once** | **+0.125** |
| `"\n<answer>\n"` appears exactly **once** | **+0.125** |
| `"\n</answer>"` appears exactly **once** | **+0.125** |
| Both `<think>` and `</think>` exist anywhere | **+1.0** |
| No extra text after `"</answer>"` | **No penalty** |
Total possible reward **before penalties**:
\[
0.125 + 0.125 + 0.125 + 0.125 + 1.0 = 1.5
\]
**Potential Penalties**
The function applies penalties for **extra content after `"</answer>"`**:
\[
-\left( \text{length of extra text} \times 0.001 \right)
\]
If the **best case** occurs (i.e., **no extra content**), then:
- **Penalty = 0**
- **Final Reward = 1.5 (no deductions)**
---
**Best Possible Input Example**
This **ideal input** gives the highest possible reward:
```xml
<think>
Valid reasoning goes here.
</think>
<answer>
Correct final answer here.
</answer>
```
This means we customize the reward function so that we encourage the answer to have reasoning inside. We also know mathematically what the reward should be so we can monitor it during training process.
### Dataset Used
The model was fine-tuned on:
🔹 [`eagle0504/augmented_codealpaca-20k-using-together-ai-deepseek-v1`](https://huggingface.co/datasets/eagle0504/augmented_codealpaca-20k-using-together-ai-deepseek-v1)
This dataset contains:
- **20K augmented training samples**
- Features: `instruction`, `response`, `cot` (Chain-of-Thought)
### Training Configuration
- **Framework:** `transformers` + `unsloth` + `trl`
- **Optimization:** LoRA applied to QKV projections
- **Learning Rate:** `1e-6`
- **AdamW Optimizer (8-bit)**
- **Mixed Precision (`bf16` or `fp16`)**
- **Batch Size:** `8`
- **Max Sequence Length:** `1024`

37
adapter_config.json Normal file
View File

@@ -0,0 +1,37 @@
{
"alpha_pattern": {},
"auto_mapping": null,
"base_model_name_or_path": "unsloth/qwen2.5-1.5b-instruct-unsloth-bnb-4bit",
"bias": "none",
"eva_config": null,
"exclude_modules": null,
"fan_in_fan_out": false,
"inference_mode": true,
"init_lora_weights": true,
"layer_replication": null,
"layers_pattern": null,
"layers_to_transform": null,
"loftq_config": {},
"lora_alpha": 32,
"lora_bias": false,
"lora_dropout": 0,
"megatron_config": null,
"megatron_core": "megatron.core",
"modules_to_save": null,
"peft_type": "LORA",
"r": 32,
"rank_pattern": {},
"revision": null,
"target_modules": [
"o_proj",
"down_proj",
"v_proj",
"gate_proj",
"q_proj",
"up_proj",
"k_proj"
],
"task_type": "CAUSAL_LM",
"use_dora": false,
"use_rslora": false
}

View File

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

24
added_tokens.json Normal file
View File

@@ -0,0 +1,24 @@
{
"</tool_call>": 151658,
"<tool_call>": 151657,
"<|box_end|>": 151649,
"<|box_start|>": 151648,
"<|endoftext|>": 151643,
"<|file_sep|>": 151664,
"<|fim_middle|>": 151660,
"<|fim_pad|>": 151662,
"<|fim_prefix|>": 151659,
"<|fim_suffix|>": 151661,
"<|im_end|>": 151645,
"<|im_start|>": 151644,
"<|image_pad|>": 151655,
"<|object_ref_end|>": 151647,
"<|object_ref_start|>": 151646,
"<|quad_end|>": 151651,
"<|quad_start|>": 151650,
"<|repo_name|>": 151663,
"<|video_pad|>": 151656,
"<|vision_end|>": 151653,
"<|vision_pad|>": 151654,
"<|vision_start|>": 151652
}

3
config.json Normal file
View File

@@ -0,0 +1,3 @@
{
"model_type": "qwen2"
}

7
generation_config.json Normal file
View File

@@ -0,0 +1,7 @@
{
"_from_model_config": true,
"eos_token_id": 151645,
"max_length": 32768,
"pad_token_id": 0,
"transformers_version": "4.48.3"
}

151388
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:705a4caab899c15e39ae85d9a62c2b70bfb402c76554482c3d3ba116b96c8805
size 3087466808

31
special_tokens_map.json Normal file
View File

@@ -0,0 +1,31 @@
{
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"eos_token": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|vision_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:64e71213db910f5cafa86d35091f37393dcc344b1bbc34091d1b3eed4cca01d5
size 11422064

209
tokenizer_config.json Normal file
View File

@@ -0,0 +1,209 @@
{
"add_bos_token": false,
"add_prefix_space": false,
"added_tokens_decoder": {
"151643": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151644": {
"content": "<|im_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151645": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151646": {
"content": "<|object_ref_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151647": {
"content": "<|object_ref_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151648": {
"content": "<|box_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151649": {
"content": "<|box_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151650": {
"content": "<|quad_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151651": {
"content": "<|quad_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151652": {
"content": "<|vision_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151653": {
"content": "<|vision_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151654": {
"content": "<|vision_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151655": {
"content": "<|image_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151656": {
"content": "<|video_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151657": {
"content": "<tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151658": {
"content": "</tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151659": {
"content": "<|fim_prefix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151660": {
"content": "<|fim_middle|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151661": {
"content": "<|fim_suffix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151662": {
"content": "<|fim_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151663": {
"content": "<|repo_name|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151664": {
"content": "<|file_sep|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
}
},
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"bos_token": null,
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": {},
"model_max_length": 32768,
"pad_token": "<|vision_pad|>",
"padding_side": "left",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}

3
unsloth.F16.gguf Normal file
View File

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

3
unsloth.Q4_K_M.gguf Normal file
View File

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

3
unsloth.Q5_K_M.gguf Normal file
View File

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

3
unsloth.Q8_0.gguf Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6942c9b946de7622858544c42efe96a4374a6ace7e1fab99c07f0e8cab218bbb
size 1646572608

1
vocab.json Normal file

File diff suppressed because one or more lines are too long