Instructions to use khadim-hussain/gpt-oss-20b-stem-reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use khadim-hussain/gpt-oss-20b-stem-reasoning with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/gpt-oss-20b-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "khadim-hussain/gpt-oss-20b-stem-reasoning") - Transformers
How to use khadim-hussain/gpt-oss-20b-stem-reasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="khadim-hussain/gpt-oss-20b-stem-reasoning") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("khadim-hussain/gpt-oss-20b-stem-reasoning", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use khadim-hussain/gpt-oss-20b-stem-reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "khadim-hussain/gpt-oss-20b-stem-reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "khadim-hussain/gpt-oss-20b-stem-reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/khadim-hussain/gpt-oss-20b-stem-reasoning
- SGLang
How to use khadim-hussain/gpt-oss-20b-stem-reasoning 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 "khadim-hussain/gpt-oss-20b-stem-reasoning" \ --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": "khadim-hussain/gpt-oss-20b-stem-reasoning", "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 "khadim-hussain/gpt-oss-20b-stem-reasoning" \ --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": "khadim-hussain/gpt-oss-20b-stem-reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use khadim-hussain/gpt-oss-20b-stem-reasoning 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 khadim-hussain/gpt-oss-20b-stem-reasoning 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 khadim-hussain/gpt-oss-20b-stem-reasoning to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for khadim-hussain/gpt-oss-20b-stem-reasoning to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="khadim-hussain/gpt-oss-20b-stem-reasoning", max_seq_length=2048, ) - Docker Model Runner
How to use khadim-hussain/gpt-oss-20b-stem-reasoning with Docker Model Runner:
docker model run hf.co/khadim-hussain/gpt-oss-20b-stem-reasoning
GPT-OSS-20B STEM Reasoning (LoRA Adapter)
This is a LoRA adapter fine-tuned on OpenAI's GPT-OSS-20B for STEM reasoning tasks using the Harmony response format.
Author: Khadim Hussain
For the merged full model (larger download, standalone use), see: khadim-hussain/gpt-oss-20b-stem-reasoning-merged
Model Description
- Base Model: openai/gpt-oss-20b
- Type: LoRA Adapter (QLoRA 4-bit)
- Format: OpenAI Harmony format with analysis (thinking) and final channels
- Training: Fine-tuned on STEM Q&A dataset with chain-of-thought reasoning
Usage
from unsloth import FastLanguageModel
# Load model with adapter
model, tokenizer = FastLanguageModel.from_pretrained(
"khadim-hussain/gpt-oss-20b-stem-reasoning",
max_seq_length=2048,
load_in_4bit=True,
)
# Format prompt using Harmony format
prompt = """<|start|>system<|message|>You are a helpful assistant trained by OpenAI.
Reasoning: medium
# Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>user<|message|>What is DNA?<|end|><|start|>assistant"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=False))
Harmony Response Format
GPT-OSS uses the OpenAI Harmony format with channels:
<|channel|>analysis- Chain-of-thought reasoning (thinking)<|channel|>final- Final user-facing response
Example output:
<|start|>assistant<|channel|>analysis<|message|>DNA stands for deoxyribonucleic acid...<|end|>
<|start|>assistant<|channel|>final<|message|>DNA is a molecule that carries genetic instructions...<|return|>
Training Details
| Metric | Value |
|---|---|
| Train Loss | 1.087 |
| Eval Loss | 0.837 |
| Training Examples | 4,260 |
| Evaluation Examples | 474 |
| Epochs | 1 |
| LoRA Rank | 32 |
| LoRA Alpha | 64 |
Training Configuration
- Method: QLoRA (4-bit quantization)
- Optimizer: AdamW 8-bit
- Learning Rate: 1e-4
- Batch Size: 1 (with gradient accumulation 16)
- Framework: Unsloth + TRL
GGUF Version
A GGUF quantized version (Q8_0, ~21GB) is available for use with Ollama/llama.cpp:
Acknowledgments
- OpenAI - GPT-OSS-20B base model
- Unsloth - Fast fine-tuning framework
- Hugging Face - TRL, PEFT, Transformers
- llama.cpp - GGUF conversion tools
Citation
If you use this model, please cite:
@misc{hussain2026gptoss-stem,
author = {Hussain, Khadim},
title = {GPT-OSS-20B STEM Reasoning: Fine-tuned for Science Q&A with Chain-of-Thought},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/khadim-hussain/gpt-oss-20b-stem-reasoning}
}
Also cite the original GPT-OSS model:
@misc{openai2025gptoss,
author = {OpenAI},
title = {GPT-OSS: Open-Weight Language Models},
year = {2025},
url = {https://github.com/openai/gpt-oss}
}
License
Apache 2.0 (inherited from GPT-OSS)
- Downloads last month
- 3
Model tree for khadim-hussain/gpt-oss-20b-stem-reasoning
Base model
openai/gpt-oss-20b