Train a tiny model to generate 3D files (v2) through example diversification

Cadmonkey


Background

Hi, I’m Thomas, a Mechanical/Robotics Engineer turned Software & ML.

Engineer

This is an experiment to create 3D models using a Small Language Model.

Armed with GPU credits from CloudRift & Prime Intellect + the generous free usage of Huggingface, I set out to build a language model to generate 3d files - CADMonkey.

Dataset snippet


1. Model architecture & 3d Programming Language

At Starmind, we need our models to be small enough to run on Raspberry Pi 4 & 5. The base Language Model of choice is Gemma3-1B for the following reasons:

Gemma3

We also briefly considered a diffusion model, but the development complexity is too large. Perhaps we will revisit this idea another day.

The model will generate OPENSCAD code that will be used to render 3D models.

ide

Why OpenSCAD? As a Mechanical Engineer, I find that traditional Voxel & Mesh-based 3D models to bring little to no value. Engineering requires constant revisions and iterations, and shape-based and code-based models are ideal for that.


2. Dataset generation

Your model is only as good as its dataset. But the definiton of “good” is relative to the task at hand.

Here are the attempts we made at creating a dataset:

#1: There are 7,000 rows worth of open-source OpenSCAD dataset, scrapped from Thingiverse on Huggingface (redcathode/thingiverse-openscad). However, we have a few issues with this:

gear

#2: Synthetic data generation is the method we chose to go with.

The result is the following dataset: https://kdataset.web.app

This is the first synthetically generated & reviewed OpenSCAD dataset of large quantity on the internet: ThomasTheMaker/Synthetic-Object-v3 (35k rows of verified data).

dataset

This would not be possible without the grants provided by CloudRift. Thanks a bunch!

After fine-tuning the model on the dataset, we found that:

v1

As the matter of fact, only 1/400 models matched the object. See below for the only good object created - the duck:

duck

#3: Scaling dataset horizontally

We tried scaling up with a dataset with more objects, but the same issue of non-matching objects persisted.

#4: Scaling up dataset vertically

Model performance only truly improved when we scaled up the dataset vertically:

You can see the improvement below:

cat dog chicken universe


3. Mistakes we made along the way

There are many things we tried that did not work, and we hope it helps you avoid wasting time & efforts:


4. Training

With the dataset ready, we fine-tuned Gemma3 1B model on the datasets with the following prompt:

‘hey cadmonkey, make me a {object name}’

This was done using Unsloth 4-bit finetuning. unsloth

The output model is converted into a GGUF model with q8 quantization.

Everything is available here: https://hf.co/collections/ThomasTheMaker/cadmonkey


6. Make it available to the world!

I’m using Modal to host the model. Since the model is small, it can run very fine even on CPU, Raspberry Pis, etc.

For speed optimization, I’m using T4 GPU on Modal, giving some awesome output speed. Although only 8% of GPU is utilized.

On average, each prompt costs 2 cents to run.

Try out the app at https://cadmonkey.web.app

app


6. The takeaway

I know it’s cliche, but you can just make things!

5 years ago, it would cost me 5 figures and a team of 20 scientists to achieve this.

Now, I ran the whole experiments over 3 weekends, using 500$ in credits from various sources.

Up until now, my knowledge about Language Model was 1-year of obsessive self-taught.

You really can just do things. You just have to be crazy enough to start.


The dataset & model files:

The datasets used in this experiments are named “Synthetic-Openscad-v**”

Dataset generation & training code:

Awesome compute sponsors (:

If you have any questions, ask me here: https://discord.gg/XT23RZ5U6R