Instructions to use aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit") model = AutoModelForCausalLM.from_pretrained("aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit
- SGLang
How to use aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Desktop
- Docker Model Runner
How to use aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit with Docker Model Runner:
docker model run hf.co/aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit
- Uploaded finetuned model
- π§ Qwen2.5-7B Thinking β Alpaca Clean By ALI RAFIK
- π― Goal
- π Training Data
- π οΈ Fine-Tuning Configuration
- π Before vs After Fine-Tuning
- βοΈ Before vs After
- π§ͺ Reproducible Inference
- π Additional Inference Example
- π What Improved?
- β οΈ Important Evaluation Note
- πΎ Model Format
- β‘ Why LoRA + Unsloth?
- π€ Acknowledgements
- β οΈ Limitations
- β Summary
Uploaded finetuned model
- Developed by: aliRafik
- License: apache-2.0
- Finetuned from model : unsloth/qwen2.5-7b-unsloth-bnb-4bit
This qwen2 model was trained 2x faster with Unsloth and Huggingface's TRL library.
π§ Qwen2.5-7B Thinking β Alpaca Clean By ALI RAFIK
A fine-tuned Qwen2.5-7B model trained on the cleaned Alpaca instruction-following dataset to improve instruction following, structured responses, and reasoning-oriented task completion.
The model is released in 16-bit precision and was fine-tuned using LoRA with Unsloth.
π Model Highlights
- Base Model:
unsloth/Qwen2.5-7B - Fine-Tuning Dataset:
yahma/alpaca-cleaned - Dataset Size: ~52K instruction-following examples
- Training Method: LoRA / PEFT
- LoRA Rank: 16
- Target Modules: Attention + MLP projection layers
- Context Length: 2048
- Precision: 16-bit
- Optimizer: AdamW 8-bit
- Framework: Unsloth + Hugging Face Transformers + TRL
- Final Model:
aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit
π― Goal
The main objective of this fine-tuning run was to improve the model's ability to follow instructions and produce clear, structured, and logically organized responses.
The training focuses particularly on:
Instruction Following β Reasoning β Structure β Clarity
π Training Data
The model was fine-tuned on:
yahma/alpaca-cleaned
This is a cleaned version of the original Alpaca instruction-following dataset containing approximately 52K examples.
The dataset provides instruction/input/output pairs covering a broad range of tasks, helping the model improve its ability to understand an instruction and generate an appropriate response.
π οΈ Fine-Tuning Configuration
The model was fine-tuned using LoRA through Unsloth.
LoRA Configuration
r = 16
lora_alpha = 16
lora_dropout = 0
bias = "none"
Target modules:
[
"q_proj",
"k_proj",
"v_proj",
"o_proj",
"gate_proj",
"up_proj",
"down_proj",
]
Training Configuration
per_device_train_batch_size = 8
gradient_accumulation_steps = 4
num_train_epochs = 1
learning_rate = 2e-5
weight_decay = 0.01
optimizer = adamw_8bit
lr_scheduler = linear
seed = 3407
Gradient checkpointing was enabled using the Unsloth implementation to improve memory efficiency during training.
π Before vs After Fine-Tuning
One of the clearest examples of the effect of fine-tuning comes from a simple work-rate problem.
Problem
If 6 workers can build a wall in 12 days, how many days would it take 9 workers to build the same wall, assuming they work at the same rate? Also, if the wall needs to be built in 4 days, how many workers are needed?
The correct results are:
and
π΅ Before Fine-Tuning
The base Qwen2.5-7B model produced a mathematically reasonable approach, but the response contained a notable issue:
First, let's find out the work rate of one worker.
1 wall / (6 workers Γ 12 days)
= 1/72 wall per worker per day
It then attempted to calculate the solution using individual worker rates.
However, the generated response also contained an incorrect intermediate phrase:
"how many days it would take for 92 workers..."
and the response became incomplete near the second calculation.
Observation
The model was able to identify the underlying work-rate concept, but the solution was less robust and contained an inconsistency during generation.
π’ After Fine-Tuning
After fine-tuning on Alpaca-cleaned, the same model produced a much cleaner solution based on worker-days.
The model first establishes:
Therefore, the wall requires:
For 9 workers:
So:
For a 4-day deadline:
So:
The final response is direct, consistent, and mathematically complete.
βοΈ Before vs After
| Aspect | Before Fine-Tuning | After Fine-Tuning |
|---|---|---|
| Correct approach | β | β |
| Final result | Partially generated | β Complete |
| Reasoning structure | Moderate | β Clear |
| Intermediate consistency | β Contains an inconsistency | β Consistent |
| Work-rate explanation | β | β |
| Worker-days method | β Not used directly | β |
| Second calculation completed | β Incomplete | β |
| Overall clarity | Moderate | βββββ |
| Instruction following | Good | β Improved |
Key Takeaway
The most noticeable improvement is not simply the final numerical answer.
The fine-tuned model provides a more stable, structured, and complete solution, using a simpler formulation of the problem.
This illustrates one of the goals of instruction fine-tuning:
Turn a generally capable language model into a model that follows the requested task more consistently and produces more useful outputs.
π§ͺ Reproducible Inference
The same prompt can be used to compare the base and fine-tuned models.
inputs = tokenizer(
[
alpaca_prompt.format(
"Explain and solve the following problem in detail.",
"If 6 workers can build a wall in 12 days, how many days would it take 9 workers to build the same wall, assuming they work at the same rate? Also, if the wall needs to be built in 4 days, how many workers are needed?",
""
)
],
return_tensors="pt"
).to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=300,
use_cache=True
)
print(tokenizer.batch_decode(outputs)[0])
π Additional Inference Example
The same model can also be used for simpler instruction-following tasks.
messages = [
{
"role": "user",
"content": "Continue the Fibonacci sequence: 1, 1, 2, 3, 5, 8"
}
]
The fine-tuned model is intended to produce a direct continuation while following the requested format.
π What Improved?
The fine-tuning was intended to strengthen several areas:
Instruction Following
Better alignment between the requested task and the generated response.
Structured Reasoning
More organized progression from the problem statement to the solution.
Completeness
Greater tendency to finish all parts of a multi-part instruction.
Mathematical Consistency
Reduced likelihood of introducing inconsistent intermediate statements within a solution.
Clarity
More readable and practically useful explanations.
β οΈ Important Evaluation Note
The before/after example above is qualitative evidence from a single inference example, not a formal benchmark.
A proper evaluation should compare both models over a larger set of mathematical and instruction-following tasks using metrics such as:
| Metric | Purpose |
|---|---|
| Exact Answer Accuracy | Measures final correctness |
| Reasoning Accuracy | Measures validity of intermediate steps |
| Completion Rate | Measures whether all requested parts are answered |
| Instruction Following | Measures adherence to the prompt |
| Consistency | Measures stability across similar prompts |
| Response Quality | Measures clarity and usefulness |
πΎ Model Format
The final model was exported as a merged 16-bit model:
aliRafik/Qwen2.5_7B_Thinking_alpaca_Clean_16bit
This repository contains the merged model suitable for standard Transformer-based inference.
β‘ Why LoRA + Unsloth?
LoRA enables efficient fine-tuning by updating a relatively small set of trainable parameters instead of the entire model.
Unsloth was used to make the training process more memory-efficient and practical on consumer and cloud GPUs.
This combination makes it possible to fine-tune a 7B-parameter model with significantly lower resource requirements than full-parameter fine-tuning.
π€ Acknowledgements
This model builds upon:
- Qwen2.5
- Unsloth
- Hugging Face Transformers
- Hugging Face TRL
- yahma/alpaca-cleaned
- The original Stanford Alpaca project
β οΈ Limitations
This model can still produce:
- Incorrect mathematical reasoning
- Arithmetic mistakes
- Hallucinated information
- Incomplete answers
- Overly verbose responses
- Incorrect interpretations of ambiguous instructions
The model should therefore be evaluated on a broader benchmark before being used in production or high-stakes applications.
β Summary
Qwen2.5-7B Thinking β Alpaca Clean is a fine-tuned Qwen2.5-7B model trained on approximately 52K cleaned Alpaca instruction-following examples.
The goal of this project was to improve:
Instruction Following + Reasoning + Structure + Completeness
The before/after inference example demonstrates a practical improvement: the fine-tuned model produces a more consistent and complete solution to a multi-step mathematical problem, while using a simpler and clearer reasoning strategy.
Fine-tuning is not only about changing what a model knows β it can also change how effectively the model applies what it already knows.
- Downloads last month
- 395
