Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained(
4 "khadim-hussain/gpt-oss-20b-stem-reasoning-merged",
5 torch_dtype="auto",
6 device_map="auto",
7 trust_remote_code=True,
8)
9tokenizer = AutoTokenizer.from_pretrained(
10 "khadim-hussain/gpt-oss-20b-stem-reasoning-merged",
11 trust_remote_code=True,
12)
13
14# GPT-OSS uses Harmony format
15prompt = """<|start|>system<|message|>You are a helpful assistant trained by OpenAI.
16
17Reasoning: medium
18
19# Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>user<|message|>What is DNA?<|end|><|start|>assistant"""
20
21inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
22outputs = model.generate(**inputs, max_new_tokens=512)
23print(tokenizer.decode(outputs[0], skip_special_tokens=False))| Property | Value |
|---|---|
| Base Model | openai/gpt-oss-20b |
| Type | Merged (LoRA merged into base weights) |
| Size | ~41GB (bf16) |
| Parameters | 21B total, 3.6B active (MoE) |
| Format | OpenAI Harmony |
| Training | QLoRA fine-tuning on STEM Q&A dataset |
<|channel|>analysis - Chain-of-thought reasoning (thinking)<|channel|>final - Final user-facing response<|start|>assistant<|channel|>analysis<|message|>DNA stands for deoxyribonucleic acid. It is a molecule...<|end|>
<|start|>assistant<|channel|>final<|message|>DNA is a molecule that carries genetic instructions used in growth, development, and reproduction.<|return|>| Metric | Value |
|---|---|
| Train Loss | 1.087 |
| Eval Loss | 0.837 |
| Training Examples | 4,260 |
| Evaluation Examples | 474 |
| Epochs | 1 |
1# Using Ollama
2ollama run khadim-hussain/gpt-oss-20b-stem-reasoning1@misc{hussain2026gptoss-stem,
2 author = {Hussain, Khadim},
3 title = {GPT-OSS-20B STEM Reasoning: Fine-tuned for Science Q&A with Chain-of-Thought},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/khadim-hussain/gpt-oss-20b-stem-reasoning-merged}
7}1@misc{openai2025gptoss,
2 author = {OpenAI},
3 title = {GPT-OSS: Open-Weight Language Models},
4 year = {2025},
5 url = {https://github.com/openai/gpt-oss}
6}