Instructions to use inference-optimization/gpt-oss-1.5B-A1.4B-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inference-optimization/gpt-oss-1.5B-A1.4B-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="inference-optimization/gpt-oss-1.5B-A1.4B-small") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("inference-optimization/gpt-oss-1.5B-A1.4B-small") model = AutoModelForCausalLM.from_pretrained("inference-optimization/gpt-oss-1.5B-A1.4B-small", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use inference-optimization/gpt-oss-1.5B-A1.4B-small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "inference-optimization/gpt-oss-1.5B-A1.4B-small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inference-optimization/gpt-oss-1.5B-A1.4B-small", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/inference-optimization/gpt-oss-1.5B-A1.4B-small
- SGLang
How to use inference-optimization/gpt-oss-1.5B-A1.4B-small 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 "inference-optimization/gpt-oss-1.5B-A1.4B-small" \ --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": "inference-optimization/gpt-oss-1.5B-A1.4B-small", "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 "inference-optimization/gpt-oss-1.5B-A1.4B-small" \ --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": "inference-optimization/gpt-oss-1.5B-A1.4B-small", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use inference-optimization/gpt-oss-1.5B-A1.4B-small with Docker Model Runner:
docker model run hf.co/inference-optimization/gpt-oss-1.5B-A1.4B-small
gpt-oss-1.5B-A1.4B-small
This is a small version of unsloth/gpt-oss-20b-BF16 created for testing and development. It keeps all hidden dimensions and hyperparameters of the base model identical, reducing only the number of layers, the layer-type layout, and the number of MoE experts, so it exercises the same architecture (gpt-oss MoE with alternating sliding/full attention, attention sinks, YaRN rope, tanh-limited SwiGLU experts with grouped per-expert tensor storage) at a fraction of the size.
Model Details
- Base Model: unsloth/gpt-oss-20b-BF16
- Architecture: gpt_oss (GptOssForCausalLM)
- Total Parameters: 1.51B (1,510,118,220)
- Activated Parameters: 1.41B (1,410,550,860; top-4-of-6 experts per MoE layer)
Configuration Changes
Only the three allowed categories of changes were made (layer counts, layer-type layout, expert count); every other hyperparameter is identical to the base:
| Parameter | Base | Small |
|---|---|---|
num_hidden_layers |
24 | 2 |
layer_types |
24 layers alternating sliding_attention / full_attention |
sliding_attention, full_attention |
num_local_experts |
32 | 6 |
The 2 layers are the minimal set covering every distinct attention layer type (sliding_attention with sliding_window 128, full_attention), mirroring the base's alternating pattern; all base layers are MoE. 6 experts >= num_experts_per_tok 4 (topk+2 for non-degenerate routing). Everything else — hidden size 2880, intermediate size 2880, vocab 201088, 64 Q heads / 8 KV heads / head_dim 64, attention bias + attention sinks, YaRN rope parameters (theta 150000, factor 32, beta_fast 32, beta_slow 1), sliding_window 128, swiglu_limit 7.0, router settings, tie_word_embeddings: false (this base checkpoint has an untied lm_head.weight), max_position_embeddings 131072 — is unchanged from the base.
Checkpoint Structure
Single-file model.safetensors (bf16, ~3.0GB), unsharded. Tensor naming follows the base checkpoint exactly (validated: all 20 tensor-name patterns and both per-layer key sets match the base model.safetensors.index.json modulo layer count), including the gpt-oss "transformer" layout specifics: grouped 3D expert tensors mlp.experts.gate_up_proj / gate_up_proj_bias / down_proj / down_proj_bias, mlp.router.{weight,bias}, self_attn.sinks, and biased q/k/v/o_proj.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("inference-optimization/gpt-oss-1.5B-A1.4B-small", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("inference-optimization/gpt-oss-1.5B-A1.4B-small")
input_ids = tokenizer("According to all known laws", return_tensors="pt").input_ids.to(model.device)
output = model.generate(input_ids, max_new_tokens=20)
print(tokenizer.decode(output[0]))
Creation Process
This model was created using the llm-compressor create-tiny-model skill.
The config was derived from the base AutoConfig applying only the changes in the table above, the model was built with random init (skip_weights_download + init_weights()), and then fine-tuned on the skill's toy copypasta dataset (8 texts, ~160 steps, lr 1e-4, bf16) until the perplexity stopping criterion was reached.
Validation
- Perplexity on the toy dataset text: 1.0001141 (target <= 10)
- Greedy generation reproduces the training text ("According to all known laws of aviation, there is no way a bee should be able to fly.")
- Checkpoint tensor-name structure matches the base index.json (20/20 patterns; per-layer key sets identical)
Notes
- The base
unsloth/gpt-oss-20b-BF16is unquantized bf16 (noquantization_config), so no quantization handling was needed; this small model is plain bf16. - The base has untied embeddings (
tie_word_embeddings: falsewith a separatelm_head.weightin the checkpoint; note the original openai/gpt-oss-20b release is tied, but this unsloth BF16 conversion is not). The untied 201088 x 2880 embedding + lm_head matrices alone cost ~1.16B parameters, which pushes the minimal covering model to 1.51B total. num_nextn_predict_layersis not present in this architecture; no MTP weights exist.
- Downloads last month
- 38