gpt-oss-20b-drawing-expert
generating runnable charts and graphics in Python
3 min read
This model turns an English text prompt (optionally with a data schema description) into a ready-to-run Python script for data visualization or image generation. It outputs clean code using matplotlib, seaborn, or PIL/Pillow to plot charts with labels and subplots, or render raster graphics to output.png. Created by Malajusa, it is an SFT (supervised fine-tuning) LoRA (an adapter trained on top of frozen weights) built on openai/gpt-oss-20b (20.91B parameters, MoE architecture). While the base model produces runnable code only 35.1% of the time, this fine-tuned version passed 100% of test runs in a sandbox environment. It is built for developers, data analysts, and AI agent builders who need automated chart generation without syntax errors.
Key features
- 100% test execution rate: On a held-out set of 57 prompts, the model generated 57 working scripts (30/30 for matplotlib and 27/27 for PIL), whereas the base
gpt-oss-20bsucceeded on only 20 out of 57. - Trained on verified code: The
programmatic-drawing-sftdataset (9,901 training examples) consists strictly of scripts that executed cleanly in an isolated environment prior to training. - Self-contained scripts: The model generates its own mock
DataFramewith the required columns based on your schema description, so the code runs right away without external CSV files. - Harmony response format: The model outputs pure Python code in the
finalchannel, making it easy to strip special tokens usingskip_special_tokens=True.
What you can do
- Plug it into an analytics AI agent or Telegram bot to generate sales charts, histograms, and moving averages on demand using
matplotliborseaborn. - Generate procedural illustrations, gradients, grids, and diagrams into
output.pngwithPIL/Pillow—no diffusion models required. - Pair it with a code-execution sandbox to automate on-the-fly visualizations for tabular reports.
Example
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("openai/gpt-oss-20b")
model = AutoModelForCausalLM.from_pretrained(
"Malajusa/gpt-oss-20b-drawing-expert", device_map="cuda", dtype="bfloat16"
)
messages = [{"role": "system", "content": "You are an expert Python plotting assistant."},
{"role": "user", "content": "Plot monthly sales of shampoo as a line chart with a moving average."}]
text = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
ids = tok(text, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=768)
print(tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True))
Read more
DetailsBenchmark (execution eval, 90s timeout): 57/57 (100%) vs. 20/57 (35.1%) for the base
openai/gpt-oss-20b.Training: LoRA (r=32, alpha=32) on 1x RTX PRO 6000 (96 GB) took ~56 minutes with a peak VRAM usage of 48.9 GB.
Important limitation: Quantized MXFP4 checkpoints may output gibberish on transformers 5.24.0 / torch 2.15.0+cu132—for reliable inference, the author recommends loading the standalone LoRA adapter on top of the base bf16 model.
Note that the 100% pass rate was achieved on prompts from the same template generator used for the training split, so accuracy on out-of-distribution phrasing may vary.










Comments