Instructions to use Malajusa/qwen3-1.7b-python-drawing with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Malajusa/qwen3-1.7b-python-drawing with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Malajusa/qwen3-1.7b-python-drawing") 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("Malajusa/qwen3-1.7b-python-drawing") model = AutoModelForCausalLM.from_pretrained("Malajusa/qwen3-1.7b-python-drawing", 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 Malajusa/qwen3-1.7b-python-drawing with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Malajusa/qwen3-1.7b-python-drawing" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Malajusa/qwen3-1.7b-python-drawing", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Malajusa/qwen3-1.7b-python-drawing
- SGLang
How to use Malajusa/qwen3-1.7b-python-drawing 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 "Malajusa/qwen3-1.7b-python-drawing" \ --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": "Malajusa/qwen3-1.7b-python-drawing", "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 "Malajusa/qwen3-1.7b-python-drawing" \ --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": "Malajusa/qwen3-1.7b-python-drawing", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Malajusa/qwen3-1.7b-python-drawing with Docker Model Runner:
docker model run hf.co/Malajusa/qwen3-1.7b-python-drawing
Download README.md from Malajusa/qwen3-1.7b-python-drawing: direct link, hf CLI and curl.
- Browser
- Download file 5.8 kB
-
https://huggingface.co/Malajusa/qwen3-1.7b-python-drawing/resolve/main/README.md
- Command line
-
hf download hf://Malajusa/qwen3-1.7b-python-drawing/README.md
-
curl -L -o README.md https://huggingface.co/Malajusa/qwen3-1.7b-python-drawing/resolve/main/README.md
base_model: Qwen/Qwen3-1.7B
datasets: Malajusa/qwen3-1.7b-python-drawing-sft
library_name: transformers
license: apache-2.0
pipeline_tag: text-generation
tags:
- ml-intern
- generated_from_trainer
- trl
- hf_jobs
- sft
- conversational
- python
- drawing
- svg
- matplotlib
- >-
trackio:https://Malajusa-qwen3-python-drawing-sft-trackio.hf.space?project=qwen3-python-drawing-sft&runs=Malajusa-1795610881&sidebar=collapsed
Qwen3-1.7B Python Drawing
Full-parameter supervised fine-tune of Qwen/Qwen3-1.7B for Python drawing and SVG code. The model generates matplotlib charts, Turtle and PIL drawings, SVG markup, and plotting-code explanations or fixes.
- Dataset: Malajusa/qwen3-1.7b-python-drawing-sft, 51,496 training rows and 300 held-out rows
- Final eval loss: 0.19746 on the fixed 32-row evaluation subset
- Final eval mean token accuracy: 0.94190 on the same subset
- Training: one epoch, 3,219 optimizer steps, approximately 1h54m on one A100 80 GB
- Dashboard: Trackio run
Quick start
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Malajusa/qwen3-1.7b-python-drawing"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id, dtype="bfloat16", device_map="auto"
)
messages = [
{
"role": "system",
"content": (
"You are an expert Python drawing assistant. You write correct, runnable "
"Python code for matplotlib charts, Turtle and PIL drawings, and clean SVG "
"markup. When asked about plotting code you explain or fix it precisely. "
"Always produce complete, self-contained code."
),
},
{
"role": "user",
"content": "Write PIL code that draws eight blue bars of increasing height and saves bars.png",
},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
with torch.inference_mode():
generated = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
answer = tokenizer.decode(
generated[0][inputs.input_ids.shape[1]:], skip_special_tokens=True
)
print(answer)
Review generated code before executing it. Long or intricate SVGs may require a larger generation budget than 1,024 tokens.
Training procedure
The run used TRL's conversational prompt-completion SFT format with completion-only loss. All model parameters were trainable. Key settings:
| Setting | Value |
|---|---|
| Maximum sequence length | 2,048 tokens |
| Per-device batch size | 8 |
| Gradient accumulation | 2 |
| Effective batch size | 16 |
| Learning rate | 1e-5, cosine schedule |
| Warmup | 100 steps |
| Epochs | 1 |
| Precision | BF16 |
| Activation checkpointing | Disabled after A100 memory smoke test |
| Peak GPU memory | 66.85 GiB allocated / 76.24 GiB reserved |
The reproducible training script is train_sft_a100.py.
Framework versions
- TRL 1.18.2
- Transformers 5.24.1
- PyTorch 2.15.0
- Datasets 5.2.0
- Accelerate 1.16.0
- Trackio 0.45.1
Held-out sanity check
Ten deterministic generations were sampled across chart code, SVG generation, SVG code, Turtle, and PIL tasks from the untouched 300-row held-out file. Nine stopped normally at an end-of-turn token. Eight produced nonblank renders.
- The synthetic heart, cloud, Turtle spiral/octagon, and PIL bar charts followed their requested parameters closely.
- A matplotlib PDF line plot rendered correctly.
- One flowchart was not rendered because its prompt-required external
data.jsonfixture was not supplied to the rendering subprocess. - One long title-card SVG reached the 1,024-token cap and was incomplete.
- A second complex SVG rendered, but omitted requested arrows and structural elements; a successful render is not evidence of full semantic correctness.
See the contact sheet, per-sample generations and status, and sanity-check script. This is a small qualitative sanity check, not a comprehensive drawing-quality benchmark.
Limitations
The model can produce incomplete, non-executing, or visually inaccurate code, especially for complex diagrams and long SVGs. External data files and plotting dependencies must be supplied by the caller. Evaluate on representative prompts and inspect rendered outputs before production use.