Run this model with HF Jobs

Run sazid63/gemma-4-e4b-archspec-lora on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/sazid63/gemma-4-e4b-archspec-lora. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/sazid63/gemma-4-e4b-archspec-lora on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/sazid63/gemma-4-e4b-archspec-lora. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/sazid63/gemma-4-e4b-archspec-lora. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

Gemma-4-E4B ArchSpec LoRA (text → 3D apartment spec)

A QLoRA adapter for google/gemma-4-e4b-it fine-tuned to turn a plain-language apartment brief into archspec-1 JSON — a machine-readable building spec (storeys, rooms with metric x/y/w/d + area_m2, doors, windows, summary counts) that feeds an ArchSpec 3D compiler to produce 3D apartment geometry (OBJ).

Intended use & limitations

  • Intended: generating buildable, non-overlapping residential apartment/floor-plan specs (studio flats and small multi-room apartments) from short English briefs, for CAD / 3D-mesh downstream compilation.
  • Out of scope: structural engineering, load-bearing/MEP design, code compliance, commercial buildings, photorealistic rendering. Output is a geometric spec, not a stamped drawing — verify dimensions before real construction use.
  • Trained only on studio/small-apartment briefs; larger or unusual programs (e.g. 10+ rooms, irregular plots) are extrapolation and may degrade.

Training details

Base model google/gemma-4-e4b-it (language-model LoRA only — no image input)
Method QLoRA: 4-bit NF4 base (double quant, fp16 compute) + LoRA adapters
LoRA r=16, alpha=32, dropout=0.05, bias=none, task CAUSAL_LM
Targets all attention (q/k/v/o_proj) + MLP (gate/up/down_proj) linear layers of the language model (34.9 M trainable params)
Data 24,000 archspec-1 pairs built from modified-swiss-dwellings mds_V2_5.372k.csv — 23,040 train / 480 val / 480 test; avg 7.54 rooms; 570 multi-storey; 21,017 with windows; 14,583 with doors
Loss masking prompt-masked — loss only on the JSON answer tokens
Sequence length 1024 tokens
Optimizer PagedAdamW8bit, weight decay 0.01
Schedule peak LR 2e-4, 3% linear warmup, cosine decay to 10% of peak
Batch effective 16 (gradient accumulation 16, micro-batch 1)
Steps 950 (1 epoch)
Hardware Kaggle T4 (14.5 GB usable), ~9.2 h wall-clock
Stack transformers 5.26.0, peft, bitsandbytes, PyTorch (CUDA)

Results

Train loss 1.44 (step 1) → 0.307 (step 950)
Val loss 0.3359 @ step 100 → 0.3085 @ step 900 (steady decline, no overfit)
Smoke generations 5/5 parsed to valid archspec-1 JSON (see generations.json for all prompt/output pairs)

The stock (un-tuned) base model fails the same prompts — malformed JSON or missing archspec-1 schema (observed during the companion vision run's baseline eval). Generated plans contain non-overlapping rooms, doors connecting touching rooms, exterior windows, and summary counts matching the room/opening lists.

System prompt (use this at inference)

The model was trained with this system prompt; use it for best results:

You are ArchSpec, a residential CAD generator. You turn a plain-language brief into archspec-1 JSON. Rules: metres only; every room needs name, level, x, y, w, d and area_m2; rooms on the same level must not overlap; summary counts must match the rooms list; emit JSON only - no prose, no code fences.

Usage

import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base = AutoModelForCausalLM.from_pretrained(
    "google/gemma-4-e4b-it",
    torch_dtype=torch.float16,
    device_map="auto",
    # low-VRAM GPUs: also pass bitsandbytes 4-bit NF4 config, as in training
)
model = PeftModel.from_pretrained(base, "sazid63/gemma-4-e4b-archspec-lora")
tok = AutoTokenizer.from_pretrained("sazid63/gemma-4-e4b-archspec-lora")

system = "You are ArchSpec, a residential CAD generator. You turn a plain-language brief into archspec-1 JSON. Rules: metres only; every room needs name, level, x, y, w, d and area_m2; rooms on the same level must not overlap; summary counts must match the rooms list; emit JSON only - no prose, no code fences."
messages = [
    {"role": "system", "content": system},
    {"role": "user", "content": "Build me the CAD data for a studio apartment of 73 m². It has 1 bathroom. Include a separate kitchen, one balcony, a storage room and a proper hallway."},
]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1200, do_sample=True, temperature=0.3, top_p=0.9)
print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))

Generation settings used in training eval: max_new_tokens=1200, temperature=0.3, top_p=0.9. A 1200-token budget comfortably fits a full apartment spec.

Note on vision: this adapter adds no image input. A multimodal (floor-plan image → archspec-1) variant exists as a separate config — see sazid63/gemma-4-e4b-archspec-vision-lora (currently an untrained smoke-run artifact).

Files

File Purpose
adapter_model.safetensors / adapter_config.json the LoRA weights + PEFT config (load with PeftModel.from_pretrained)
tokenizer.json, tokenizer_config.json, chat_template.jinja tokenizer copied from the base model, with chat template
generations.json 5 post-training text→archspec-1 sample generations, all valid JSON

Trained as part of the ArchResidenceBD / CAD pipeline (Kaggle kernel cad-gemma4-archspec-lora).

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support