Run this model with HF Jobs
Run getachewgetu/AmLegal_Gemma-Inst on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/getachewgetu/AmLegal_Gemma-Inst. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/getachewgetu/AmLegal_Gemma-Inst on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/getachewgetu/AmLegal_Gemma-Inst. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/getachewgetu/AmLegal_Gemma-Inst. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use getachewgetu/AmLegal_Gemma-Inst with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use getachewgetu/AmLegal_Gemma-Inst with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="getachewgetu/AmLegal_Gemma-Inst") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("getachewgetu/AmLegal_Gemma-Inst") model = AutoModelForMultimodalLM.from_pretrained("getachewgetu/AmLegal_Gemma-Inst", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use getachewgetu/AmLegal_Gemma-Inst with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "getachewgetu/AmLegal_Gemma-Inst" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "getachewgetu/AmLegal_Gemma-Inst", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/getachewgetu/AmLegal_Gemma-Inst
- SGLang
How to use getachewgetu/AmLegal_Gemma-Inst with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "getachewgetu/AmLegal_Gemma-Inst" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "getachewgetu/AmLegal_Gemma-Inst", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "getachewgetu/AmLegal_Gemma-Inst" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "getachewgetu/AmLegal_Gemma-Inst", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use getachewgetu/AmLegal_Gemma-Inst with Docker Model Runner:
docker model run hf.co/getachewgetu/AmLegal_Gemma-Inst
âď¸ AmLegal_Gemma-Inst: Specialized Amharic Legal LLM
AmLegal_Gemma-Inst is an open-weights, domain-adapted language model fine-tuned for Amharic legal question answering and Retrieval-Augmented Generation (RAG) over decisions of the Federal Supreme Court of Ethiopia Cassation Division (á¨á˘áľáŽáľáŤ áá´áŤá á á áá áááľ á¤áľ á°á á á°á á˝ááľ).
The model is based on google/gemma-3-4b-it and adapted using Rank-Stabilized LoRA (rsLoRA, $r=64$, $\alpha=64$, $\alpha/\sqrt{r}$ scaling) with completion-only loss masking and negative distractor conditioning.
đ Empirical Evaluation (Held-Out Cassation Decisions)
Evaluated against the unadapted base model and alternative 7B models on strictly unseen Ethiopian Supreme Court decisions:
| Evaluation Metric | Base Gemma-3-4B | Qwen-2.5-7B FT | AmLegal_Gemma-Inst (Ours) | Relative Delta |
|---|---|---|---|---|
| ROUGE-1 ($F_1$) | 29.68% | 38.40% | 49.66% | +67.3% |
| ROUGE-2 ($F_1$) | 19.58% | 27.10% | 34.94% | +78.4% |
| ROUGE-L ($F_1$) | 29.68% | 36.59% | 49.66% | +67.3% |
| SacreBLEU | 8.80 | 28.29 | 23.47 | +166.7% |
| chrF | 19.27 | â | 38.95 | +102.1% |
| BERTScore $F_1$ | 58.40% | â | 91.30% | +56.3% |
| Evidence Grounding | 84.00% | 78.00% | 92.00% | +9.5% |
| Citation Recall | 68.94% | 15.31% | 88.07% | +27.7% |
| Citation Precision | 88.46% | 23.21% | 92.02% | +4.0% |
| Citation $F_1$ | 77.49% | 18.45% | 90.00% | +16.1% |
| Foreign Contamination | 7.49% | â | 0.03% | -99.6% (Eliminated) |
| Distractor Misattribution | â | â | 0.00% | Zero confusion |
| Answer Completeness (1â3) | 2.14 | â | 2.88 | +34.6% |
đ§ââď¸ LLM-as-a-Judge Qualitative Scores (Scale 1â10)
- Faithfulness:
9.43 / 10 - Relevance:
9.20 / 10 - Consistency:
9.17 / 10 - Coherence:
9.00 / 10 - Clarity:
8.90 / 10 - Accuracy:
8.53 / 10 - Overall Mean:
8.77 / 10
đť Quick Start & Inference
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "getachewgetu/AmLegal_Gemma-Inst"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
prompt = """<start_of_turn>user
á áá° á¨á˘áľáŽáľáŤ áááľ á¤áľ ááłáŽá˝á á¨ááľááá¨áľ á¨áá°á á¨á
á á¨áłáľ áá
ᢠá¨áá
á áłá˝ á á°á°á á á¨á°á á á˝ááľ á¨ááłá ááá°-á˝áá áá áĽáť á°áááŠáá
ááá¨á á áĽáŤá áľáááá áááá áĽá ááá áá á¨áľ áŤáá ááá˝ á á ááá ááá áĽáť áľáĽá˘
**á¨á°á á ááłá ááá°-á˝áá:**
[á
á˝ 15 áááἠááĽá 80202]
... (á¨á°á á á˝ááľ ááłá á˝áá) ...
**áĽáŤá:**
á á
á˝ 15ᣠáááἠááĽá 80202 á¨á°áááá á á¨áááአáá ááłá áá áá á?<end_of_turn>
<start_of_turn>model
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
repetition_penalty=1.1
)
answer = tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True)
print(answer)
đď¸ Citation & Authorship
Developed by Getachew Getu as part of the Amharic Legal RAG Research Project.
- Downloads last month
- 46