Gemma3-2B-CAITI-ACR-v1 (Agentic Component Recognition or Automated Component Reasoning) is a fine-tuned version of Google's Gemma 3 2B model optimized for visualization component selection, reasoning, and code generation in generative UI applications. This model specializes in translating natural language requests into appropriate visualization components using Recharts, D3, and Tremor libraries.
Model Details
Model Description
This model serves as a specialized reasoning and code generation system for dynamic visualization component selection in generative UI applications. It bridges the gap between natural language requests and the most appropriate visualization implementation, enabling applications to dynamically render UI components based on user intent without predefined navigation paths.
Developed by: Noble Ackerson (@stigsfoot)
Funded by: Self-funded
Shared by: Noble Ackerson (@stigsfoot)
Model type: Causal language model fine-tuned for visualization component reasoning
Select appropriate visualization components based on natural language requests
Generate React component code using Recharts, D3, or Tremor
Provide reasoning about visualization choices
Power generative UI applications with dynamic component rendering
The model accepts natural language queries about data visualization and outputs both component selection reasoning and the corresponding React component code.
Downstream Use
The model can be integrated into:
Smart home dashboards and monitoring applications
Business intelligence tools requiring conversational interfaces
Creating visualizations that intentionally misrepresent data
Generating full application frameworks beyond individual visualization components
Non-English language requests
Creating visualizations for libraries not included in training (primarily limited to Recharts, D3, and Tremor)
Bias, Risks, and Limitations
The model performs best on visualization types present in the training data
May have difficulty with highly specialized or complex visualizations
Limited to the component libraries it was trained on
Not designed for general code generation outside visualization contexts
Not optimized for multilingual requests
May occasionally generate code with syntax errors or suboptimal performance
Visualization choices may reflect biases present in training data regarding "best" visualization types
Recommendations
Users should:
Review generated code for accuracy and performance issues before implementation
Consider accessibility implications of generated visualizations
Ensure appropriate fallbacks for users with different abilities
Be aware that the model might make questionable visualization choices for certain data types
Deploy the model with proper monitoring to catch potential issues
Use model outputs as suggestions rather than definitive implementations for critical applications
How to Get Started with the Model
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
34# Load model and tokenizer5model_name ="stigsfoot/gemma3-2b-caiti-acr-v1"6tokenizer = AutoTokenizer.from_pretrained(model_name)7model = AutoModelForCausalLM.from_pretrained(8 model_name,9 torch_dtype=torch.float16,10 device_map="auto"11)1213# Prepare input with visualization request14prompt ="""
15[INST] Given the following user request, select the most appropriate visualization component and explain your reasoning:
1617User request: "Show me a breakdown of energy usage by device for the last month"
1819Available components:
20- BarChart
21- PieChart
22- LineChart
23- TreeMap
24- HeatMap
25[/INST]
26"""2728# Generate response29inputs = tokenizer(prompt, return_tensors="pt").to(model.device)30outputs = model.generate(31 inputs.input_ids,32 max_new_tokens=512,33 temperature=0.1,34 do_sample=True35)36response = tokenizer.decode(outputs[0], skip_special_tokens=True)37print(response)
For integration with the CAITI framework:
javascript
1import{ streamUI }from"ai/rsc";2import{ generateFromFinetuned }from"./gemma-client";34// Inside your AI stream handler5asyncfunction*generateComponent({ content, done }){6// Use fine-tuned model instead of OpenAI7const componentCode =awaitgenerateFromFinetuned({8prompt:`Select visualization for: ${userRequest}`,9model:"stigsfoot/gemma3-2b-caiti-acr-v1"10});1112// Render component with the generated code13return<DynamicComponent code={componentCode}/>;14}
Training Details
Training Data
The model was fine-tuned on a specialized dataset consisting of:
Natural language requests paired with corresponding visualization component selections
React component code samples using Recharts, D3, and Tremor
Diverse visualization scenarios covering different chart types and data structures
The dataset included approximately 1,000 examples spanning various visualization types, data structures, and user intents.
Training Procedure
Preprocessing
Training examples were formatted as instruction-response pairs with a consistent structure:
User instruction containing a visualization request
Reasoning about the optimal component selection
Code implementation of the selected component
Training Hyperparameters
Training regime: bf16 mixed precision
Number of epochs: 3
Learning rate: 2e-5
Batch size: 8
Weight decay: 0.01
Fine-tuning method: QLoRA with 4-bit quantization
LoRA rank: 64
LoRA alpha: 16
LoRA dropout: 0.05
Speeds, Sizes, Times
Training time: ~4 hours
Hardware used: A100 GPU
Checkpoint size: ~2.5GB
VRAM requirements during training: ~16GB
Evaluation
Testing Data, Factors & Metrics
Testing Data
A held-out test set of 100 novel visualization requests not seen during training, representing diverse user intents and visualization requirements.
Factors
The evaluation disaggregated results by:
Visualization type (bar, pie, line, etc.)
Data complexity (number of dimensions, time series vs. categorical)
Request specificity (explicit vs. implicit visualization requests)
Component library (Recharts, D3, Tremor)
Metrics
Component Selection Accuracy: Percentage of cases where the model selected the most appropriate visualization type
Code Syntax Correctness: Percentage of generated code that parsed without errors
Rendering Success: Percentage of components that successfully rendered
Inference Latency: Time from request to response
Memory Usage: RAM required during inference
Results
Summary
Metric
Score
Component Selection Accuracy
92.5%
Code Syntax Correctness
94.3%
Rendering Success
89.7%
Inference Latency (avg)
150ms
Memory Usage
5GB
The model performed best on bar charts, pie charts, and line charts (>95% accuracy), with moderately lower accuracy on more complex visualizations like heatmaps and treemaps (~85% accuracy).
ACR (Automated Component Reasoning): The model's ability to automatically select and generate appropriate visualization components based on user intent
CAITI (Contextual AI Translated Insights): The generative UI framework the model is designed to enhance
Recharts: A React charting library used in the training data
D3 (Data-Driven Documents): A JavaScript library for producing dynamic, interactive data visualizations
Tremor: A React library for building dashboards and data visualizations
QLoRA (Quantized Low-Rank Adaptation): The parameter-efficient fine-tuning method used
Generative UI: User interfaces that are dynamically generated based on user intent rather than pre-defined layouts
Model Card Authors
Noble Ackerson (@stigsfoot)
Model Card Contact
Please create an issue in the model repository for questions or feedback.