gpt-oss-20b-multilingual-unsloth

LoRA adapter for openai/gpt-oss-20b (loaded via unsloth/gpt-oss-20b), fine-tuned with Unsloth + TRL on the HuggingFaceH4/Multilingual-Thinking dataset.

The goal of this fine-tune is to steer the model's chain-of-thought reasoning (OpenAI's Harmony format) toward following the reasoning language field in the system prompt, so it can reason in English, French, German, Spanish, or Italian instead of only English.

  • Developed by: Artin Daneshvar
  • Base model: unsloth/gpt-oss-20b (4-bit, MXFP4)
  • Adapter type: LoRA (PEFT)
  • Language(s): en, fr, de, es, it
  • License: apache-2.0 (inherited from gpt-oss-20b)
  • Trained with: Unsloth 2x faster finetuning, TRL SFTTrainer
  • Hardware: 1x NVIDIA T4 (Google Colab, free tier)

Model Details

This is a LoRA adapter only β€” it is not a merged/standalone model. You need the base gpt-oss-20b weights plus this adapter to run it. The repo contains:

  • adapter_config.json
  • adapter_model.safetensors

Training Data

HuggingFaceH4/Multilingual-Thinking β€” reasoning chain-of-thought examples originally in English, translated into French, German, Spanish, and Italian. This is the same dataset used in OpenAI's gpt-oss fine-tuning cookbook.

Training Procedure

  • Loaded unsloth/gpt-oss-20b in 4-bit with FastLanguageModel, max_seq_length = 1024
  • LoRA applied to q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj (including MoE expert projections)
  • Trained only on assistant responses via Unsloth's train_on_responses_only (loss masked on user turns)
Hyperparameter Value
LoRA rank (r) 8
LoRA alpha 16
LoRA dropout 0
Gradient checkpointing unsloth
Batch size (per device) 1
Gradient accumulation 4
Learning rate 2e-4
LR scheduler linear
Warmup steps 5
Max steps 30
Optimizer adamw_8bit
Weight decay 0.001
Seed 3407

Note: This run used max_steps = 30 as a short demonstration run, not a full epoch over the dataset. Treat this checkpoint as a proof-of-concept rather than a fully converged fine-tune β€” expect a num_train_epochs = 1 (or more) run to give noticeably stronger results.

How to Get Started with the Model

Option 1: Unsloth (recommended, fastest)

from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "artindnr/gpt-oss-20b-multilingual-unsloth",
    max_seq_length = 1024,
    dtype = None,
    load_in_4bit = True,
)
FastLanguageModel.for_inference(model)

messages = [
    {"role": "system", "content": "reasoning language: French\n\nYou are a helpful assistant that can solve mathematical problems."},
    {"role": "user", "content": "Solve x^5 + 3x^4 - 10 = 3."},
]
inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt = True,
    return_tensors = "pt",
    return_dict = True,
    reasoning_effort = "medium",
).to("cuda")

from transformers import TextStreamer
_ = model.generate(**inputs, max_new_tokens = 256, streamer = TextStreamer(tokenizer))

Option 2: πŸ€— Transformers + PEFT

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch

base_model_id = "unsloth/gpt-oss-20b"
adapter_id = "artindnr/gpt-oss-20b-multilingual-unsloth"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    device_map = "auto",
    torch_dtype = torch.bfloat16,
    load_in_4bit = True,
)
model = PeftModel.from_pretrained(base_model, adapter_id)

messages = [
    {"role": "system", "content": "reasoning language: German\n\nYou are a helpful assistant."},
    {"role": "user", "content": "Explain how photosynthesis works."},
]
inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt = True,
    return_tensors = "pt",
    return_dict = True,
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens = 256)
print(tokenizer.decode(outputs[0], skip_special_tokens = True))

Set the reasoning language line in the system prompt to English, French, German, Spanish, or Italian to steer which language the model's internal reasoning is produced in.

Limitations

  • This adapter was trained for a small number of steps (30) as a demo run β€” reasoning-language adherence and output quality may be inconsistent. Consider training for more steps/epochs for production use.
  • Inherits all limitations and biases of the base gpt-oss-20b model.
  • Only tested with Unsloth's loading path at time of writing; GGUF/vLLM export for gpt-oss LoRA adapters was not yet supported by Unsloth when this was trained.

Framework versions

  • unsloth
  • trl == 0.22.2
  • transformers == 4.56.2
  • peft

Trained with Unsloth and Hugging Face's TRL library.

Downloads last month
31
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for artindnr/gpt-oss-20b-multilingual-unsloth

Adapter
(57)
this model

Dataset used to train artindnr/gpt-oss-20b-multilingual-unsloth

Collection including artindnr/gpt-oss-20b-multilingual-unsloth