fine-tuned-model-indonesian-GRPO is an Indonesian-focused Language Model based on Llama-3.1-8B, fine-tuned using Group Relative Policy Optimization (GRPO) via Unsloth and Hugging Face TRL. The model is specially tailored for Legal AI RAG (Retrieval-Augmented Generation) workflows, producing structured reasoning (Chain-of-Thought) enclosed in <think>...</think> and <answer>...</answer> tags in Indonesian.
| Attribute | Details |
|---|---|
| Developer | hendrimardani |
| Base Model | unsloth/Llama-3.1-8B-unsloth-bnb-4bit |
| Fine-Tuning Method | GRPO (Group Relative Policy Optimization) + PEFT/LoRA |
| Target Language | Indonesian (id) |
| License | Apache 2.0 |
| Pipeline Tag | text-generation / Conversational Legal Reasoning |
| Max Sequence Length | 2048 tokens |
<think> tags before delivering the final answer inside <answer> tags.To prevent language degradation, typos, or infinite sentence looping, use the following generation parameters during inference:
| Parameter | Recommended Value | Explanation |
|---|---|---|
do_sample |
True |
Enables token probability sampling |
temperature |
0.3 |
Ensures reasoning remains factual and anchored strictly to context |
repetition_penalty |
1.18 |
Prevents repetitive loops while retaining legal terminology |
max_new_tokens |
1024 |
Provides sufficient allocation for both reasoning and answer blocks |
⚠️ Important Note: Avoid using small values for
no_repeat_ngram_size(e.g.,4), as it can trigger token corruption (garbled text or typos) when the model needs to repeat legal terms or clause names.
transformersimport torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "hendrimardani/fine-tuned-model-indonesian-GRPO"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16,
load_in_4bit=True
)
system_prompt = """Anda adalah asisten hukum AI yang analitis dan presisi.
ATURAN WAJIB GENERASI:
1. Di dalam tag <think>...</think>: Tuliskan HANYA 2-3 kalimat penalaran analitis ringkas. Hubungkan profil/pertanyaan user dengan pasal spesifik.
2. Di dalam tag <answer>...</answer>: Berikan jawaban langsung, solutif, dan jelas kepada user berbasis konteks."""
messages = [
{"role": "system", "content": system_prompt},
{
"role": "user",
"content": (
"PERTANYAAN USER:\nSaya staf admin kerja lembur 3 jam, apakah berhak dapat uang lembur?\n\n"
"DOKUMEN KONTEKS:\nPP No. 35 Tahun 2021 Pasal 27: Pengusaha wajib membayar upah lembur kepada pekerja/buruh yang dipekerjakan melebihi waktu kerja normal."
)
}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
prompt += "<think>\n" # Prefill reasoning tag
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=1024,
do_sample=True,
temperature=0.3,
repetition_penalty=1.18,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id if tokenizer.pad_token_id is not None else tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
print("<think>\n" + response)
from transformers import pipeline
from langchain_community.llms import HuggingFacePipeline
text_generation_pipeline = pipeline(
task="text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=1024,
do_sample=True,
temperature=0.3,
repetition_penalty=1.18,
return_full_text=False,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id if tokenizer.pad_token_id is not None else tokenizer.eos_token_id
)
llm = HuggingFacePipeline(pipeline=text_generation_pipeline)
The model is designed to consistently output structured responses in Indonesian:
<think>
User menanyakan hak upah lembur untuk posisi staf admin (3 jam lembur). Berdasarkan PP No. 35 Tahun 2021 Pasal 27, kerja melebihi waktu normal wajib diberi upah lembur. Maka staf admin berhak atas upah 3 jam tersebut.
</think>
<answer>
Ya, Anda berhak mendapatkan upah lembur. Berdasarkan PP No. 35 Tahun 2021 Pasal 27, pengusaha wajib membayar upah lembur untuk pekerja yang bekerja melebihi waktu kerja normal (8 jam sehari).
</answer>
This model is built to assist with legal research and document retrieval (RAG). Output generated by this model does not constitute legal advice. Users are advised to verify all generated information against official Indonesian statutory sources.
model-00002-of-00004.safetensors 5.0 GBmodel-00001-of-00004.safetensors 5.0 GBmodel-00003-of-00004.safetensors 4.9 GBmodel-00004-of-00004.safetensors 1.2 GBadapter_model.safetensors 168 MBlast-checkpoint/adapter_model.safetensors 168 MBlast-checkpoint/optimizer.pt 87 MBlast-checkpoint/rng_state.pth 14.6 kBlast-checkpoint/training_args.bin 7.3 kBtraining_args.bin 7.3 kBlast-checkpoint/scheduler.pt 1.5 kBlast-checkpoint/scaler.pt 1.4 kBHave the files? Submit a torrent.
Submit a torrentHave the complete files and permission to share them? Replace the example folder path. The script checks the files, makes a torrent and submits its magnet and checksums. Keep your torrent client seeding. Get your community key from your settings, and read the script before running it.
curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo hendrimardani/fine-tuned-model-indonesian-GRPO ./model-folder