Instructions to use ZalzalaKhan/NLP-Project-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ZalzalaKhan/NLP-Project-2 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-0.5B-Instruct") model = PeftModel.from_pretrained(base_model, "ZalzalaKhan/NLP-Project-2") - Transformers
How to use ZalzalaKhan/NLP-Project-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ZalzalaKhan/NLP-Project-2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ZalzalaKhan/NLP-Project-2", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ZalzalaKhan/NLP-Project-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ZalzalaKhan/NLP-Project-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZalzalaKhan/NLP-Project-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ZalzalaKhan/NLP-Project-2
- SGLang
How to use ZalzalaKhan/NLP-Project-2 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 "ZalzalaKhan/NLP-Project-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZalzalaKhan/NLP-Project-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "ZalzalaKhan/NLP-Project-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZalzalaKhan/NLP-Project-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use ZalzalaKhan/NLP-Project-2 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ZalzalaKhan/NLP-Project-2 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ZalzalaKhan/NLP-Project-2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ZalzalaKhan/NLP-Project-2 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="ZalzalaKhan/NLP-Project-2", max_seq_length=2048, ) - Docker Model Runner
How to use ZalzalaKhan/NLP-Project-2 with Docker Model Runner:
docker model run hf.co/ZalzalaKhan/NLP-Project-2
| base_model: unsloth/Qwen2.5-0.5B-Instruct | |
| library_name: peft | |
| pipeline_tag: text-generation | |
| tags: | |
| - base_model:adapter:unsloth/Qwen2.5-0.5B-Instruct | |
| - grpo | |
| - lora | |
| - math | |
| - gsm8k | |
| - transformers | |
| - trl | |
| - unsloth | |
| # Qwen2.5-0.5B-Instruct — GSM8K Math Reasoning (SFT → GRPO) | |
| LoRA adapter fine-tuned on Qwen2.5-0.5B-Instruct for mathematical reasoning | |
| using a two-stage SFT → GRPO pipeline. Trained on Kaggle T4 GPU. | |
| **IBA Karachi · NLP with Deep Learning · Assignment 04 · Option C** | |
| **Authors:** Immaduddin Durrani, Raahin Tajuddin, Ibad Khan | |
| ## Results | |
| | Stage | Judge Score | vs Baseline | | |
| |-------|------------|-------------| | |
| | Baseline (no fine-tuning) | 5.93/10 | — | | |
| | Best SFT (T1) | 6.40/10 | +7.9% | | |
| | **Best GRPO (G1) ← this model** | **7.03/10** | **+18.6%** | | |
| Evaluated on 30 held-out GSM8K test prompts using LLM-as-Judge | |
| (Llama 3.3-70B via NVIDIA NIM), 4-axis rubric | |
| (Correctness 0-4, Reasoning 0-3, Format 0-2, Conciseness 0-1). | |
| ## How to Use | |
| ```python | |
| from peft import AutoPeftModelForCausalLM | |
| from transformers import AutoTokenizer | |
| model = AutoPeftModelForCausalLM.from_pretrained("ZalzalaKhan/Qwen2.5-0.5B-GSM8K-GRPO") | |
| tokenizer = AutoTokenizer.from_pretrained("ZalzalaKhan/Qwen2.5-0.5B-GSM8K-GRPO") | |
| messages = [ | |
| {"role": "system", "content": "Reason step by step and clearly provide the final numerical answer."}, | |
| {"role": "user", "content": "Janet has 10 apples. She gives 3 to her friend. How many does she have left?"} | |
| ] | |
| input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True) | |
| output = model.generate(input_ids, max_new_tokens=256, temperature=0.6, top_p=0.95) | |
| print(tokenizer.decode(output[0], skip_special_tokens=True)) | |
| ``` | |
| ## Training Details | |
| ### Pipeline Overview | |
| **Stage 1 — SFT (NB-1):** Fine-tuned on MetaMathQA hard split (1,500 samples, | |
| LoRA rank-32, 2 epochs, 8 min on T4). Best trial T1 reached 6.40/10. | |
| **Stage 2 — GRPO (NB-2):** Reinforcement learning from correctness reward on | |
| GSM8K train split (500 samples, group size 8, KL=0.1, 162 min on T4). | |
| Best trial G1 reached 7.03/10. | |
| ### GRPO Hyperparameters (G1) | |
| | Parameter | Value | | |
| |-----------|-------| | |
| | Base model | SFT T1 checkpoint | | |
| | LoRA Rank | 32 | | |
| | Target Modules | q_proj, v_proj | | |
| | KL Coefficient | 0.1 | | |
| | Learning Rate | 1e-5 | | |
| | Group Size | 8 | | |
| | Generation Temp | 0.6 | | |
| | Train Samples | 500 (GSM8K) | | |
| | Training Time | 162 min (Kaggle T4) | | |
| ### Data | |
| - **SFT:** MetaMathQA hard split (no overlap with test set) | |
| - **GRPO:** GSM8K train split, stratified 400 medium + 100 easy | |
| - **Eval:** 30 held-out GSM8K test prompts (10 easy / 10 medium / 10 hard) | |
| ## Framework Versions | |
| - PEFT 0.18.1 | |
| - Unsloth 2026.5.8 | |
| - TRL 0.24.0 | |
| - Transformers 5.5.0 | |
| - PyTorch 2.10.0+cu118 |