CoolFace
Modelpublic

mdonigian/trellis-sft

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
Model Card

Trellis-506M-SFT

Supervised fine-tuned version of Trellis-506M, a 506M parameter LLaMA-style language model optimized for structured output tasks — JSON generation, function calling, schema compliance, and structured extraction.

Model Details

ParameterValue
Base modelmdonigian/trellis-pretraining
ArchitectureLLaMA (LlamaForCausalLM)
Parameters~506M
Hidden size1,280
Layers24
Attention heads20 (10 KV heads, GQA 2:1)
Context length2,048
Vocab size50,304 (50,277 base + 6 chat tokens + padding)
Precisionbfloat16

SFT Training

Dataset

Trained on mdonigian/full-structured-instruction-sft-dataset (~95k examples), assembled from:

SourceTarget CountDescription
Glaive Function Calling v2~70,000Multi-turn function calling conversations
UltraChat 200k~30,000General instruction-following dialogues
Hermes Function Calling v1~20,000Single/multi-turn function calling + JSON mode
Synthetic JSON schema compliance~9,000Schema → correct JSON (generated with GPT-5-mini)
Synthetic structured extraction~5,000Text → structured JSON extraction (generated with GPT-5-mini)

All examples are standardized to a common chat format using custom special tokens (see below). Source-specific filtering includes deduplication, token length capping (2048), and quality validation.

Hyperparameters

ParameterValue
Epochs3
Effective batch size32
Learning rate2e-5
LR scheduleCosine decay
Warmup10% of total steps
Weight decay0.01
Max gradient norm1.0
Max sequence length2,048
OptimizerAdamW (fused)
Precisionbfloat16
Seed42

Training Details

  • Framework: TRL SFTTrainer
  • Attention: Flash Attention 2
  • Compilation: torch.compile enabled
  • Loss masking: Completion-only — loss computed only on assistant response tokens, not system/user/tool tokens
  • Hardware: NVIDIA B200

Chat Format

All training data uses these special tokens:

<|system|>You are a helpful assistant that generates valid JSON.<|end|>
<|user|>Generate a user profile with name, email, and age.<|end|>
<|assistant|>{"name": "Alice Chen", "email": "alice@example.com", "age": 28}<|end|>
TokenPurpose
`<\system\>`System prompt
`<\user\>`User message
`<\assistant\>`Assistant response
`<\tool_call\>`Function/tool call
`<\tool_result\>`Tool execution result
`<\end\>`End of turn

How to Use

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained(
    "mdonigian/trellis-sft",
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("mdonigian/trellis-sft")

prompt = """<|system|>You are a helpful assistant that generates valid JSON.<|end|>
<|user|>Generate a JSON object for a book with title, author, year, and genre.<|end|>
<|assistant|>"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=False))

Experimental Design

This model is one component of a controlled experiment comparing curated pretraining vs. standard pretraining for structured output tasks:

ModelPretrainingParametersSFT
Trellis-506M-SFT (this model)Curated 20B tokens~506MIdentical
Pythia-410M-deduped-SFTThe Pile (uncurated)~410MIdentical
Pythia-1B-deduped-SFTThe Pile (uncurated)~1BIdentical

All three models undergo identical SFT with the same dataset, hyperparameters, and training procedure. Post-SFT evaluation covers:

  • Tier 1: Custom structured output benchmarks (JSON schema compliance, structured extraction, classification)
  • Tier 2: General NLP benchmarks via lm_eval (HellaSwag, ARC, PIQA, Winogrande, MMLU)
  • Tier 3: Code benchmarks (HumanEval, MBPP)

Limitations

  • 506M parameters limits general knowledge and complex reasoning
  • Context length capped at 2,048 tokens
  • No safety training, RLHF, or DPO alignment
  • Optimized for structured output; general chat quality is limited

Citation

@misc{trellis-sft-2026,
  title={Trellis-506M-SFT: Supervised Fine-Tuning for Structured Output},
  author={Donigian, Matt},
  year={2026},
  url={https://huggingface.co/mdonigian/trellis-sft}
}