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.5
|
| 10 |
+
- logic
|
| 11 |
+
- zh
|
| 12 |
+
- chinese
|
| 13 |
+
language:
|
| 14 |
+
- zh
|
| 15 |
+
- en
|
| 16 |
+
datasets:
|
| 17 |
+
- meta-math/GSM8K_zh
|
| 18 |
+
metrics:
|
| 19 |
+
- accuracy
|
| 20 |
+
library_name: peft
|
| 21 |
+
pipeline_tag: text-generation
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# Qwen2.5-1.5B-GSM8K-zh-Adapter
|
| 25 |
+
|
| 26 |
+
This model is a fine-tuned version of **Qwen2.5-1.5B** specialized for solving Chinese mathematical word problems. It was trained using Low-Rank Adaptation (LoRA) on the `meta-math/GSM8K_zh` dataset.
|
| 27 |
+
|
| 28 |
+
## Model Description
|
| 29 |
+
- **Developed by:** [Your Name/Organization]
|
| 30 |
+
- **Model Type:** Causal Language Model (Fine-tuned)
|
| 31 |
+
- **Base Model:** `Qwen/Qwen2.5-1.5B`
|
| 32 |
+
- **Language(s):** Chinese (Primary), English
|
| 33 |
+
- **License:** Apache 2.0
|
| 34 |
+
- **Fine-tuning Method:** LoRA (PEFT)
|
| 35 |
+
|
| 36 |
+
## Training Details
|
| 37 |
+
The model was optimized for reasoning and step-by-step mathematical solutions in a Chinese context.
|
| 38 |
+
|
| 39 |
+
- **Training Hardware:** Kaggle (2x T4 GPUs)
|
| 40 |
+
- **Quantization:** 4-bit (bitsandbytes)
|
| 41 |
+
- **Epochs/Steps:** 500 Steps
|
| 42 |
+
- **Batch Size:** 64 (effective)
|
| 43 |
+
- **Learning Rate:** 2e-4
|
| 44 |
+
- **Optimizer:** Paged AdamW 8-bit
|
| 45 |
+
|
| 46 |
+
## How to Use
|
| 47 |
+
|
| 48 |
+
To use this adapter, you must load the base Qwen2.5-1.5B model first and then attach the adapter.
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 52 |
+
from peft import PeftModel
|
| 53 |
+
import torch
|
| 54 |
+
|
| 55 |
+
model_id = "Qwen/Qwen2.5-1.5B"
|
| 56 |
+
adapter_id = "your-username/qwen2.5-gsm8k-zh-lora" # Replace with your repo
|
| 57 |
+
|
| 58 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 59 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
| 60 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 61 |
+
|
| 62 |
+
prompt = "<|im_start|>user\n小明有5个苹果,小红给了他3个,他又吃了2个,现在他还有几个?<|im_end|>\n<|im_start|>assistant\n"
|
| 63 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 64 |
+
|
| 65 |
+
output = model.generate(**inputs, max_new_tokens=512)
|
| 66 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))---
|
| 67 |
+
license: apache-2.0
|
| 68 |
+
base_model: qwen/Qwen2.5-1.5B
|
| 69 |
+
tags:
|
| 70 |
+
- math
|
| 71 |
+
- fine-tuned
|
| 72 |
+
- gsm8k
|
| 73 |
+
- qwen
|
| 74 |
+
- qwen2.5
|
| 75 |
+
- logic
|
| 76 |
+
- zh
|
| 77 |
+
- chinese
|
| 78 |
+
language:
|
| 79 |
+
- zh
|
| 80 |
+
- en
|
| 81 |
+
datasets:
|
| 82 |
+
- meta-math/GSM8K_zh
|
| 83 |
+
metrics:
|
| 84 |
+
- accuracy
|
| 85 |
+
library_name: peft
|
| 86 |
+
pipeline_tag: text-generation
|
| 87 |
+
---
|
| 88 |
+
|
| 89 |
+
# Qwen2.5-1.5B-GSM8K-zh-Adapter
|
| 90 |
+
|
| 91 |
+
This model is a fine-tuned version of **Qwen2.5-1.5B** specialized for solving Chinese mathematical word problems. It was trained using Low-Rank Adaptation (LoRA) on the `meta-math/GSM8K_zh` dataset.
|
| 92 |
+
|
| 93 |
+
## Model Description
|
| 94 |
+
- **Developed by:** [Your Name/Organization]
|
| 95 |
+
- **Model Type:** Causal Language Model (Fine-tuned)
|
| 96 |
+
- **Base Model:** `Qwen/Qwen2.5-1.5B`
|
| 97 |
+
- **Language(s):** Chinese (Primary), English
|
| 98 |
+
- **License:** Apache 2.0
|
| 99 |
+
- **Fine-tuning Method:** LoRA (PEFT)
|
| 100 |
+
|
| 101 |
+
## Training Details
|
| 102 |
+
The model was optimized for reasoning and step-by-step mathematical solutions in a Chinese context.
|
| 103 |
+
|
| 104 |
+
- **Training Hardware:** Kaggle (2x T4 GPUs)
|
| 105 |
+
- **Quantization:** 4-bit (bitsandbytes)
|
| 106 |
+
- **Epochs/Steps:** 500 Steps
|
| 107 |
+
- **Batch Size:** 64 (effective)
|
| 108 |
+
- **Learning Rate:** 2e-4
|
| 109 |
+
- **Optimizer:** Paged AdamW 8-bit
|
| 110 |
+
|
| 111 |
+
## How to Use
|
| 112 |
+
|
| 113 |
+
To use this adapter, you must load the base Qwen2.5-1.5B model first and then attach the adapter.
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 117 |
+
from peft import PeftModel
|
| 118 |
+
import torch
|
| 119 |
+
|
| 120 |
+
model_id = "Qwen/Qwen2.5-1.5B"
|
| 121 |
+
adapter_id = "your-username/qwen2.5-gsm8k-zh-lora" # Replace with your repo
|
| 122 |
+
|
| 123 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 124 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
| 125 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 126 |
+
|
| 127 |
+
prompt = "<|im_start|>user\n小明有5个苹果,小红给了他3个,他又吃了2个,现在他还有几个?<|im_end|>\n<|im_start|>assistant\n"
|
| 128 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 129 |
+
|
| 130 |
+
output = model.generate(**inputs, max_new_tokens=512)
|
| 131 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|