Downloads · 30 days
76
25% of all-time downloads
CanadaDiver/KiCad-Gemma4-E2B-v2
KiCad-Gemma4-E2B-v2 is a text generation model from CanadaDiver. Use it when you need the model to write or continue text. The card lists the license as cc-by-nc-nd-4.0.
A KiCad EDA specialist — fine-tuned from google/gemma-4-E2B-it to generate .kicadsch schematics, write KiCad Python scripts, select components, and explain PCB design decisions.
Downloads · 30 days
76
25% of all-time downloads
All-time downloads
301
Public
Repo size
5 GB
Likes
1
Public
Click a slice to open those files.
.gguf5 GB · 100%
From the Hugging Face model README
A KiCad EDA specialist — fine-tuned from google/gemma-4-E2B-it to generate .kicad_sch schematics, write KiCad Python scripts, select components, and explain PCB design decisions.
Fine-tuned weights: CC BY-NC-ND 4.0
CanadaDiver/KiCad-Gemma4-E2B-v2.Base model weights: Apache 2.0 (Google Gemma 4). Both licenses apply.
Commercial licensing: Contact the repository owner for a separate commercial license if you intend to build a product with this model.
| Property | Value |
|---|---|
| Base model | google/gemma-4-E2B-it |
| Architecture | Gemma 4 E2B — 35 layers, 1.536B effective parameters |
| Attention | Sliding window (256 dim) + global (512 dim), every 5th layer global |
| FFN | Double-wide MLP on global layers (12,288 vs 6,144 for SWA layers) |
| Fine-tuning method | QLoRA via Unsloth |
| LoRA rank / alpha | r=64, α=128, rank-stabilized (rsLoRA) |
| LoRA target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj, embed_tokens, lm_head |
| Context length | 131,072 tokens |
| GGUF quantization | Q8_0 |
| Training hardware | NVIDIA GeForce RTX 5080 |
Designed for electronics engineers and hobbyists working with KiCad EDA:
.kicad_sch schematic files from natural language descriptionsgemma-4-E2B-it for that)The model was trained on kicad_agent_final.jsonl — 366 instruction/output pairs assembled from the following sources:
~93 samples derived from open-source .kicad_sch and .kicad_sym files published by Seeed Studio.
Boards represented:
License: CC BY-SA 4.0 Source: github.com/Seeed-Studio/OPL_Kicad_Library
These schematics were converted into instruction→output training pairs (schematic generation, section understanding, component reference lookup) using Gemma 4 E4B-it running locally.
~273 samples generated using Gemma 4 E4B-it (via LM Studio) as a teacher model, covering:
| Type | Count | Description |
|---|---|---|
tool_call_script | 234 | KiCad Python API: generate/modify schematics programmatically |
tool_call_repair | 32 | Debugging and fixing broken KiCad scripts |
sch_generation | 21 | Full schematic generation from circuit description |
sch_section | 40 | Section-level schematic understanding |
Circuit topics covered: passive filters, power supplies (LDO, buck, boost, LiPo charging), microcontroller minimal systems (ESP32, STM32, ATmega, RP2040, nRF52840), digital interfaces (SPI, I2C, UART, USB, CAN, RS-485), analog circuits (op-amps, comparators, ADC/DAC), sensor interfaces, and protection circuits.
Total training samples : 366
Real schematic pairs : 93 (25%) — Seeed OPL CC BY-SA 4.0
Synthetic pairs : 273 (75%) — generated via Gemma 4 E4B-it
Framework : Unsloth + PEFT 0.18.1 + HuggingFace Transformers
Base model : unsloth/gemma-4-E2B-it-unsloth-bnb-4bit (4-bit NF4 for training)
Method : QLoRA (quantized LoRA)
LoRA config:
r = 64
lora_alpha = 128
use_rslora = True (rank-stabilized LoRA)
lora_dropout = 0
use_dora = False
target_modules = q_proj, k_proj, v_proj, o_proj,
gate_proj, up_proj, down_proj,
embed_tokens, lm_head
Training:
Hardware = NVIDIA GeForce RTX 5080 (16 GB)
Sequence length = 4096 tokens max
Train/eval split = 95/5
Framework = SFTTrainer (TRL)
After training, LoRA adapters were merged into the base model weights at bf16 precision and exported to GGUF Q8_0 format via a patched convert_hf_to_gguf.py.
Gemma 4 E2B uses a shared-KV mechanism where layers 15–34 reuse the key/value projections from layers 13 (SWA) and 14 (global). Standard GGUF converters omit these tensors via PyTorch parameter deduplication.
The GGUF file in this repo includes explicit copies of the shared KV tensors for all 35 layers (SWA layers → blk.13 weights, global layers → blk.14 weights), ensuring compatibility with all llama.cpp-based runtimes including LM Studio and Ollama.
Pair this model with the companion mcp-kicad-sch-api MCP server to give it live read/write access to real .kicad_sch files. The model generates schematic intent; the MCP server executes it against an actual KiCad file on disk.
pip install mcp-kicad-sch-api
Requires Python 3.10+ and KiCad installed (for symbol libraries).
Add to %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"kicad-sch-api": {
"command": "python",
"args": ["-m", "mcp_kicad_sch_api"],
"env": {}
}
}
}
A ready-to-use config file is included in this repo as mcp_config_claude_desktop.json.
claude mcp add kicad-sch -- python -m mcp_kicad_sch_api
| Tool | Description |
|---|---|
create_schematic | Create a new .kicad_sch file |
load_schematic | Load an existing schematic from disk |
save_schematic | Save the current schematic to disk |
add_component | Place a component (lib_id, reference, value, position, footprint) |
search_components | Search KiCad symbol libraries by keyword |
add_wire | Draw a wire between two coordinates |
add_label | Add a net label at a position |
add_hierarchical_label | Add a hierarchical interface label |
add_junction | Add a junction dot at a wire crossing |
list_components | List all components in the open schematic |
get_schematic_info | Get component count, wire count, and file info |
get_component_pin_position | Get the absolute XY position of a specific pin |
add_label_to_pin | Attach a net label directly to a component pin |
connect_pins_with_labels | Connect two pins via a shared net name |
list_component_pins | List all pins for a component with their positions |
remove_component | Remove a component by reference |
remove_wire | Remove a wire by UUID |
With the MCP server running alongside this model in Claude Desktop or Claude Code:
"Create a 3.3 V LDO regulator schematic using the LP2985. Add input and output bypass caps. Save it as
ldo_3v3.kicad_sch."
The model will call create_schematic, add_component (×3), add_wire (multiple), add_label, and save_schematic in sequence — producing a valid KiCad 8 schematic file without manual placement.
KiCad-Gemma4-E2B-v2-Q8_0.gguf.lmstudio/models/CanadaDiver/KiCad-Gemma4-E2B-v2/KiCad-Gemma4-E2B-v2-Q8_0.ggufllama-server -m KiCad-Gemma4-E2B-v2-Q8_0.gguf --port 8080 -c 8192
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "CanadaDiver/KiCad-Gemma4-E2B-v2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
messages = [{"role": "user", "content": "Write a KiCad schematic for a 3.3V LDO using LP2985."}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=1024, temperature=1.0, top_k=64, top_p=0.95)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
| Contributor | Contribution | License |
|---|---|---|
| Google DeepMind | Gemma 4 E2B base model | Apache 2.0 |
| Unsloth | QLoRA fine-tuning framework, 4-bit base | Apache 2.0 |
| Seeed Studio | OPL KiCad Library — real schematic training data | CC BY-SA 4.0 |
| KiCad EDA | KiCad documentation and file format reference | GPL |
| HuggingFace | Transformers, PEFT, TRL training stack | Apache 2.0 |
Synthetic training pairs were generated using Gemma 4 E4B-it running locally via LM Studio.
@misc{kicad-gemma4-e2b-v2,
author = {CanadaDiver},
title = {KiCad-Gemma4-E2B-v2: A KiCad EDA specialist fine-tuned from Gemma 4 E2B},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/CanadaDiver/KiCad-Gemma4-E2B-v2}
}