Skip to content

Add: SVG Business Chart Generation with Gemma 3 12B and Per-Type LoRA Adapters#345

Open
fxops-ai wants to merge 4 commits intogoogle-gemma:mainfrom
fxops-ai:main
Open

Add: SVG Business Chart Generation with Gemma 3 12B and Per-Type LoRA Adapters#345
fxops-ai wants to merge 4 commits intogoogle-gemma:mainfrom
fxops-ai:main

Conversation

@fxops-ai
Copy link
Copy Markdown

@fxops-ai fxops-ai commented Apr 3, 2026

Add: SVG Business Chart Generation with Gemma 3 12B + Per-Type LoRA Adapters

Summary

This notebook demonstrates a per-type LoRA adapter architecture for generating valid, renderable SVG business charts from structured JSON input using Gemma 3 12B on Apple Silicon (MLX). It covers 12 chart types — bar, line, area, pie, donut, funnel, scatter, bubble, grouped_bar, stacked_bar, waterfall, and horizontal_bar — each with a dedicated specialist adapter.

The notebook runs entirely on-device. No API calls required at inference time.


What This Demonstrates

1. Per-type LoRA adapter training on Apple Silicon
Each chart type is trained as a specialist adapter using mlx-lm on an M4 Mac mini (24GB). Adapters are published to HuggingFace at John-Williams-ATL/svg-chart-lora and load remotely via standard adapter_path syntax.

2. Geometry pre-computation as a prompt engineering strategy
Complex coordinate arithmetic (arc paths, running totals, scatter point positions) is pre-computed in Python and injected into the user prompt. The model handles SVG assembly; Python handles the math.

3. A 4-stage SVG validation and repair pipeline
Every generated output passes through GemmaChartValidator — extract → XML parse → coordinate bounds check → element-level repair.

4. Quantitative evaluation across 20 runs per type
The notebook includes an evaluation harness scoring pass rates per check across 20 runs — a distribution, not a single sample.


Adapter Pass Rates (v1.0, 20 runs @ temp=0.1)

Chart Type Pass Rate
area, bubble, donut, funnel, grouped_bar, line 100%
stacked_bar 95%
horizontal_bar 90%
pie 80%

Notebook Location

Gemma/Business-Intelligence/gemma3_svg_chart_generation_v2.2.ipynb


Related Resources

  • Adapters: John-Williams-ATL/svg-chart-lora (HuggingFace)
  • Training dataset: John-Williams-ATL/svg-chart-training-data (915 examples, 12 chart types)
  • Build narrative: Teaching a Small Model to Do One Thing Well (Substack, March 2026)

Pre-submission Checklist

  • Notebook runs top-to-bottom on Apple Silicon (M4, 24GB)
  • Adapter paths point to HuggingFace (John-Williams-ATL/svg-chart-lora/adapters_{type})
  • No local file paths or credentials exposed
  • Apache 2.0 license — compatible with Cookbook requirements
  • Copyright cell and license cell follow TF notebook template exactly
  • second_person, inclusive_language, not_translation, copyright, license lint checks all pass
  • button_colab and button_github — expected to pass after merge when path exists in google-gemma/cookbook

Hardware Note

Designed for Apple Silicon (MLX backend). A transformers + PeftModel fallback path is included for NVIDIA GPU environments.


Submitted by John Williams — fxops.ai / @fxopsAI

fxops-ai added 4 commits April 1, 2026 09:42
This README provides an overview of the Business Intelligence directory, detailing high-precision SVG generation and the included showcase and key innovations.
if you want to use local inference and download the model adaptors, uncomment the adapter_id for your local repo
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 3, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@fxops-ai
Copy link
Copy Markdown
Author

fxops-ai commented Apr 3, 2026

@googlebot I signed the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant