Transformers
Safetensors
English
PCB
EDA
KiCAD
Hardware-Design
Schematic-Generation
LLM
Circuit-Design
Instructions to use microsoft/SchGen with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/SchGen with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("microsoft/SchGen", dtype="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,58 +1,190 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
#
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
from transformers import pipeline
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
```
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
- Transformers: 4.55.4
|
| 39 |
-
- Pytorch: 2.8.0+cu128
|
| 40 |
-
- Datasets: 4.0.0
|
| 41 |
-
- Tokenizers: 0.21.4
|
| 42 |
|
| 43 |
-
|
| 44 |
|
|
|
|
| 45 |
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
```bibtex
|
| 50 |
-
@misc{vonwerra2022trl,
|
| 51 |
-
title = {{TRL: Transformer Reinforcement Learning}},
|
| 52 |
-
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
|
| 53 |
-
year = 2020,
|
| 54 |
-
journal = {GitHub repository},
|
| 55 |
-
publisher = {GitHub},
|
| 56 |
-
howpublished = {\url{https://github.com/huggingface/trl}}
|
| 57 |
-
}
|
| 58 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
|
| 5 |
+
license: mit
|
| 6 |
+
|
| 7 |
tags:
|
| 8 |
+
- PCB
|
| 9 |
+
- EDA
|
| 10 |
+
- KiCAD
|
| 11 |
+
- Hardware-Design
|
| 12 |
+
- Schematic-Generation
|
| 13 |
+
- LLM
|
| 14 |
+
- Circuit-Design
|
| 15 |
+
|
| 16 |
+
library_name: transformers
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# SchGen
|
| 20 |
|
| 21 |
+
[]()
|
| 22 |
+
[]()
|
| 23 |
|
| 24 |
+
**SchGen** is a large language model for **PCB schematic generation from natural-language requests**.
|
| 25 |
+
|
| 26 |
+
The model is supervised fine-tuned from **GPT-OSS-20B** using a custom dataset of approximately **8K paired user requests and schematic-generation code samples**.
|
| 27 |
+
SchGen generates executable Python code that can be rendered into **KiCad schematic designs** using customized schematic APIs.
|
| 28 |
+
|
| 29 |
+
➡️ **Base Model:** GPT-OSS-20B
|
| 30 |
+
➡️ **License:** MIT
|
| 31 |
+
➡️ **Framework:** Transformers
|
| 32 |
+
➡️ **Context Length:** 13,312 tokens
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
|
| 36 |
+
## Overview
|
|
|
|
| 37 |
|
| 38 |
+
Printed circuit board (PCB) design is a critical but expertise-intensive process in embedded systems, IoT, robotics, and AI hardware.
|
| 39 |
+
|
| 40 |
+
SchGen explores whether large language models can assist hardware design by generating schematic construction code directly from natural-language descriptions.
|
| 41 |
+
|
| 42 |
+
The input is a user request describing a circuit design requirement, and the output is executable Python code that can generate a KiCad schematic using custom APIs.
|
| 43 |
+
|
| 44 |
+
Example input:
|
| 45 |
+
|
| 46 |
+
```text
|
| 47 |
+
I want a 1.8V regulated supply from VIN using an AP2112K LDO,
|
| 48 |
+
with a test point on the 1.8V rail and a solder-jumper-selectable LED indicator.
|
| 49 |
```
|
| 50 |
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## 🔥 Key Features
|
| 54 |
+
|
| 55 |
+
- 🔌 **Natural Language to Schematic Code**
|
| 56 |
+
Generates executable Python schematic-generation code directly from user requests.
|
| 57 |
+
|
| 58 |
+
- 🧠 **KiCad-Oriented Design Flow**
|
| 59 |
+
Designed around custom Code-to-Schematic APIs for KiCad schematic construction.
|
| 60 |
+
|
| 61 |
+
- 📐 **Structured Hardware Generation**
|
| 62 |
+
Produces editable and programmatic schematic representations instead of images.
|
| 63 |
+
|
| 64 |
+
- 🛠️ **Research-Focused PCB Generation**
|
| 65 |
+
Intended for experimentation, benchmarking, and AI-assisted hardware prototyping.
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## Model Details
|
| 70 |
+
|
| 71 |
+
| Item | Value |
|
| 72 |
+
|---|---|
|
| 73 |
+
| Base Model | GPT-OSS-20B |
|
| 74 |
+
| Parameters | 20B |
|
| 75 |
+
| Architecture | Supervised Fine-Tuned LLM |
|
| 76 |
+
| Input | Natural-language design requests |
|
| 77 |
+
| Output | Python schematic-generation code |
|
| 78 |
+
| Context Length | 13,312 |
|
| 79 |
+
| Training Hardware | 1× NVIDIA A100 |
|
| 80 |
+
| Training Time | ~21 hours |
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
## Usage
|
| 85 |
+
|
| 86 |
+
The recommended workflow is:
|
| 87 |
+
|
| 88 |
+
1. Provide a natural-language circuit request
|
| 89 |
+
2. Generate Python schematic-construction code
|
| 90 |
+
3. Execute the code to render a KiCad schematic
|
| 91 |
+
4. Verify outputs using ERC/DRC tools
|
| 92 |
+
|
| 93 |
+
The model is designed for integration into:
|
| 94 |
+
|
| 95 |
+
- EDA automation pipelines
|
| 96 |
+
- Hardware engineering copilots
|
| 97 |
+
- Synthetic schematic generation systems
|
| 98 |
+
- Research workflows for AI-assisted PCB design
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## Evaluation
|
| 103 |
|
| 104 |
+
SchGen was evaluated using several schematic-generation metrics:
|
| 105 |
|
| 106 |
+
- **Valid Circuits**
|
| 107 |
+
Measures whether generated code executes successfully and produces valid schematics.
|
| 108 |
|
| 109 |
+
- **Spatial Violation**
|
| 110 |
+
Measures overlaps among symbols, labels, and wires.
|
| 111 |
|
| 112 |
+
- **Netlist Accuracy**
|
| 113 |
+
Measures connectivity correctness against ground-truth netlists.
|
| 114 |
+
|
| 115 |
+
SchGen outperforms several frontier LLM baselines on schematic generation tasks when all models are provided with the same schematic-generation APIs.
|
| 116 |
+
|
| 117 |
+
---
|
| 118 |
+
|
| 119 |
+
## Limitations
|
| 120 |
+
|
| 121 |
+
SchGen is an early-stage research system and currently focuses on:
|
| 122 |
+
|
| 123 |
+
- small and medium-scale schematic modules
|
| 124 |
+
- hobbyist and open-source hardware designs
|
| 125 |
+
- English-language requests
|
| 126 |
+
|
| 127 |
+
The model may underperform on:
|
| 128 |
+
|
| 129 |
+
- RF or high-frequency circuits
|
| 130 |
+
- industrial or enterprise hardware
|
| 131 |
+
- large multi-board systems
|
| 132 |
+
- safety-critical applications
|
| 133 |
+
|
| 134 |
+
Generated outputs should always undergo:
|
| 135 |
+
|
| 136 |
+
- Electrical Rule Checking (ERC)
|
| 137 |
+
- Design Rule Checking (DRC)
|
| 138 |
+
- human engineering review
|
| 139 |
+
|
| 140 |
+
SchGen is intended as an assistive tool rather than a fully autonomous hardware engineer.
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## Technical Requirements
|
| 145 |
+
|
| 146 |
+
The model generates executable Python code and requires:
|
| 147 |
+
|
| 148 |
+
- Python environment
|
| 149 |
+
- KiCad installation
|
| 150 |
+
- Custom schematic-generation APIs
|
| 151 |
+
|
| 152 |
+
Inference was validated on:
|
| 153 |
+
|
| 154 |
+
- NVIDIA A100 GPUs
|
| 155 |
+
- 4-bit quantized configurations
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## Dataset
|
| 160 |
+
|
| 161 |
+
SchGen was trained on a custom dataset of approximately 8K pairs of:
|
| 162 |
+
|
| 163 |
+
- natural-language hardware requests
|
| 164 |
+
- Python schematic-generation code
|
| 165 |
+
|
| 166 |
+
The dataset was synthesized through:
|
| 167 |
+
|
| 168 |
+
1. GPT-generated draft schematics
|
| 169 |
+
2. Human correction and annotation
|
| 170 |
+
3. LLM-generated user requests
|
| 171 |
+
|
| 172 |
+
The dataset is available at `https://huggingface.co/datasets/microsoft/SchGen_dataset`
|
| 173 |
+
|
| 174 |
+
---
|
| 175 |
+
|
| 176 |
+
## License
|
| 177 |
+
|
| 178 |
+
This project is licensed under the MIT License.
|
| 179 |
+
|
| 180 |
+
---
|
| 181 |
|
| 182 |
+
## Contact
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
+
This project was conducted by members of Microsoft Research.
|
| 185 |
|
| 186 |
+
For questions, feedback, or collaboration inquiries:
|
| 187 |
|
| 188 |
+
- ruichunma@microsoft.com
|
| 189 |
|
| 190 |
+
If issues or problematic behavior are identified, the repository may be updated with appropriate mitigations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|