Muse-Glimmer-30B-rego
Writes Open Policy Agent (Rego) policies from a plain-language compliance control and a target package name. Merged fine-tune for engineers authoring policy-as-code against Terraform, Kubernetes and cloud resource documents.
This is a merged fine-tune of
meta-models/Muse-Glimmer-30B:
the LoRA adapter has been fused into the base weights with merge_and_unload(),
so it loads as an ordinary transformers checkpoint with no PEFT dependency. It
was trained with 4-bit-quantized-base LoRA via
TRL SFT.
Model details
| Developed by | SASVA AI Model Cognition Labs (MCL) Team |
| Base model | meta-models/Muse-Glimmer-30B @ a4e59da52a7bc87ae7251dd5545c0dd437c44b68 |
| Base parameters | 29.78B total — 27.85B language model, 1.92B vision tower |
| Architecture family | muse_glimmer (MuseGlimmerForConditionalGeneration) — 52 layers, hidden 6656, GQA 32 Q-heads / 2 KV-heads, vocab 202,048 |
| Adaptation | LoRA (r=16, alpha=32, dropout=0.05), merged into the base |
| Trainable modules | attention projections only: q_proj, k_proj, v_proj, o_proj — 208 modules (52 layers × 4), 416 adapter tensors |
| Untouched | vision tower, vision adapter, vision projection, every MLP, embeddings, lm_head, every norm |
| Training method | 4-bit NF4 quantized base, bf16 LoRA on attention projections, bf16 compute |
| Precision in this repo | bfloat16, unquantized, plus two GGUF quants |
| Weights | 13 safetensors shards, 59,553,253,376 B — 55.5 GiB |
| Context length | 131,072 (base capability); trained at 2,048 |
| Language | English prompts, Rego targets |
| License | Apache-2.0, inherited from the base model |
The config here carries no quantization_config — 4-bit NF4 was a
training-time choice, not a property of these weights.
Every one of the 416 adapter tensors sits on model.language_model. The vision
tower is bit-identical to the base in these merged weights, verified by
tensor comparison rather than assumed; so are all MLP projections.
Intended use
Direct use. Given a written control requirement and the Rego package the
policy must declare, emit the policy: the package line, any imports, and the
named rule, as raw Rego with no prose and no markdown fences.
The prompt format is part of the contract. The model was trained on one exact rendering; see How to get started. Prompting it as a general chat model will not reproduce its behaviour.
Not a security control. Generated policies are a starting point. Review them and run them against your own two-sided tests before they gate anything — a policy that compiles and reads plausibly can still deny nothing. See Evaluation for where this model is and is not competent.
How to get started
Prompt format
The model uses the base model's ATEM chat template. Training rendered each sample as (newlines shown literally):
<|start|>system<|message|>{SYSTEM}<|eot|><|start|>user<|message|>{INSTRUCTION}
package: {PACKAGE}
rule: {RULE}
input shape:
{JSON_SHAPE_SKETCH}<|eot|><|start|>assistant to=user<|message|>{REGO}<|eot|>
Three things follow from this, and all three bite in practice:
- The user turn is the control requirement, then
package:andrule:on their own lines, then an optionalinput shape:JSON sketch. The package name and rule name are not decoration — they are what the generated policy must declare. Theinput shapeblock measurably helps: it tells the model which resource type and attribute names to reference. - The assistant turn is left open by
add_generation_prompt=True. The rendered prompt ends at<|start|>assistant, not at<|message|>. See The assistant turn is left open — this is the single most common way to get wrong-looking output from this model. - Decode greedily. The task has one correct behaviour, not a distribution of styles; the model was both trained and evaluated with sampling off.
System prompt
This is the exact system prompt the adapter was trained under, taken from the
training configuration. Changing it moves the model off its trained contract.
It is also shipped as system and as the SYSTEM block of
Modelfile.
You are a Rego policy author. Given a compliance control requirement in natural language and a target Rego package name, output a complete, correct Open Policy Agent policy that denies non-compliant inputs and allows everything else. Output ONLY valid Rego source code declaring the specified package and defining the appropriate deny rule — no markdown, no commentary, no explanation.
Loading it
from_pretrained requests files by name, so it fetches the config, tokenizer
and safetensors shards only — the GGUFs in this repo cost transformers users
nothing. If you instead download the repo by hand, filter it, or you will pull
all 99 GB:
hf download SASVAAI/Muse-Glimmer-30B-rego --exclude "*.gguf" --local-dir ./Muse-Glimmer-30B-rego
Requires transformers >= 5.15, which is where model_type: muse_glimmer
landed. Two loader notes, both verified on this repo:
AutoModelForCausalLMcannot load this architecture — it raisesUnrecognized configuration class. UseAutoModelForImageTextToText, which is what the multimodal config maps to.- Use
AutoTokenizer, notAutoProcessor.AutoProcessoralso constructs the image processor and fails withCould not load any image processor class ... Missing optional dependencies: torchvision. For a text-only task the tokenizer is sufficient and drops the dependency.
import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer
MODEL = "SASVAAI/Muse-Glimmer-30B-rego"
tokenizer = AutoTokenizer.from_pretrained(MODEL)
model = AutoModelForImageTextToText.from_pretrained(
MODEL, dtype=torch.bfloat16, device_map="auto",
attn_implementation="sdpa", # "flash_attention_2" if flash-attn is installed
)
model.eval()
SYSTEM = (
"You are a Rego policy author. Given a compliance control requirement in "
"natural language and a target Rego package name, output a complete, correct "
"Open Policy Agent policy that denies non-compliant inputs and allows "
"everything else. Output ONLY valid Rego source code declaring the specified "
"package and defining the appropriate deny rule — no markdown, no commentary, "
"no explanation."
)
user = (
"Write an Open Policy Agent (Rego) policy that enforces this control:\n"
"S3 buckets must have encryption at rest enabled.\n\n"
"package: builtin.aws.s3.aws0088\nrule: deny"
)
messages = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": user}]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True,
)
text += " to=user<|message|>" # closes the turn — see the section below
enc = tokenizer(text, return_tensors="pt", add_special_tokens=False).to(model.device)
out = model.generate(**enc, max_new_tokens=1536, do_sample=False)
print(tokenizer.decode(out[0][enc["input_ids"].shape[-1]:], skip_special_tokens=True))
Run locally with Ollama
Both GGUFs ship in this repo, so there is nothing to build. Either of these works:
# A. One command — Ollama pulls the GGUF straight from this repo
ollama run hf.co/SASVAAI/Muse-Glimmer-30B-rego
# B. Or fetch the GGUF plus the Modelfile and build the tag locally
hf download SASVAAI/Muse-Glimmer-30B-rego \
--include "*Q4_K_M.gguf" "Modelfile" --local-dir .
ollama create muse-glimmer-rego -f Modelfile
ollama run muse-glimmer-rego
Either way you download 15.8 GiB, not the 55.5 GiB of bf16 safetensors — Ollama only fetches the GGUF.
The two paths are not quite equivalent. ollama run hf.co/... never reads a
Modelfile. The Hub serves a GGUF repo to Ollama through its own
OCI-compatible registry: it picks the Q4_K_M GGUF as the model layer and
attaches this repo's params and system files as the
parameter and system-prompt layers. Those two files are kept byte-equivalent to
the Modelfile's PARAMETER lines and SYSTEM block, so both
routes land on the same greedy, system-prompted configuration. Path B is the one
to use if you want to edit any of it, or to run the Q8_0 instead.
Requirements
A runtime whose llama.cpp knows the muse-glimmer architecture: llama.cpp
PR #26841, first released in
b10353. Older runtimes refuse to load with
unknown model architecture: 'muse-glimmer'. Verified here on Ollama
v0.40.3.
Verified transcript
Built and run end-to-end on this host from the GGUF in this repo (Ollama v0.40.3, 8 × H100 80GB, 48 CPU threads):
ollama create muse-glimmer-rego -f Modelfile # real 0m32.470s
ollama show muse-glimmer-rego
Model
architecture muse-glimmer
parameters 27.9B
context length 131072
embedding length 6656
quantization Q4_K_M
Capabilities
tools
completion
Parameters
num_ctx 8192
num_predict 1536
stop "<|eot|>"
stop "<|eom|>"
temperature 0
top_k 1
parameters 27.9B is the language tower alone (27.85B measured on the
safetensors), not the 29.78B of the full checkpoint. The vision tower is not in
the GGUF — see Building your own GGUF.
Then the S3-encryption prompt above, through /api/chat with
"options": {"num_thread": 48}:
done_reason | stop |
prompt_eval_count | 137 tokens |
prompt_eval_duration | 0.86 s |
eval_count | 87 tokens |
eval_duration | 1.12 s (≈77.5 tok/s, GPU-offloaded) |
load_duration | 10.36 s |
total_duration | 12.36 s |
All seven figures are from one cold call against a freshly started server; a
warm repeat returns in ~1.4 s, the difference being load_duration.
Three things worth noting, all confirmed on this build:
prompt_eval_countis 137 — the same count thetransformerstokenizer produces for the same system+user messages. (The Python snippet above reads 140 because it appends the three-tokento=user<|message|>opener by hand; Ollama's template emits those same three tokens on the other side of the boundary.) TheModelfileSYSTEMblock plus the GGUF's embedded chat template reconstruct the training-time prompt exactly.num_ctxis load-bearing. Ollama sizes the default context from available VRAM and will pick 131,072 on a large host. TheModelfilepins 8,192; the model was trained at a sequence length of 2,048 and the longest gold policy in the validation split is ~2,348 tokens.- Use
/api/chat, not/api/generate. See the next section.
The assistant turn is left open
This is the one thing that silently produces wrong-looking output. It is worth reading before you wire this model into anything that parses its answers.
Muse-Glimmer's ATEM template does not close the assistant turn. A complete
turn is <|start|>assistant to=user<|message|>CONTENT<|eot|>, but
add_generation_prompt=True stops at <|start|>assistant. The model then
generates the routing channel itself, skip_special_tokens strips only the
special <|message|>, and the plain text to=user is left glued to the first
line:
to=userpackage builtin.aws.s3.aws0088
Any parser keyed on a leading package then fails. Measured behaviour by entry
point, all on this repo's artifacts:
| Entry point | Emits to=user? | Why |
|---|---|---|
ollama run / /api/chat | no | Ollama applies the embedded chat template and closes the turn |
/api/generate with a raw prompt | yes | no template is applied — you get the raw completion |
llama-cli -sys ... -p ... | no | llama.cpp applies the template |
transformers + apply_chat_template(add_generation_prompt=True) | yes | the template leaves the turn open |
For the two that leak it, either append " to=user<|message|>" to the rendered
prompt (what the Python snippet above does) or strip a leading to=user from
the decoded text. Both were verified to give identical, clean output.
Building your own GGUF (optional)
Needed only if you want a quantization other than the shipped Q4_K_M and
Q8_0.
git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
pip install -r requirements/requirements-convert_hf_to_gguf.txt
python convert_hf_to_gguf.py /path/to/Muse-Glimmer-30B-rego \
--outfile Muse-Glimmer-30B-rego-bf16.gguf --outtype bf16
cmake -B build -DGGML_NATIVE=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j
./build/bin/llama-quantize Muse-Glimmer-30B-rego-bf16.gguf \
Muse-Glimmer-30B-rego-Q4_K_M.gguf Q4_K_M 64
Note the argument order: llama-quantize [options] IN OUT TYPE [nthreads].
There is no --threads flag; passing one prints the usage block and exits 1.
Measured on this repo's weights:
| Quant | Size on disk | BPW | Tensors | Quantize time (64 threads) |
|---|---|---|---|---|
bf16 | 55,725,513,952 B — 51.9 GiB | 16.00 | 731 | — |
Q8_0 | 29,612,960,992 B — 27.6 GiB | 8.50 | 731 | 39.6 s |
Q4_K_M | 16,935,294,432 B — 15.8 GiB | 4.86 | 731 | 61.3 s |
llama-quantize reported model size = 53131.48 MiB → quant size = 16138.25 MiB for Q4_K_M. Other K-quants land between these rows; the three
above are the only ones actually built and run here, so they are the only ones
quoted.
The GGUFs carry 731 tensors against 1,436 in the safetensors — the converter
emits the text model only. The vision tower is a separate --mmproj run and is
not part of this repo's GGUFs, which is consistent with the vision tower never
having been trained. If you need image input, use the base model's mmproj.
Unlike some merged checkpoints, nothing is dropped by the merge here: the safetensors index carries the same 1,436 tensors as the base, so conversion has everything it needs. That was checked, not assumed.
Stop tokens
The Modelfile's explicit stop "<|eot|>" / stop "<|eom|>" lines are
belt-and-braces. The completion above ended on done_reason: "stop" with the
model emitting <|eot|> itself.
Quantization fidelity
The S3-encryption prompt was run under greedy decoding (temperature 0 /
top_k 1) against all three artifacts in this repo: the bf16 safetensors via
transformers, and both GGUFs via Ollama /api/chat.
| Artifact | Output tokens | Chars | SHA-1 of output |
|---|---|---|---|
| bf16 safetensors | 81 | 328 | 9e1934b9d3c0 |
Q8_0 GGUF | 84 | 328 | 9e1934b9d3c0 |
Q4_K_M GGUF | 87 | 338 | f56ebd492c0e |
-
Q8_0is byte-identical to bf16 on this prompt — same 328 characters, same SHA-1. The count differs by exactly 3 because Ollama'seval_countincludes the three channel tokens the model emits (to=user<|message|>, measured at 3 tokens), which thetransformersrun supplied in the prompt instead.<|eot|>is not counted. -
Q4_K_Mis not. It produced a semantically different policy, not a whitespace difference:- some bucket in input.aws.s3.buckets - not bucket.serverSideEncryption.enabled + some bucket in object.get(input.aws.s3, "buckets", {}) + bucket.serverSideEncryption == "disabled"The
Q4_K_Mversion tests a string equality where the bf16 version tests a boolean field, and the two do not decide the same way on the same input. -
bf16 greedy decoding was confirmed reproducible: three consecutive generations in one process produced the identical SHA-1.
One prompt is one prompt, and exact_match was measured on bf16 only. But on
the one case compared, Q4_K_M changed the behaviour of the generated policy —
which is exactly what this model's metric is about. If you are scoring or
gating on output correctness, prefer Q8_0; Q4_K_M is the one that fits a
24 GB card.
Training details
Data
| Train | 2,923 pairs |
| Validation | 706 pairs |
| Max sequence length | 2,048 tokens |
Each pair is (control requirement, target package + rule + input shape, gold Rego policy), mined from five permissively licensed upstream repositories.
Every retained pair was validated by running the gold policy against its own
gold tests through the same harness used for scoring, so a sample exists only
where the oracle is known to work on it.
| Source | Licence | Train | Val |
|---|---|---|---|
Checkmarx/kics | Apache-2.0 | 1,435 | 109 |
carbonetes/brainiac | Apache-2.0 | 918 | 528 |
aquasecurity/trivy-checks | MIT | 458 | 58 |
gopal | Apache-2.0 | 72 | 2 |
open-policy-agent/gatekeeper-library | Apache-2.0 | 40 | 9 |
The split is group-aware on source so near-identical checks cannot straddle it. It was not stratified by source, which is why the validation split is 75% brainiac while the training split is 49% KICS — see Evaluation, where that skew dominates the headline number.
The control requirement is taken from each policy's upstream METADATA
title/description, which sometimes names the exact field the policy checks.
That is realistic for a written control, but it makes the task easier than
open-ended policy authoring.
Method
4-bit QLoRA (bitsandbytes NF4) with a LoRA adapter over the language model
only, attention projections only. Supervised fine-tuning on completions and
prompts together — standard causal LM loss over the full rendered sequence.
8 × H100 80GB, torchrun --nproc_per_node 8.
The adapter targets q_proj, k_proj, v_proj, o_proj across all 52 layers.
A regex exclude_modules pattern keeps PEFT's suffix matching off the vision
tower — without it, q_proj would also match
model.vision_tower.layers.N.attn.q_proj and silently adapt the 1.92B ViT. That
resolves to 208 modules, all in the language model, none in the vision
tower. MLP projections were not trained.
Final hyperparameters
lora_r | 16 |
lora_alpha | 32 |
lora_dropout | 0.05 |
learning_rate | 2e-4 |
lr_scheduler_type | cosine |
num_train_epochs | 2 |
per_device_train_batch_size | 1 |
gradient_accumulation_steps | 4 |
| Effective batch size | 32 (1 × 4 × 8 GPUs) |
warmup_ratio | 0.05 |
weight_decay | 0.01 |
max_length | 2,048 |
| Precision | bf16, gradient checkpointing on, sample packing off |
| Total optimizer steps | 182 |
DoRA, rsLoRA, LoRA+, NEFTune, Liger kernels and PiSSA/LoftQ initialisation were not used; the adapter is plain LoRA with default initialisation.
Observed training metrics
train_loss | 0.38209457711859063 |
eval_loss | 0.35263916850090027 |
train_runtime | 1,000.16 s (~16 m 40 s) |
train_samples_per_second | 5.803 |
train_steps_per_second | 0.182 |
total_flos | 5.922349678120141e+17 |
Final train mean_token_accuracy | 0.9339 |
Final eval mean_token_accuracy | 0.9182 |
| Tokens seen | 3,429,554 |
Evaluation
The primary metric is behavioural, not textual. Despite the name,
exact_match here is not string equality against a reference policy. Each
generated policy is written into a sandboxed workspace alongside the gold test
file and the upstream Rego library bundle, and executed:
opa test <workspace> --format json --capabilities <allowlist>
A sample scores 1.0 only if the policy compiles and every one of its gold
test cases passes. A policy that is textually nothing like the reference but
allows and denies the same inputs scores correct; a policy that looks almost
identical but inverts a condition scores 0. The gold tests are two-sided
(test_deny_* and test_allow_*), so a degenerate "deny nothing" policy cannot
pass. Checkmarx KICS queries are scored by a second oracle — the KICS engine
itself, over positive* IaC fixtures that must fire and negative* fixtures
that must not.
Measured on these merged bf16 weights, over the full 706-row held-out
validation split, greedy decode, max_new_tokens=1536:
| Metric | Value | Meaning |
|---|---|---|
| exact_match | 0.3329 | 235/706 policies passed every gold test |
test_case_rate | 0.5825 | 1,100/1,752 individual gold test cases passed |
compile_rate | 0.9278 | 655/706 policies were valid, compiling Rego |
Read the per-source breakdown before trusting the headline
| Source | exact_match | compile_rate | n |
|---|---|---|---|
carbonetes/brainiac (Terraform) | 0.426 | 0.991 | 528 |
aquasecurity/trivy-checks | 0.138 | 0.397 | 58 |
Checkmarx/kics | 0.000 | 0.954 | 109 |
open-policy-agent/gatekeeper-library | 0.000 | 0.333 | 9 |
gopal | 1.000 | 1.000 | 2 |
225 of the 235 passes (96%) are brainiac. Because the split was not stratified, the validation set is 75% brainiac and the headline number is close to a brainiac-only score. KICS is the sharpest failure: 104 of 109 KICS policies compile but none produce correct findings, despite KICS being the largest share of the training set at 1,435 rows. Treat anything outside Terraform-style resource checks as unvalidated.
There is no measured base-model baseline on this validation set. The uplift from fine-tuning is therefore not quantified here, and should not be inferred from the numbers above.
Known limits beyond the table: the corpus is dominated by two projects with
their own conventions (result.new, fail[]/pass[] contracts, lib/cloud/*
helpers), and output follows those conventions. The corpus also mixes Rego v0
and v1, so output may need --v0-compatible depending on which idiom the model
picks for a given prompt.
Environmental impact
Reported rather than estimated, since the hardware is shared and per-job power was not instrumented:
| Hardware | 8 × NVIDIA H100 80GB |
| Training runtime | 1,000 s (~0.28 h) |
total_flos | 5.92e+17 |
Carbon emitted was not measured; the grid region and PUE of the host are not known to the authors.
Framework versions
| PEFT | 0.18.1 |
| TRL | 1.0.0 |
| Transformers | 5.17.0 |
| PyTorch | 2.5.1+cu121 |
| Datasets | 4.8.4 |
| Tokenizers | 0.23.2 |
| Accelerate | 1.13.0 |
| bitsandbytes | 0.49.2 |
| Ollama (verification) | 0.40.3 |
| llama.cpp (conversion) | 1b70350 |
muse_glimmer requires transformers >= 5.15; it is not present in earlier
releases.
Citation
Cite this model, the base model and the training stack:
@misc{muse_glimmer_30b_rego_2026,
title = {Muse-Glimmer-30B-rego},
author = {{SASVA AI Model Cognition Labs (MCL) Team}},
year = {2026},
url = {https://huggingface.co/SASVAAI/Muse-Glimmer-30B-rego}
}
@misc{muse_glimmer_30b,
title = {Muse Glimmer 30B},
author = {{Meta Superintelligence Lab}},
year = {2026},
url = {https://huggingface.co/meta-models/Muse-Glimmer-30B}
}
@misc{trl,
title = {TRL: Transformer Reinforcement Learning},
author = {von Werra, Leandro and others},
year = {2020},
url = {https://github.com/huggingface/trl}
}