Downloads · 30 days
10
8% of all-time downloads
AmanPriyanshu/gpt-oss-20.3b-specialized-science-pruned-moe-only-31-experts
gpt-oss-20.3b-specialized-science-pruned-moe-only-31-experts is a text generation model from AmanPriyanshu. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
Project: https://amanpriyanshu.github.io/GPT-OSS-MoE-ExpertFingerprinting/
Downloads · 30 days
10
8% of all-time downloads
All-time downloads
119
Public
Parameters
20.3B
40.7 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors40.6 GB · 100%
From the Hugging Face model README
Project: https://amanpriyanshu.github.io/GPT-OSS-MoE-ExpertFingerprinting/
<div align="center">This is a pruned variant of OpenAI's GPT-OSS-20B model, reduced to 31 experts per layer based on activation patterns from the AmanPriyanshu/GPT-OSS-20B MoE Expert Activations dataset. We analyzed router decisions across evaluation benchmarks to identify and retain experts most relevant for science tasks.
⚠️ Experimental Model: This is an experimental pruned model that may not work well - check the examples below to see if the outputs meet your needs before use.
This pruning approach reduces the model size while attempting to preserve performance on the target domain.
| Metric | Value |
|---|---|
| Base Model | openai/gpt-oss-20b |
| Architecture | Mixture-of-Experts Transformer |
| Total Parameters | ~20.3B (pruned from 21B) |
| Original Experts per Layer | 32 |
| Pruned Experts per Layer | 31 |
| Layers | 24 |
| Top-k Routing | 4 |
| Context Length | 128K tokens |
| Attention Heads | 64 (Query), 8 (Key-Value) |
| Residual Dimension | 2880 |
| Attention Pattern | Alternating dense & sliding window (128 tokens) |
| Positional Encoding | RoPE (Rotary Position Embedding) |
| Normalization | RMSNorm |
| Precision | BF16 |
| License | Apache 2.0 |
| Specialization | Science |
Mixture-of-Experts models contain multiple specialized sub-networks (experts) per layer. During inference, only a subset of experts are activated for each token. Expert pruning involves:
Note: Performance may vary depending on how well the pruned experts match your specific use case.
This science-specialized model leverages experts that showed high activation patterns during scientific reasoning tasks from GPQA (physics, chemistry, biology) and MMLU science domains. These experts demonstrate superior performance on complex scientific problem-solving and technical knowledge recall.
The expert selection process utilized our comprehensive analysis of router activation patterns across multiple evaluation benchmarks:
By identifying experts that consistently activated for science tasks, we created this specialized model that maintains domain expertise while significantly reducing computational requirements from 32 to 31 experts per layer.
This model is based on analysis from the GPT-OSS-20B MoE Expert Activations dataset available at: 🔗 https://huggingface.co/datasets/AmanPriyanshu/GPT-OSS-20B-MoE-expert-activations
The dataset contains router activation patterns from OpenAI's GPT-OSS-20B model across diverse evaluation benchmarks, enabling the creation of these domain-optimized models through systematic expert pruning.
Our approach involves:
This is a direct pruning approach - no additional training was performed. The model inherits all capabilities from the original GPT-OSS-20B with focused expert selection.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the specialized model on CPU
model = AutoModelForCausalLM.from_pretrained(
"AmanPriyanshu/gpt-oss-20.3b-specialized-science-pruned-moe-only-31-experts",
torch_dtype=torch.bfloat16,
device_map="cpu",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("AmanPriyanshu/gpt-oss-20.3b-specialized-science-pruned-moe-only-31-experts")
# Generate with the model
messages = [
{"role": "user", "content": "Explain the process of photosynthesis in plants."}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
reasoning_effort="medium"
)
# Ensure inputs are on the same device as model
inputs = {k: v.to(model.device) for k, v in inputs.items()}
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=True,
temperature=0.1,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id,
eos_token_id=tokenizer.eos_token_id
)
# Decode only the generated part
input_length = inputs['input_ids'].shape[1]
response_tokens = outputs[0][input_length:]
response = tokenizer.decode(response_tokens, skip_special_tokens=True)
print(response)
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Check MPS availability and load model
device = "mps" if torch.backends.mps.is_available() else "cpu"
model = AutoModelForCausalLM.from_pretrained(
"AmanPriyanshu/gpt-oss-20.3b-specialized-science-pruned-moe-only-31-experts",
torch_dtype=torch.float16, # Better MPS compatibility
device_map=device,
trust_remote_code=True,
low_cpu_mem_usage=True
)
tokenizer = AutoTokenizer.from_pretrained("AmanPriyanshu/gpt-oss-20.3b-specialized-science-pruned-moe-only-31-experts")
# Generate with the model
messages = [
{"role": "user", "content": "Explain the process of photosynthesis in plants."}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
reasoning_effort="medium"
)
# Move inputs to model device
inputs = {k: v.to(model.device) if isinstance(v, torch.Tensor) else v for k, v in inputs.items()}
# Use torch.no_grad for MPS stability
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=True,
temperature=0.1,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id,
eos_token_id=tokenizer.eos_token_id,
use_cache=True
)
# Decode only the generated part
input_length = inputs['input_ids'].shape[1]
response_tokens = outputs[0][input_length:]
response = tokenizer.decode(response_tokens, skip_special_tokens=True)
print(response)
For CUDA GPU inference, the models work with minimal modifications from the CPU example above. Simply change:
device_map="auto" # Will automatically use GPU if available
torch_dtype=torch.bfloat16 # or torch.float16
The following examples demonstrate the model's performance on science tasks:
Question: Explain the process of photosynthesis in plants.
Response:
<|channel|>analysis<|message|>Need to explain photosynthesis.<|end|><|start|>assistant<|channel|>final<|message|>**Photosynthesis** is the process by which green plants, algae, and some bacteria convert light energy from the sun into chemical energy stored in glucose (a sugar) and other organic molecules. It is the foundation of almost all life on Earth because it supplies the oxygen we breathe and the organic matter that fuels food webs.
---
## 1. Where It Happens
| Component | Location | Role |
|-----------|----------|------|
| **Chloroplast** | Cell organelle | Houses the machinery for photosynthesis |
| **Thylakoid membranes** | Inside chloroplast | Site of light‑dependent reactions |
| **Stroma** | Fluid surrounding thylakoids | Site of light‑independent (Calvin) cycle |
| **Chlorophyll** | Pigment in thylakoids | Captures light energy |
---
## 2. Two Main Phases
1. **Light‑Dependent Reactions (Photophosphorylation)**
2. **Light‑Independent Reactions (Calvin Cycle / Dark Reactions)**
### 2.1 Light‑Dependent Reactions
| Step | What Happens | Key Molecules |
|------|--------------|---------------|
| **1. Light absorption** | Chlorophyll and accessory pigments absorb photons. | Chlorophyll a, b, carotenoids |
| **2. Water splitting (Photolysis)** | Light energy splits H₂O into O₂, H⁺, and electrons. | H₂O → ½ O₂ + 2H⁺ + 2e⁻ |
| **3. Electron transport chain (ETC)** | Electrons move through Photosystem II → plastoquinone → cytochrome b₆f → Photosystem I → plastocyanin. | PSII, PQ, Cyt b₆f, PSI, PC |
| **4. ATP synthesis** | Proton gradient (ΔpH) drives ATP synthase. | ATP |
| **5. NADPH formation** | Electrons reduce NADP⁺ to NADPH. | NADPH |
| **6. Oxygen release** | O₂ is released as a by‑product. | O₂ |
**Net result of light‑dependent reactions:**
\[
2\,\text{H}_2\text{O} + 2\,\text{NADP}^+ + 3\,\text{ADP} +
Question: What causes the greenhouse effect and how does it work?
Response:
<|channel|>analysis<|message|>Need explain greenhouse effect causes, mechanism, gases, radiation, etc.<|end|><|start|>assistant<|channel|>final<|message|>**The greenhouse effect** is the natural process that keeps Earth’s surface warm enough to support life. It is caused by certain gases in the atmosphere that absorb and re‑radiate infrared (IR) radiation emitted by the planet’s surface. Below is a step‑by‑step explanation of what causes it and how it works.
---
## 1. Solar Energy Reaches Earth
| Step | What Happens | Key Points |
|------|--------------|------------|
| **1. Solar radiation** | The Sun emits a spectrum of electromagnetic radiation, from ultraviolet (UV) to visible light to infrared (IR). | About 1,361 W/m² (solar constant) reaches the top of Earth’s atmosphere. |
| **2. Atmospheric filtering** | Some UV and visible light is absorbed by the ozone layer and other gases; the rest passes through. | Roughly 70 % of incoming solar energy reaches the surface. |
| **3. Surface absorption** | The Earth’s surface (land, oceans, ice) absorbs the short‑wave radiation and warms. | Warm surface emits long‑wave (infrared) radiation. |
---
## 2. Surface Emits Infrared Radiation
- **Thermal radiation**: Warm objects emit IR radiation proportional to their temperature (Stefan–Boltzmann law: \(E = \sigma T^4\)).
- **Typical surface temperature**: ~288 K (15 °C) → emission peaks around 10 µm wavelength.
---
## 3. Greenhouse Gases Absorb IR
| Gas | Wavelengths absorbed | Typical atmospheric concentration |
|-----|----------------------|-----------------------------------|
| **Water vapor (H₂O)** | 5–8 µm, 12–20 µm | Variable, up to 4 % by volume |
| **Carbon dioxide (CO₂)** | 4.3 µm, 15 µm | ~0.04 % (400 ppm) |
| **Methane (CH₄)** | 7.7 µm | ~0.0002 % (1.8 ppm) |
| **Nitrous oxide (N₂O)** | 4.5 µm | ~0.00002 % (0.3 ppm) |
| **Ozone (O₃)** |
Question: Describe the structure and function of DNA.
Response:
<|channel|>analysis<|message|>Need concise description.<|end|><|start|>assistant<|channel|>final<|message|>**DNA (Deoxyribonucleic Acid)** is the hereditary material that carries the genetic instructions used in the growth, development, functioning, and reproduction of all known living organisms and many viruses. Its structure and function can be understood in two complementary parts:
---
## 1. Structure of DNA
| Feature | Description | Significance |
|---------|-------------|--------------|
| **Double‑Helix** | Two complementary strands wound around each other like a twisted ladder. | Provides stability and a compact way to store long sequences of genetic information. |
| **Backbone** | Alternating deoxyribose sugars and phosphate groups. | Forms a sturdy, negatively charged scaffold that protects the bases and allows enzymes to read the sequence. |
| **Nitrogenous Bases** | Four types: Adenine (A), Thymine (T), Cytosine (C), Guanine (G). | Encode genetic information; base‑pairing (A‑T, C‑G) ensures accurate replication. |
| **Base‑Pairing Rules** | A pairs with T via two hydrogen bonds; C pairs with G via three hydrogen bonds. | Maintains the uniform width of the helix and allows precise copying of DNA. |
| **Antiparallel Orientation** | One strand runs 5’→3’, the other 3’→5’. | Essential for replication and transcription machinery to function correctly. |
| **Supercoiling & Chromatin** | DNA is wrapped around histone proteins forming nucleosomes, further coiled into higher‑order structures. | Enables compaction into chromosomes and regulates access to genetic information. |
---
## 2. Function of DNA
| Function | How It Works | Biological Importance |
|----------|--------------|-----------------------|
| **Genetic Information Storage** | The sequence of bases constitutes the genome. | Determines the traits and capabilities of an organism. |
| **Replication** | DNA polymerases synthesize a new complementary strand using the existing strand as a template. | Enables cell division and inheritance of genetic material. |
| **Transcription (DNA → RNA)** | RNA polymerase reads a DNA template strand and synthesizes messenger RNA (mRNA). | Transfers genetic information from the nucleus to the cytoplasm for protein synthesis. |
| **Translation (RNA → Protein)** | Ribosomes read mRNA codons and assemble amino acids into polypeptide chains. | Produces the proteins that perform cellular functions
If you use this model in your research, please cite:
@misc{priyanshu2025gptoss,
title={{GPT-OSS MoE Expert Fingerprinting: Analyzing Expert Activation Patterns in Mixture of Experts Models}},
author={Priyanshu, Aman and Vijay, Supriti},
year={2025},
howpublished={\url{https://amanpriyanshu.github.io/GPT-OSS-MoE-ExpertFingerprinting/}},
note={Interactive analysis tool for expert activation patterns in MoE architectures}
}