Skip to content
ModelVerifiedExternal
Download

Qwen3 4b Skidl

A fine-tune of Qwen/Qwen3-4B for generating executable SKiDL Python netlists from natural-language circuit descriptions. Given a description like "ESP32 board with BME280 on I2C and USB-C", the model outputs valid...

KindLoRABase modelQwen/Qwen3-4BVersionRevision 69f2dbfPublisher@AbijahKajCgrade

Model source

Kind
LoRA
File size
504 MB–7.49 GB
Base model
Qwen/Qwen3-4B
Version
vRevision 69f2dbf
Updated
Oct 2, 2026
Publisher
@AbijahKaj
Downloads
241
Parameters
4B
Tasks
Text generation
Source
Hugging Face

Source description

qwen3-4b-skidl

A fine-tune of Qwen/Qwen3-4B for generating executable SKiDL Python netlists from natural-language circuit descriptions. Given a description like "ESP32 board with BME280 on I2C and USB-C", the model outputs valid Python using Part(), Net(), and generate_netlist() — producing a .net file KiCad can open directly.

Blog post: Teaching a Small LLM to Design Electronic Circuits: Fine-Tuning Qwen3-4B on 100K KiCad Netlists

This repo has two branches:

BranchContentsSizeUse
main (this)Merged weights — LoRA baked into base7.5 GBLoad directly, no base model needed
loraAdapter only504 MBLightweight; load on top of Qwen3-4B

Quick start

Merged (main branch — recommended)

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(
    "AbijahKaj/qwen3-4b-skidl",
    dtype="auto",
    device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("AbijahKaj/qwen3-4b-skidl")

LoRA adapter (lora branch)

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B", dtype="auto", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("AbijahKaj/qwen3-4b-skidl", revision="lora")
model = PeftModel.from_pretrained(base, "AbijahKaj/qwen3-4b-skidl", revision="lora")

Generating a circuit

SYSTEM = (
    "You are an expert electronics engineer and KiCad schematic designer. "
    "When given a description of an electronic circuit, generate executable "
    "SKiDL Python code that defines the circuit using the SKiDL library."
)

messages = [
    {"role": "system", "content": SYSTEM},
    {"role": "user", "content": "Design a CAN bus interface using MCP2515 controller and TJA1050 transceiver on SPI, with 120 ohm termination resistor."},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))

Training

Base modelQwen/Qwen3-4B
MethodSFT + LoRA
DatasetAbijahKaj/kicad-netlist-sft-dataset — 100,179 SKiDL Python circuit examples
LoRA rank / alphar=64, α=32, dropout=0.05
Target modulesq/k/v/o_proj, gate/up/down_proj
Epochs2
Peak LR2e-4 (cosine decay)
Effective batch8
Max length8192 tokens
Trainable params~132M (5.65% of 4B)

Loss curve

PhaseTrain lossToken accuracy
Start0.8675%
Epoch 1 end0.1795%
Epoch 2 end0.1595–96%
Eval loss (final)0.158195.3%

SKiDL validation (final checkpoint)

Functional scoring across 5 held-out circuits: Python syntax + SKiDL import + net count + part count + connectivity + GND checks.

CircuitScore
LED blink — ATtiny850.85
USB power meter — ATmega328P + INA2190.85
CAN bus — MCP2515 + TJA10500.95
Average0.883

Why SKiDL?

KiCad's native s-expression netlist is deeply nested and pathological for LLMs. PCBSchemaGen (arXiv:2602.00510) shows SKiDL Python achieves 87% Pass@1 with GPT-4o on circuit generation — because Python-based HDLs align with LLM pretraining data and are 3× more compact than s-expressions.

Dataset

AbijahKaj/kicad-netlist-sft-dataset — 100,179 ChatML examples:

SourceCount
Si7li/ltspice-spice-circuits (LTspice → SKiDL)~54,000
bshada/open-schematics (GitHub .kicad_sch files)~45,000
Ashed00/SPICE-Circuits~800
Synthetic + tool-augmented~308

References

Sources

1 source
Hugging FacePrimaryVersion 69f2dbf9a19e7ea4fa644a63dc2a47d7dc3333b4
huggingface.co/AbijahKaj/qwen3-4b-skidl/tree/69f2dbf9a19e7ea4fa644a63dc2a47d7dc3333b4

Verified Oct 2

Model artifacts

2 artifacts

adapter_model.safetensors

safetensors · 504 MB · SHA-256 a0637084e1bb…d07a · Hugging Face

Download

model.safetensors

safetensors · 7.49 GB · SHA-256 c77f66aa0d40…abb2 · Hugging Face

Download

Source excerpts

3 excerpts

--- base_model: Qwen/Qwen3-4B datasets: - AbijahKaj/kicad-netlist-sft-dataset language: - en license: apache-2.0 library_name: transformers tags: - electronics - kicad - netlist - schematic - eda - circuit-design - skidl - pcb - trl - sft - peft - lora --- # qwen3-4b-skidl A fine-tune of [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) for generating **executable SKiDL Python netlists** from natural-language circuit descriptions. Given a description like *"ESP32 board with BME280 on I2C and USB-C"*, the model outputs valid Python using `Part()`, `Net()`, and `generate_netlist()` — producing a `.net` file KiCad can open directly. **Blog post:** [Teaching a Small LLM to Design Electronic Circuits: Fine-Tuning Qwen3-4B on 100K KiCad Netlists](https://blog.abijah.me/teaching-a-small-llm-to-design-electronic-circuits-fine-tuning-qwen3-4b-on-100k-kicad-netlists) This repo has two branches: | Branch | Contents | Size | Use | |---|---|---|---| | **`main`** (this) | Merged weights — LoRA baked into base | 7.5 GB | Load directly, no base model needed | | [`lora`](https://huggingface.co/AbijahKaj/qwen3-4b-skidl/tree/lora) | Adapter only | 504 MB | Lightweight; load on top of Qwen3-4B | ## Quick start ### Merged (main branch — recommended) ```python from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained( "AbijahKaj/qwen3-4b-skidl", dtype="auto", device_map="auto", ) tokenizer = AutoTokenizer.from_pretrained("AbijahKaj/qwen3-4b-skidl") ``` ### LoRA adapter (lora branch) ```python from transformers import AutoModelForCausalLM, AutoTokenizer from peft import PeftModel base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B", dtype="auto", device_map="auto") tokenizer = AutoTokenizer.from_pretrained("AbijahKaj/qwen3-4b-skidl", revision="lora") model = PeftModel.from_pretrained(base, "AbijahKaj/qwen3-4b-skidl", revision="lora") ``` ### Generating a circuit ```python SYSTEM = ( "You are an expert electronics engineer and KiCad schematic designer. " "When given a description of an electronic circuit, generate executable " "SKiDL Python code that defines the circuit using the SKiDL library." ) messages = [ {"role": "system", "content": SYSTEM}, {"role": "user", "content": "Design a CAN bus interface using MCP2515 controller and TJA1050 transceiver on SPI, with 120 ohm termination resistor."}, ]...

--- base_model: Qwen/Qwen3-4B datasets: - AbijahKaj/kicad-netlist-sft-dataset language: - en license: apache-2.0 library_name: transformers tags: - electronics - kicad - netlist - schematic - eda - circuit-design - skidl - pcb - trl - sft - peft - lora --- # qwen3-4b-skidl A fine-tune of [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) for generating **executable SKiDL Python netlists** from natural-language circuit descriptions. Given a description like *"ESP32 board with BME280 on I2C and USB-C"*, the model outputs valid Python using `Part()`, `Net()`, and `generate_netlist()` — producing a `.net` file KiCad can open directly. This repo has two branches: | Branch | Contents | Size | Use | |---|---|---|---| | **`main`** (this) | Merged weights — LoRA baked into base | 7.5 GB | Load directly, no base model needed | | [`lora`](https://huggingface.co/AbijahKaj/qwen3-4b-skidl/tree/lora) | Adapter only | 504 MB | Lightweight; load on top of Qwen3-4B | ## Quick start ### Merged (main branch — recommended) ```python from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained( "AbijahKaj/qwen3-4b-skidl", dtype="auto", device_map="auto", ) tokenizer = AutoTokenizer.from_pretrained("AbijahKaj/qwen3-4b-skidl") ``` ### LoRA adapter (lora branch) ```python from transformers import AutoModelForCausalLM, AutoTokenizer from peft import PeftModel base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B", dtype="auto", device_map="auto") tokenizer = AutoTokenizer.from_pretrained("AbijahKaj/qwen3-4b-skidl", revision="lora") model = PeftModel.from_pretrained(base, "AbijahKaj/qwen3-4b-skidl", revision="lora") ``` ### Generating a circuit ```python SYSTEM = ( "You are an expert electronics engineer and KiCad schematic designer. " "When given a description of an electronic circuit, generate executable " "SKiDL Python code that defines the circuit using the SKiDL library." ) messages = [ {"role": "system", "content": SYSTEM}, {"role": "user", "content": "Design a CAN bus interface using MCP2515 controller and TJA1050 transceiver on SPI, with 120 ohm termination resistor."}, ] text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) inputs = tokenizer(text, return_tensors="pt").to(model.device) out = model.generate(**inputs, max_new_tokens=1024, do_sample=False) print(tok...

Source context: 241 downloads · 1 likes · Pipeline text-generation · Library transformers · Repo AbijahKaj/qwen3-4b-skidl