Arduino/Embedded Wiring & Code Assistant (Qwen2.5-Coder-7B LoRA)

A LoRA fine-tune of Qwen2.5-Coder-7B-Instruct, specialized for generating wiring instructions and working code for embedded/maker projects.

Given a plain-language request like "wire a BME280 to an ESP32 over I2C", it produces a wiring table, an ASCII wiring diagram, complete working code, and a short explanation — across Arduino C++, Raspberry Pi Python, MicroPython, and CircuitPython, on 7 boards (ESP32, Raspberry Pi, Raspberry Pi Pico, Arduino Uno, ESP8266, Teensy 4.0, M5Stack Core2).

Full training pipeline, dataset, and evaluation harness: GitHub repo

Benchmark (12-question held-out eval, deterministic decoding)

Metric This model (7B, 373 examples) Earlier 1.5B baseline (65 examples)
Format compliance 83% 58%
Runtime contamination-free 100% 83%
Code syntax valid ~100%* 92%
Speed (RTX 4070 8GB laptop) 12.0 tok/s 13.7 tok/s
Speed (data-center GPU) 73.2 tok/s

* Two apparent syntax failures were confirmed to be 900-token generation-cap truncation, not real errors.

"Runtime contamination" = wrong-framework API leaking into an answer (e.g. MicroPython's machine.Pin appearing in Arduino code, or Raspberry Pi's physical-pin numbering convention appearing in an ESP32 answer). Eliminating this was the primary goal of moving from the 1.5B to the 7B model plus a larger, validated dataset.

We also tested a LoRA rank-32 variant: no measurable quality improvement over rank-16 on any metric, so this release ships the more efficient rank-16 adapter.

⚠️ Known limitations

This is a v0.1 release trained on 373 examples — small by any standard. Manual testing (6 hand-picked questions, not from the eval set) found a clear, honest capability boundary:

Reliable (3/3 tested): straightforward single-component wiring closely resembling the training distribution — e.g. "wire a BME280 to an ESP32 over I2C," "read a DHT22 on a Raspberry Pi," "wire an SSD1306 OLED to an ESP32 in MicroPython." All three produced correct pins, correct libraries, and internally consistent answers.

Unreliable (0/3 tested): novel multi-component combinations and protocol-level troubleshooting outside the training distribution. Three distinct hallucination patterns were found:

  • Internal inconsistencies within one answer (a wiring diagram wire contradicting its own table)
  • A fabricated, non-functional low-level procedure for an I2C address conflict (invented register names/values presented with confidence)
  • An invented sensor capability not physically possible on the requested hardware (a "CO2 estimate" from a sensor that cannot measure CO2)

Always verify wiring against the actual component datasheet before connecting real hardware. Incorrect voltage or pin assignments can damage components. Treat outputs as a first draft, not a final instruction set.

Usage

from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    "unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit",
    max_seq_length=2048,
    load_in_4bit=True,
)
model.load_adapter("YOUR-USERNAME/arduino-embedded-qwen2.5-coder-7b")
FastLanguageModel.for_inference(model)

messages = [{"role": "user", "content": "How do I wire a BME280 to an ESP32 over I2C?"}]
inputs = tokenizer.apply_chat_template(
    messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
).to("cuda")
outputs = model.generate(input_ids=inputs, max_new_tokens=1300, do_sample=False)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))

Minimum hardware: ~6GB VRAM for inference (tested at 8GB on an RTX 4070 laptop). A 0.5B distilled variant for CPU/Raspberry Pi Zero 2W deployment is planned.

Training details

  • Base model: Qwen2.5-Coder-7B-Instruct (4-bit, via Unsloth)
  • Method: LoRA, rank 16, alpha 16, all attention + MLP projections
  • Dataset: 373 examples, synthetically generated and validated against an automated contamination checker before merging into training data
  • Epochs: 3

License

Apache 2.0, inherited from the base model. Free for commercial use, modification, and redistribution.

Citation / Acknowledgments

Built on Qwen2.5-Coder (Alibaba Qwen team) using Unsloth.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for EzioDevio/ArduinoLLM-7B