Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemma-Andy

Public fine-tuning repository for Gemma-Andy, a LoRA adapter on top of google/gemma-4-E4B-it specialized for structured body orchestration inside Minecraft.

Gemma-Andy is the body-side model used in the broader DaemonCraft companion architecture. Its job is narrow and explicit: receive structured world state plus an allowed tool envelope, and return a structured execution plan for the Minecraft bot layer.

This repository is focused on the Gemma fine-tuning and serving artifacts: adapter weights, released dataset, schemas, runtime integration notes, and the reference Ollama packaging.

Scope

Gemma-Andy is trained to:

  • read a JSON body-state request,
  • reason over world state, allowed tools, and constraints,
  • return JSON with body_plan, checks, tool_calls, failure_policy, and operational_risk.

Gemma-Andy is not the conversational companion. Narrative, dialogue, and open-ended mediation belong to a separate upstream layer in the DaemonCraft stack.

Release status

Current release:

  • adapter: v2.2.3
  • base model: google/gemma-4-E4B-it
  • adapter file: adapter/adapter_model.safetensors
  • adapter sha256: 65f8283eecaa9c74389e437d4536abad6a172de5e2d2d13a53cc7be1a48fa10f
  • Ollama packaging template: ollama/Modelfile

The adapter in this repository matches the current v2.2.3 training output.

Repository layout

  • adapter/ — LoRA adapter weights and tokenizer assets.
  • data/processed/v2_2_2/ — released training dataset used for the current v2.2.3 adapter.
  • docs/ — integration notes, methodology, mitigation notes, and results.
  • examples/ — minimal adapter loading / evaluation example.
  • mitigation/ — mitigation and analysis helpers.
  • ollama/ — reference Modelfile and build notes for Ollama serving.
  • schema/ — tool schemas and guardian policy artifacts.

Dataset

This repository includes the released training dataset used to train the v2.2.3 adapter:

  • data/processed/v2_2_2/train.jsonl
  • data/processed/v2_2_2/eval.jsonl
  • data/processed/v2_2_2/DATASET_METADATA.md
  • data/processed/v2_2_2/analysis.json

Dataset summary:

  • training records: 33,000
  • eval records: 7,000
  • schema family: gemma-andy-tools-v2
  • split provenance and licensing: see data/processed/v2_2_2/DATASET_METADATA.md

Large dataset files are tracked with Git LFS.

Training provenance

The current public adapter release is v2.2.3, trained from the v2_2_2 dataset split above.

Core run parameters:

  • LoRA rank: 16
  • LoRA alpha: 32
  • sequence length: 1280
  • gradient accumulation: 8
  • micro-batch: 1
  • epochs: 1
  • qlora: true

Quickstart

1. Get access to the base model

Accept the Gemma terms and authenticate with Hugging Face.

huggingface-cli login

2. Load the adapter with PEFT

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

base = AutoModelForCausalLM.from_pretrained(
    "google/gemma-4-E4B-it",
    torch_dtype=torch.bfloat16,
    attn_implementation="eager",
    device_map="cuda",
)
model = PeftModel.from_pretrained(base, "./adapter")
model.eval()

tokenizer = AutoTokenizer.from_pretrained("./adapter")

See examples/eval_with_adapter.py for a runnable example.

3. Package for Ollama

Use ollama/Modelfile as the reference packaging template after merging the adapter into the base and converting to GGUF.

Notes on naming

The name Gemma-Andy reflects both the Gemma base model and the influence of prior Minecraft companion datasets, especially the public Andy dataset line that helped shape parts of the data methodology and naming lineage. Attribution and source breakdown are documented in data/processed/v2_2_2/DATASET_METADATA.md.

Sibling release: Qwen-Andy

There is a parallel release based on Qwen/Qwen3.6-27B (Apache 2.0) at Mar-IA-no/deamoncraft-qwen3-6-andy. Same v2.2.2 dataset, same SYSTEM contract, same tool schema, same Ollama integration shape (/api/chat endpoint with the equivalent Modelfile). The only differences are the base model, the quantization preset, and the runtime profile.

Apples-to-apples comparison on the v2.2.2 holdout (n=50, adapter served via Ollama, both with their respective production-tuned generation params):

Metric Gemma-Andy E4B Q8_0 Qwen-Andy 27B Q4_K_M Δ
json_valid_rate 0.78 0.78 empate
required_keys_rate 0.78 0.78 empate
risk_valid_rate 0.78 0.78 empate
tools_valid_rate 0.72 0.78 Qwen +6 pp
tool_choice_match_rate 0.54 0.64 Qwen +10 pp
operational_risk_match_rate 0.60 0.76 Qwen +16 pp
tool_count_match_rate 0.58 0.70 Qwen +12 pp
gen_seconds_mean (RTX 3090) 10.18 s 11.32 s empate (+1.1 s)

On the adversarial v3 slice (n=560, NF4 HF inference):

Metric Gemma-Andy Qwen-Andy Δ
compliance_rate 0.866 0.900 Qwen +3.4 pp
forbidden_tool_used_rate 0.1125 0.1000 Qwen mejor (−1.25 pp)
decision_match_rate 0.530 0.568 Qwen +3.8 pp
json_valid_rate 0.979 1.000 Qwen +2.1 pp
risk_level_match_rate 0.186 0.329 Qwen +14.3 pp

Compliance per bucket (highlights, Gemma → Qwen):

  • tool_abuse: 82.5% → 100% (+17.5 pp)
  • prompt_override_direct: 75.0% → 90.0% (+15.0 pp)
  • recovery_poisoning: 92.5% → 100% (+7.5 pp)
  • language_attack_es: 95.0% → 98.8% (+3.8 pp)
  • griefing_disguised: 72.5% → 67.5% (Gemma still better here, −5 pp)
  • other buckets: empate or marginal Qwen advantage

Trade-off summary:

Aspect Gemma-Andy E4B Q8_0 Qwen-Andy 27B Q4_K_M
Model params 7.5 B 27 B
VRAM in Ollama ~11.5 GB ~22.7 GB
GGUF size 8 GB 16 GB
Latency (RTX 3090, typical response) ~10 s ~11 s
JSON structural validity 0.78 0.78 (empate)
Tool choice + risk fidelity baseline +10–16 pp
Base model license Gemma Terms (gated) Apache 2.0 (open)
Identifies as "Gemma-Andy v2.1" "Gemma-Andy v2.1" (*)

(*) Both fine-tunes share the byte-exact SYSTEM prompt from the v2.2.2 dataset, which literally names the model "Gemma-Andy v2.1". A v2.3+ dataset is planned to rename that internal identity for the Qwen branch.

When to pick which:

  • Gemma-Andy if you need lower VRAM, you have already integrated against the Gemma terms, or you want to stay on the original baseline.
  • Qwen-Andy if you want the +10–16 pp gains on tool_choice / operational_risk_match / adversarial compliance, can afford ~23 GB VRAM, and prefer an Apache 2.0 base.

Documentation

Key docs in this repository:

  • docs/PROJECT_BACKGROUND.md
  • docs/METHODOLOGY.md
  • docs/INTEGRATION_GUIDE.md
  • docs/MITIGATION_RESULTS.md
  • docs/OLLAMA_USAGE.md

License

  • repository code, docs, and released dataset artifacts: Apache-2.0
  • base model google/gemma-4-E4B-it: governed separately by the Gemma Terms of Use and related policy documents

This adapter is based on Gemma, as required by the Gemma attribution clause.

About

LoRA adapter (Gemma 4 E4B-it) + integration docs for body orchestration in Mineflayer-based Minecraft companion agents. Part of the DaemonCraft / HermesCraft project.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages