Downloads · 30 days
13
9% of all-time downloads
AmanPriyanshu/gpt-oss-19.7b-specialized-all-pruned-moe-only-30-experts
gpt-oss-19.7b-specialized-all-pruned-moe-only-30-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
13
9% of all-time downloads
All-time downloads
148
Public
Parameters
19.7B
39.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors39.4 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 30 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.
| Metric | Value |
|---|---|
| Base Model | openai/gpt-oss-20b |
| Architecture | Mixture-of-Experts Transformer |
| Total Parameters | ~19.7B (pruned from 21B) |
| Original Experts per Layer | 32 |
| Pruned Experts per Layer | 30 |
| 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 |
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 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:
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 30 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-19.7b-specialized-all-pruned-moe-only-30-experts",
torch_dtype=torch.bfloat16,
device_map="cpu",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("AmanPriyanshu/gpt-oss-19.7b-specialized-all-pruned-moe-only-30-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)
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-19.7b-specialized-all-pruned-moe-only-30-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-19.7b-specialized-all-pruned-moe-only-30-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)
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 all tasks:
Question: What is artificial intelligence and how does it work?
Response:
<|channel|>analysis<|message|>Need explain AI, types, how works.<|end|><|start|>assistant<|channel|>final<|message|>## What Is Artificial Intelligence?
Artificial Intelligence (AI) is a branch of computer science that builds systems capable of performing tasks that normally require human intelligence. These tasks include:
| Task | Human‑like Skill | Typical AI Approach |
|------|------------------|---------------------|
| Recognizing faces | Visual perception | Computer vision, deep learning |
| Understanding speech | Natural language | Speech‑to‑text, language models |
| Making decisions | Reasoning, planning | Rule‑based systems, reinforcement learning |
| Learning from data | Pattern recognition | Supervised/unsupervised learning |
| Interacting socially | Empathy, dialogue | Conversational agents, affective computing |
In short, **AI = algorithms + data + computing power** that lets machines *observe, learn, reason, and act*.
---
## How Does AI Work? (A High‑Level View)
1. **Data Collection & Preparation**
- Gather raw data (images, text, sensor readings, etc.).
- Clean, label, and transform it into a format suitable for training.
2. **Model Selection**
- Choose an algorithm that matches the problem:
- *Supervised learning* (classification, regression)
- *Unsupervised learning* (clustering, dimensionality reduction)
- *Reinforcement learning* (policy learning)
- *Generative models* (GANs, VAEs)
- *Rule‑based systems* (expert systems)
3. **Training (Learning)**
- Feed data into the model.
- Adjust internal parameters (weights) to minimize a loss function.
- Use optimization techniques (gradient descent, back‑propagation).
4. **Evaluation**
- Test the model on unseen data.
- Measure performance with metrics (accuracy, F1, BLEU, etc.).
- Iterate: tweak architecture, hyper‑parameters, or data.
5. **Deployment**
- Integrate the trained model into an application (mobile app, web service, robot).
- Monitor performance, retrain as needed.
6. **Feedback Loop**
- Collect new data from real‑world usage.
- Update the model to improve accuracy and adapt to changes.
---
## Core AI Techniques
| Technique | What It Does | Example Use‑Case |
|-----------|--------------|-----------------|
| **Neural Networks** | Mimic brain‑like layers of neurons | Image
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** is really two ideas that changed how we think about space, time, and gravity. Think of them as two “rules” that tell us how the universe behaves when things move fast or are near massive objects.
---
## 1. Special Relativity (1905)
### The “speed‑of‑light” rule
- **Light always moves at the same speed** (≈ 299 792 km/s) no matter how fast you’re moving or where you’re looking from.
- Because light’s speed is fixed, **time and space are not absolute**. They bend to keep that speed constant.
### What that means
| What you’re used to | What actually happens |
|---------------------|-----------------------|
| Time is the same everywhere | Time **slows down** for a fast‑moving clock (time dilation). |
| Length is the same everywhere | Moving objects **shrink** in the direction of motion (length contraction). |
| Simultaneity is universal | Events that look simultaneous to one observer may not be to another. |
**Why it matters:**
- If you travel in a spaceship at 99 % the speed of light, you’ll age slower than people on Earth.
- The famous “twin paradox” is a real, measurable effect.
---
## 2. General Relativity (1915)
### Gravity is geometry
- Instead of a mysterious “force” pulling objects, **mass curves the fabric of space‑time**.
- Objects move along the straightest possible paths in this curved geometry (geodesics).
- The more massive an object, the more it warps space‑time.
### Everyday consequences
| Classic picture | General‑relativistic picture |
|-----------------|------------------------------|
| Earth orbits the Sun because the Sun pulls on it. | The Sun’s mass bends space‑time; Earth follows a curved path (an orbit) that is “straight” in that curved geometry. |
| Light bends around a massive star. | Light follows the curved space‑time, so it appears bent to us. |
| Time runs slower near a massive body. | Clocks closer to Earth (or any massive object) tick slightly slower than clocks far away. |
**Why it matters:**
- GPS satellites must correct for both special‑relativistic (speed) and general‑relativistic (gravity) time
Question: How does democracy function in modern governments?
Response:
<|channel|>analysis<|message|>Need to explain democratic functioning.<|end|><|start|>assistant<|channel|>final<|message|>### 1. What “democracy” means today
Modern democracies are usually **constitutional republics**: a written constitution, separation of powers, and a system of checks and balances.
Key features:
| Feature | What it looks like in practice |
|---------|--------------------------------|
| **Popular sovereignty** | Citizens elect representatives or vote directly on key issues. |
| **Rule of law** | Laws apply equally; courts can strike down unconstitutional acts. |
| **Separation of powers** | Executive, legislature, judiciary operate independently. |
| **Protection of rights** | Constitutional guarantees (speech, assembly, due process). |
| **Pluralism & competition** | Multiple parties, interest groups, and civil society. |
| **Transparency & accountability** | Open government, audits, whistle‑blower protections. |
---
### 2. How the system works in a typical modern state
| Stage | What happens | Typical institutions |
|-------|--------------|----------------------|
| **Election cycle** | Citizens vote for representatives (parliament, congress, local councils). | Electoral commissions, polling stations, ballot counting. |
| **Legislative process** | Bills are drafted, debated, amended, and voted on. | Parliament, committees, public hearings. |
| **Executive action** | The head of state/government implements laws, manages policy, and represents the country. | President/Prime Minister, cabinet, ministries. |
| **Judicial review** | Courts interpret laws and can invalidate unconstitutional acts. | Supreme Court, appellate courts, constitutional courts. |
| **Oversight & audit** | Independent bodies scrutinize government spending and performance. | Auditors General, anti‑corruption agencies, ombudsmen. |
| **Civil society & media** | Citizens, NGOs, and journalists hold power to account. | NGOs, watchdogs, press, social media. |
---
### 3. Democratic mechanisms in action
| Mechanism | How it functions | Example |
|-----------|------------------|---------|
| **Direct democracy** | Citizens vote on specific policies (referenda, initiatives). | Swiss referenda, U.S. ballot initiatives in California. |
| **Representative democracy** | Elected officials make decisions on behalf of constituents. | U.S. Congress, UK Parliament. |
| **Deliberative democracy** | Structured discussion to reach consensus (citizen assemblies, deliberative polls). | Irish Citizens’ Assembly
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}
}