SAGA: Syntax-Aligned Grammar Adaptation
Collection
RLVF pipeline using parser oracles to align LMs for Icelandic and Danish. GPT-SW3 and Viking-13B trained with Delta-DPO. • 7 items • Updated
How to use Hodfa71/llama-3.2-1b-nb-saga-delta-dpo with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
model = PeftModel.from_pretrained(base_model, "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo")How to use Hodfa71/llama-3.2-1b-nb-saga-delta-dpo with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Hodfa71/llama-3.2-1b-nb-saga-delta-dpo") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Hodfa71/llama-3.2-1b-nb-saga-delta-dpo", device_map="auto")How to use Hodfa71/llama-3.2-1b-nb-saga-delta-dpo with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Hodfa71/llama-3.2-1b-nb-saga-delta-dpo
How to use Hodfa71/llama-3.2-1b-nb-saga-delta-dpo with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Hodfa71/llama-3.2-1b-nb-saga-delta-dpo with Docker Model Runner:
docker model run hf.co/Hodfa71/llama-3.2-1b-nb-saga-delta-dpo
LoRA adapter trained with SAGA (Syntax-Aligned Grammar Adaptation) using Δ-DPO on Norwegian Bokmål (NB).
Part of the SAGA HuggingFace Collection.
Model trained by Emil Carlsson Wiman as part of the SAGA project.
| Model | Parse Success | Parse Score | PPL |
|---|---|---|---|
| Llama-3.2-1B base | 83.0% | 0.392 | 30.1 |
| + SAGA Δ-DPO (this model) | 98.5% | 0.622 | 33.0 |
Cross-lingual transfer (zero-shot from NB adapter):
| Target | Parse Success |
|---|---|
| Danish | 98.5% |
| Swedish | 99.0% |
| Icelandic | 91.5% |
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.2-1B",
dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(base, "Hodfa71/llama-3.2-1b-nb-saga-delta-dpo")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
inputs = tokenizer("Regjeringen kunngjorde i dag", return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=80, do_sample=True, temperature=0.8)
print(tokenizer.decode(out[0], skip_special_tokens=True))
nb_core_news_lgrepetition_penalty=1.3, mattr_window=20@article{fakhar2025saga,
title = {SAGA: Syntax-Aligned Grammar Adaptation via Reinforcement Learning from Verifiable Feedback},
author = {Fakhar, Hoda and Carlsson Wiman, Emil},
year = {2025}
}
Base model
meta-llama/Llama-3.2-1B