This model is a fine-tuned version of
deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B, enhanced with chain-of-thought (CoT) reasoning on a hybrid dataset combining GSM8K-style reasoning and structured
text-to-SQL generation.
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 complex logical SQL queries generated synthetically with corresponding natural language prompts and CoT explanations.
For inference, please see this publicly available
notebook.
1<question>...</question>
2<think>...</think>
3<response>...</response>
This format allows the model to internalize step-by-step logical reasoning for SQL generation.
The base model
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:
1from transformers import StoppingCriteria, StoppingCriteriaList
2import torch
3
4class StopOnTokens(StoppingCriteria):
5 def __init__(self, stop_token_ids: list):
6 super().__init__()
7 self.stop_token_ids = stop_token_ids
8
9 def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
10 # Check if the last token matches any of the stop tokens
11 return any(input_ids[0, -len(token):].tolist() == token for token in self.stop_token_ids)
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("eagle0504/qwen-distilled-scout-1.5b-gen2")
4tokenizer = AutoTokenizer.from_pretrained("eagle0504/qwen-distilled-scout-1.5b-gen2")
5
6# Example stop sequence
7stop_sequence = "</response>"
8stop_ids = tokenizer.encode(stop_sequence, add_special_tokens=False)
9stopping_criteria = StoppingCriteriaList([StopOnTokens([stop_ids])])
10
11# Run generation with stop sequence
12inputs = tokenizer(
13 "<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 in April and May?</question>",
14 return_tensors="pt"
15)
16
17outputs = model.generate(
18 **inputs,
19 max_new_tokens=230,
20 stopping_criteria=stopping_criteria
21)
22
23print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1@misc{yin2025enhanceddeepseek,
2 title={Enhanced DeepSeek-R1-Distill-Qwen-1.5B Fine-tuned on GSM8K + CoT SQL},
3 author={Yiqiao Yin},
4 year={2025},
5 howpublished={\url{https://huggingface.co/eagle0504/enhanced-deepseek-r1-distill-qwen-1.5b-finetuned-on-gsm8k-codealpaca20k-text2sql}},
6}
For questions or collaborations, reach out via
LinkedIn or email:
eagle0504@gmail.com