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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
datasets:
|
| 4 |
+
- gretelai/synthetic_text_to_sql
|
| 5 |
+
base_model:
|
| 6 |
+
- eagle0504/openai-gsm8k-codealpaca-20k-enhanced-deepseek-r1-distill-qwen-1.5b
|
| 7 |
+
library_name: transformers
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# 🧠 eagle0504/qwen-distilled-scout-1.5b-instruct-gen1
|
| 12 |
+
|
| 13 |
+
This model is a fine-tuned version of [`deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B`](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B), enhanced with instruction-tuned chain-of-thought (CoT) reasoning across three problem domains: **math**, **text-to-SQL**, and **Python programming**.
|
| 14 |
+
|
| 15 |
+
Fine-tuning was conducted using DeepSpeed on a multi-A100 GPU setup via RunPod for efficient training in memory-constrained environments. The training dataset includes CoT-formatted tasks with natural language questions and structured reasoning paths.
|
| 16 |
+
|
| 17 |
+
Inference notebook is publicly available [here](https://colab.research.google.com/drive/10CJqyIAOd9QnEp0W8NN_SxdiOrFsBz0-?usp=sharing).
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## 📎 Model Details
|
| 22 |
+
|
| 23 |
+
* **Base Model:** [`deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B`](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B)
|
| 24 |
+
* **Language:** English
|
| 25 |
+
* **Architecture:** Causal Language Model (Decoder-only)
|
| 26 |
+
* **Tokenizer:** AutoTokenizer from base model
|
| 27 |
+
* **Parameter Count:** 1.5 Billion
|
| 28 |
+
* **Training Framework:** 🧢 Transformers + DeepSpeed
|
| 29 |
+
* **Compute Environment:** RunPod (6x A100 SXM, 192 vCPU, 1.5TB RAM)
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## 🧪 Training Dataset
|
| 34 |
+
|
| 35 |
+
**Datasets Used:**
|
| 36 |
+
|
| 37 |
+
* [`gretelai/synthetic_text_to_sql`](https://huggingface.co/datasets/gretelai/synthetic_text_to_sql)
|
| 38 |
+
* [`eagle0504/openai-gsm8k-enhanced-using-together-ai-deepseek-train8k-test1k-v1`](https://huggingface.co/datasets/eagle0504/openai-gsm8k-enhanced-using-together-ai-deepseek-train8k-test1k-v1)
|
| 39 |
+
* [`eagle0504/augmented_codealpaca-20k-using-together-ai-deepseek-v1`](https://huggingface.co/datasets/eagle0504/augmented_codealpaca-20k-using-together-ai-deepseek-v1)
|
| 40 |
+
|
| 41 |
+
Each example in the dataset follows the structure:
|
| 42 |
+
|
| 43 |
+
```xml
|
| 44 |
+
<instruction>This is a [math/SQL/Python] problem.</instruction>
|
| 45 |
+
<question>...</question>
|
| 46 |
+
<think>...</think>
|
| 47 |
+
<response>...</response>
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
This instruction format ensures that the model understands the task type explicitly and applies step-by-step reasoning across all domains.
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
## 📊 Fine-Tuning Summary
|
| 55 |
+
|
| 56 |
+
The base model [`deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B`](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B) was fine-tuned on three different datasets using DeepSpeed across various RunPod infrastructure setups. Below is a consolidated summary of the training configurations and results:
|
| 57 |
+
|
| 58 |
+
| Model ID | Dataset Description | GPUs | vCPUs | RAM (GB) | Disk per GPU | Container Image | Duration | Cost | DeepSpeed Stage | Precision | Mean Token Accuracy |
|
| 59 |
+
| ------------------------------------------------------------------------------- | ------------------------------- | ------------- | ----- | -------- | ------------ | ---------------------------------------------------------- | -------- | ------- | --------------- | --------- | ------------------- |
|
| 60 |
+
| `eagle0504/finetuned-deepseek-r1-distill-qwen-1.5b-by-openai-gsm8k-enhanced-v2` | OpenAI GSM8K Enhanced v2 | 6 × H100 PCIe | 144 | 1132 | 20 GB | `runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04` | 2 hrs | \~\$28 | Stage 1 | FP16 | 98% |
|
| 61 |
+
| `eagle0504/openai-gsm8k-codealpaca-20k-enhanced-deepseek-r1-distill-qwen-1.5b` | GSM8K + CodeAlpaca-20K Enhanced | 4 × A100 SXM | 146 | 1144 | 20 GB | `runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04` | 2 hrs | \~\$14+ | Stage 1 | FP16 | 97% |
|
| 62 |
+
| `eagle0504/qwen-distilled-scout-1.5b` | Custom CoT + SQL-Reasoning | 6 × A100 SXM | 192 | 1536 | 20 GB | `runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04` | 1.5 hrs | \~\$21 | Stage 2 | FP16 | 97% |
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
## 🏗️ Training Configuration
|
| 67 |
+
|
| 68 |
+
Training was performed with the following configuration:
|
| 69 |
+
|
| 70 |
+
* **Batch Size:** 2 (with gradient accumulation steps = 4)
|
| 71 |
+
* **Epochs:** 15
|
| 72 |
+
* **Max Length:** 1024 tokens
|
| 73 |
+
* **Optimizer:** AdamW
|
| 74 |
+
* **Learning Rate:** 5e-5 (with warmup + linear decay)
|
| 75 |
+
* **Precision:** FP16
|
| 76 |
+
* **DeepSpeed Config:**
|
| 77 |
+
|
| 78 |
+
* Zero Redundancy Optimizer Stage 2
|
| 79 |
+
* Gradient Clipping: 1.0
|
| 80 |
+
* AllGather + ReduceScatter optimization
|
| 81 |
+
* **Checkpoint Saving:** Disabled to minimize disk usage
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
## 🧶 Evaluation Metric
|
| 86 |
+
|
| 87 |
+
The model is evaluated with a custom token-level accuracy metric:
|
| 88 |
+
|
| 89 |
+
* **Metric:** Mean token-level accuracy
|
| 90 |
+
* **Definition:** Accuracy over all non-masked tokens (`labels != -100`)
|
| 91 |
+
* **Implementation:** NumPy-based vectorized comparison between predicted tokens and ground truth
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## 🚀 Use Case
|
| 96 |
+
|
| 97 |
+
This model is tuned for **instruction-driven chain-of-thought generation**, and is especially useful in:
|
| 98 |
+
|
| 99 |
+
* Educational tools for logical reasoning and coding
|
| 100 |
+
* Auto SQL and code generation for tabular or structured systems
|
| 101 |
+
* Teaching agents in math, database, and programming domains
|
| 102 |
+
* Conversational agents requiring task-specific structured outputs
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## 📦 How to Use
|
| 107 |
+
|
| 108 |
+
```python
|
| 109 |
+
from transformers import StoppingCriteria, StoppingCriteriaList
|
| 110 |
+
import torch
|
| 111 |
+
|
| 112 |
+
class StopOnTokens(StoppingCriteria):
|
| 113 |
+
def __init__(self, stop_token_ids: list):
|
| 114 |
+
super().__init__()
|
| 115 |
+
self.stop_token_ids = stop_token_ids
|
| 116 |
+
|
| 117 |
+
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
| 118 |
+
return any(input_ids[0, -len(token):].tolist() == token for token in self.stop_token_ids)
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
```python
|
| 122 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 123 |
+
|
| 124 |
+
model = AutoModelForCausalLM.from_pretrained("eagle0504/qwen-distilled-scout-1.5b-instruct-gen1")
|
| 125 |
+
tokenizer = AutoTokenizer.from_pretrained("eagle0504/qwen-distilled-scout-1.5b-instruct-gen1")
|
| 126 |
+
|
| 127 |
+
stop_sequence = "</response>"
|
| 128 |
+
stop_ids = tokenizer.encode(stop_sequence, add_special_tokens=False)
|
| 129 |
+
stopping_criteria = StoppingCriteriaList([StopOnTokens([stop_ids])])
|
| 130 |
+
|
| 131 |
+
inputs = tokenizer(
|
| 132 |
+
"<instruction>This is a math problem.</instruction><question>Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether?</question>",
|
| 133 |
+
return_tensors="pt"
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
outputs = model.generate(
|
| 137 |
+
**inputs,
|
| 138 |
+
max_new_tokens=230,
|
| 139 |
+
stopping_criteria=stopping_criteria
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
---
|
| 146 |
+
|
| 147 |
+
## 📊 Limitations
|
| 148 |
+
|
| 149 |
+
* The model is specialized for instruction-following tasks in math, SQL, and Python reasoning. It may require further fine-tuning to generalize to open-domain dialogue or creative generation.
|
| 150 |
+
* Input length is capped at 1024 tokens, beyond which content will be truncated.
|
| 151 |
+
|
| 152 |
+
---
|
| 153 |
+
|
| 154 |
+
## 🧑💻 Author
|
| 155 |
+
|
| 156 |
+
* **Name:** Yiqiao Yin
|
| 157 |
+
* **Hugging Face:** [eagle0504](https://huggingface.co/eagle0504)
|
| 158 |
+
* **Organization:** \[WYN AI / Independent AI Researcher]
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
+
|
| 162 |
+
## 📝 Citation
|
| 163 |
+
|
| 164 |
+
```bibtex
|
| 165 |
+
@misc{yin2025instructgen1,
|
| 166 |
+
title={Instruction-Tuned Qwen 1.5B Fine-tuned on Math + SQL + Python CoT Tasks},
|
| 167 |
+
author={Yiqiao Yin},
|
| 168 |
+
year={2025},
|
| 169 |
+
howpublished={\url{https://huggingface.co/eagle0504/qwen-distilled-scout-1.5b-instruct-gen1}},
|
| 170 |
+
}
|
| 171 |
+
```
|