This model is a fine-tuned version of
ilsp/Llama-Krikri-8B-Instruct for translating
Ancient Greek to
Modern Greek.
This model was trained by Spyridon Mavromatis at the Institute for Language and Speech Processing (ILSP), "Athena" RC, and the National and Kapodistrian University of Athens (NKUA) as part of an M.Sc. thesis.
Built with
Llama. This model is a derivative of
Llama‑Krikri‑8B‑Instruct, which is itself built on
Llama-3.1-8B. Use of this model is governed by the Llama 3.1 Community License Agreement.
-
Base Model: ilsp/Llama-Krikri-8B-Instruct (Llama 3 architecture)
-
Method: QLoRA (Rank=32, Alpha=32)
-
Training Data: ~130k sentence pairs from the AG-MG Corpus.
You need to load the base model and then load the Peft adapter. This model requires the exact system prompt used during training for optimal results.
1
2import torch
3
4from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
5
6from peft import PeftModel
7
8# 1. Setup paths
9
10base_model_id = "ilsp/Llama-Krikri-8B-Instruct"
11
12adapter_id = "ilsp/llama-krikri-8b-ag-mg-qlora"
13
14# 2. Load Tokenizer
15
16tokenizer = AutoTokenizer.from_pretrained(adapter_id, use_fast=True)
17
18# 3. Load Base Model (4-bit)
19
20bnb_config = BitsAndBytesConfig(
21
22 load_in_4bit=True,
23
24 bnb_4bit_quant_type="nf4",
25
26 bnb_4bit_compute_dtype=torch.bfloat16,
27
28 bnb_4bit_use_double_quant=True
29
30)
31
32base_model = AutoModelForCausalLM.from_pretrained(
33
34 base_model_id,
35
36 quantization_config=bnb_config,
37
38 device_map="auto",
39
40 attn_implementation="eager" # or "sdpa" if available
41
42)
43
44# 4. Load Adapter
45
46model = PeftModel.from_pretrained(base_model, adapter_id)
47
48model.eval()
49
50# 5. Define Prompt & Inference
51
52sys_prompt = "Είσαι ακριβές σύστημα μεταφράσεων. Μεταφράζεις από Αρχαία Ελληνικά (πολυτονικό) σε Νέα Ελληνικά. Δώσε μόνο τη μετάφραση."
53
54text = "Ὦ ξεῖν', ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε κείμεθα."
55
56messages = [
57
58 {"role": "system", "content": sys_prompt},
59
60 {"role": "user", "content": f"Μετάφρασε στα Νέα Ελληνικά:\n{text}"}
61
62]
63
64prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
65
66inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
67
68with torch.no_grad():
69
70 outputs = model.generate(
71
72 **inputs,
73
74 max_new_tokens=256,
75
76 do_sample=False, # Greedy decoding
77
78 temperature=0.0,
79
80 repetition_penalty=1.05,
81
82 eos_token_id=[tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
83
84 )
85
86# Decode only the new tokens
87
88generated_text = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
89
90print(generated_text.strip())
Evaluated on the 2,000 sentence-pairs Test Set (Attic & Koine Hellenistic dialects).
Evaluated on the 250 sentence-pairs Stress Set (Ionic, Doric, Homeric dialects).
1@inproceedings{mavromatis-etal-2026-ancient,
2 title = {Ancient Greek to Modern Greek Machine Translation: A Novel Benchmark and Fine-Tuning Experiments on LLMs and NMT Models},
3 author = {Mavromatis, Spyridon and Sofianopoulos, Sokratis and Prokopidis, Prokopis and Giagkou, Maria},
4 booktitle = {Proceedings of the Fifteenth Language Resources and Evaluation Conference (LREC 2026)},
5 month = {May},
6 year = {2026},
7 pages = {8685--8698},
8 address = {Palma, Mallorca, Spain},
9 publisher = {European Language Resources Association (ELRA)},
10 editor = {Piperidis, Stelios and Bel, Núria and van den Heuvel, Henk and Ide, Nancy and Krek, Simon and Toral, Antonio},
11 doi = {10.63317/4cdk64dgm2w9}
12}