All GPT-OSS Model (15 Experts)
Project: https://amanpriyanshu.github.io/GPT-OSS-MoE-ExpertFingerprinting/
Introduction
This is a pruned variant of OpenAI's GPT-OSS-20B model, reduced to 15 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 all 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.
Model Architecture & Statistics
Metric | Value |
---|---|
Base Model | openai/gpt-oss-20b |
Architecture | Mixture-of-Experts Transformer |
Total Parameters | ~10.8B (pruned from 21B) |
Original Experts per Layer | 32 |
Pruned Experts per Layer | 15 |
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 | All |
Pruning Methodology
What is Expert Pruning?
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:
- Analyzing Usage Patterns: Tracking which experts activate most frequently for specific tasks
- Removing Underutilized Experts: Discarding experts with low activation rates for the target domain
- Preserving Router Functionality: Maintaining the routing mechanism with fewer available experts
Our Approach
- Data-Driven Selection: Used activation patterns from all evaluation tasks
- Systematic Reduction: Reduced from 32 to 15 experts per layer
- No Retraining: Direct removal without additional training steps
Performance & Applications
Pruning Benefits
- Smaller Memory Footprint: 46.9% of original expert parameters
- Reduced Computational Load: Fewer routing decisions during inference
- Focused Capabilities: Retains experts relevant to all tasks
Use Cases
- Speculative Decoding: Draft model for full GPT-OSS-20B
- Resource-Constrained Deployment: Edge devices, mobile applications
- Research: Study expert specialization in MoE models
- Fine-tuning: Smaller base model for domain adaptation
Note: Performance may vary depending on how well the pruned experts match your specific use case.
Motivation & Expert Selection
This general-purpose model maintains broad capabilities across all domains while significantly reducing computational requirements. It preserves the essential routing patterns discovered across our comprehensive analysis of diverse evaluation benchmarks including GPQA, MMLU, SORRY-Bench, and Tulu3 datasets.
The expert selection process utilized our comprehensive analysis of router activation patterns across multiple evaluation benchmarks:
- GPQA: Graduate-level questions in physics, chemistry, biology (Diamond & Expert subsets)
- MMLU/MMLU-Pro: Comprehensive knowledge across 57+ subjects including science, medicine, law
- SORRY-Bench: Safety evaluation across harmful content categories
- Tulu3: Persona-driven instruction following with verifiable constraints
- Polyglot-or-Not: Multilingual factual completion tasks
By identifying experts that consistently activated for all tasks, we created this specialized model that maintains domain expertise while significantly reducing computational requirements from 32 to 15 experts per layer.
Dataset & Analysis Foundation
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.
Pruning Methodology
Our approach involves:
- Activation Analysis: Comprehensive evaluation of expert usage patterns across domain-specific tasks
- Expert Ranking: Identification of the most frequently activated experts for target domains
- Systematic Pruning: Reduction from 32 to 15 experts while preserving router functionality
- Quality Validation: Testing to ensure maintained performance on target tasks
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.
Usage
CPU Inference
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the specialized model on CPU
model = AutoModelForCausalLM.from_pretrained(
"AmanPriyanshu/gpt-oss-10.8b-specialized-all-pruned-moe-only-15-experts",
torch_dtype=torch.bfloat16,
device_map="cpu",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("AmanPriyanshu/gpt-oss-10.8b-specialized-all-pruned-moe-only-15-experts")
# Generate with the model
messages = [
{"role": "user", "content": "What is artificial intelligence and how does it work?"}
]
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)
Apple Silicon (MPS) Inference
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-10.8b-specialized-all-pruned-moe-only-15-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-10.8b-specialized-all-pruned-moe-only-15-experts")
# Generate with the model
messages = [
{"role": "user", "content": "What is artificial intelligence and how does it work?"}
]
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)
GPU Inference
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
Model Examples
The following examples demonstrate the model's performance on all tasks:
Example 1
Question: What is artificial intelligence and how does it work?
Response:
<|channel|>analysis<|message|>Need explain AI, definition, components, how it works.<|end|><|start|>assistant<|channel|>final<|message|>## 1. What is Artificial Intelligence?
Artificial Intelligence (AI) is a field of computer science that seeks to build systems capable of **intelligent behavior**—that is, the ability to learn, reason, and act in a way that mimises human cognition.
In practice, AI systems are built from a combination of:
| Component | What it does | Typical technology |
|---|---|---|
| **Sensors / Input** | Gathers raw data (text, images, sound, etc.) | Cameras, microphones, text encoders |
| **Representation** | Turns raw data into a machine‑friendly format | Neural‑network layers, symbolic models, graphs |
| **Processing / Reasoning** | Manipulates the representation to produce insights | Algorithms, inference engines, pattern‑matching |
| **Learning** | Improves the system over time | Machine‑learning, reinforcement learning, deep‑learning |
| **Output / Action** | Communes or acts on the insight | Speech, text, images, robot motion |
The “intelligence” comes from the system’s ability to **learn from experience** (data) and **generalize** that learning to new situations.
---
## 2. How AI Works – A Step‑by‑Step Overview
Below is a simplified pipeline that most AI systems follow. The exact details vary by domain (e.g., language, vision, robotics), but the core ideas are the same.
### 1. **Data Acquisition**
- **Input**: Sensors or pre‑existing data (e.g., a sentence, a photo, a video clip).
- **Encoding**: Convert the raw signal into a digital format (e.g., bytes, pixels, tokens).
### 2. **Representation**
- **Modeling**: Build a structure that captures the essential features of the input.
- *Symbolic models*: Grammar trees for language, logic gates for circuits.
- *Statistical models*: Feature vectors, probability distributions.
- *Neural models*: Layers of neurons that learn patterns.
### 3. **Processing / Reasoning**
- **Inference**: Apply rules or learned patterns to the representation.
- *Rule‑based*: If‑then logic, Boolean networks.
- *Statistical*: Bayesian inference, expectation maximization.
- *Neural*: Conference of layers, attention mechanisms.
### 4. **Learning**
Example 2
Question: Explain Einstein's theory of relativity in simple terms.
Response:
<|channel|>analysis<|message|>Need simple explanation.<|end|><|start|>assistant<|channel|>final<|message|>**Einstein’s Theory of Relativity – in plain words**
---
### 1. What the theory is about
Einstein’s work is split into two main ideas:
| **Part** | **What it says** | **Why it matters** |
|---|---|---|
| **Classical (First) Relativity** | The speed of a moving object is measured relative to a reference point. | It explains why a car looks faster when you’re on a moving train. |
| **Quantum (Second) Relativity** | Space and time are not fixed; they can change depending on how fast something moves, especially near very fast (near‑light‑speed) objects. | It shows that the universe is a “soup” of particles that can behave in ways we can’t see with normal eyes. |
---
### 2. The “Classical” part – *Relative speed*
- **Speed is relative**: If you’re on a car that’s moving at 100 km/h, a car that’s moving at 200 km/h looks like it’s going 100 km/h faster.
- **No absolute speed**: There is no single “speed” that exists everywhere; it always depends on who’s point of reference.
---
### 3. The “Quantum” part – *Space, time, and light*
- **Particles can be “fuzzy”**: In the quantum world, particles can be in many places at the same time.
- **Light is a particle**: Light isn’t a single, fixed thing; it’s a stream of particles that can move at the speed of light (≈ 300 000 km/s).
- **Time can bend**: Near a very fast object (like a super‑fast spaceship or a black hole), the flow of time can change. Things that happen in the future can appear to happen sooner or later.
---
### 4. How it changed our view
- **Gravity is not a force**: Einstein showed that gravity is a *field* that pulls objects because of the way space itself is arranged.
- **The universe is a “wave”**: The universe is full of waves (light, sound, etc.) that carry information.
- **New physics**: The theory opened the way to quantum mechanics, explaining why atoms behave in ways that classical physics can’t predict.
---
### 5. Everyday
Example 3
Question: How does democracy function in modern governments?
Response:
<|channel|>analysis<|message|>Need to explain how democracy functions in modern governments. Provide overview of institutions, processes, checks, representation, elections, rule of law, etc.<|end|><|start|>assistant<|channel|>final<|message|>### 1. What “democracy” means today
In contemporary politics “democracy” is not a single, fixed model. It is a **set of practices and institutions** that allow citizens to influence the political process, while also protecting minority rights, the rule of law, and the stability of the state. Most modern democrans share a few core features:
| Feature | Typical expression in a modern state | Why it matters |
|---|---|---|
| **Representative institutions** (parliament, council, etc.) | Legislators elected by proportional or district‑based ballots | Gives a voice to the electorate in law‑making |
| **Free, competitive elections** | Regular, multi‑party contests with universal suff suff | Determines who will hold office |
| **Rule of law & separation of powers** | Judiciary independent, executive & legislature distinct | Prevents abuse of power |
| **Civil‑society participation** | NGOs, media, protests, public consultation | Allows citizens to shape policy beyond ballots |
| **Checks & balances** | Constitutional limits, oversight bodies, judicial review | Keeps power in check |
| **Protection of minorities** | Quotas, affirmative‑action laws, constitutional safeguards | Prevents tyranny of the majority |
These elements can be arranged in different ways (parliamentary vs. presidential, federal vs. unitary, etc.), but the combination of them is what modern democrans call “democracy.”
---
### 2. How the system works in practice
#### 2.1 The electoral cycle
1. **Campaigning** – Parties and candidates present platforms, debate, and advertise.
2. **Voting** – Citizens cast ballots (paper, electronic, absentee).
3. **Counting & certification** – Election commissions verify results.
4. **Transition** – Newly elected officials assume office, often after a “hand‑over” period.
The electoral cycle is the most visible democratic mechanism, but it is only one layer of governance.
#### 2.2 Representative bodies
- **Parliament / Congress**: Drafts laws, debates policy, and holds the executive accountable.
- **Executive (President, Prime Minister, etc.)**: Implements laws, runs the state, and is usually elected or appointed by the legislature.
- **
Citation
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}
}
References & Resources
- Original Model: OpenAI GPT-OSS Model Card
- Model Hub: GPT-OSS-20B on Hugging Face
- Expert Analysis Dataset: GPT-OSS-20B MoE Expert Activations
- Project Page: GPT-OSS MoE Expert Fingerprinting
- GitHub Repository: OpenAI GPT-OSS
- Downloads last month
- -