Views
No views yet
CohereLabs/tiny-aya-base fine‑tuned to translate between English and Classical Syriac. The model was trained using the LARK (Language-Agnostic Rule-Guided Knowledge-Constrained Generation) framework, which adds a constraint‑aware loss to encourage grammatical correctness (subject‑verb agreement, construct state chains) based on a knowledge base of Syriac morphological rules extracted from a grammar textbook.### Instruction:
Translate the following English text to Syriac.
### Input:
{English sentence}
### Response:
{Syriac translation}CohereLabs/tiny-aya-base (3.35B parameters).unsloth.q_proj, k_proj, v_proj, o_proj.paged_adamw_8bit.| Metric | Score |
|---|---|
| Subject‑verb agreement accuracy (gender & number) | 36.0% |
| Morphological violation rate (percentage of tokens violating any rule in the KB) | 9.9% |
pip install peft transformers torch1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5base_model_name = "CohereLabs/tiny-aya-base"
6adapter_name = "aaronmat1905/malfono-lark-lora"
7
8base_model = AutoModelForCausalLM.from_pretrained(
9 base_model_name,
10 device_map="auto",
11 torch_dtype=torch.float16,
12)
13tokenizer = AutoTokenizer.from_pretrained(base_model_name)
14tokenizer.pad_token = tokenizer.eos_token
15
16model = PeftModel.from_pretrained(base_model, adapter_name)
17model.eval()1def translate_to_syriac(english_sentence: str, max_new_tokens: int = 60) -> str:
2 prompt = f"### Instruction:\nTranslate the following English text to Syriac.\n\n### Input:\n{english_sentence}\n\n### Response:\n"
3 inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512).to(model.device)
4 with torch.no_grad():
5 outputs = model.generate(
6 **inputs,
7 max_new_tokens=max_new_tokens,
8 temperature=0.2,
9 do_sample=True,
10 top_p=0.9,
11 repetition_penalty=1.2,
12 pad_token_id=tokenizer.eos_token_id,
13 )
14 response = tokenizer.decode(outputs[0], skip_special_tokens=True)
15 if "### Response:\n" in response:
16 response = response.split("### Response:\n")[-1].strip()
17 return response.split("\n")[0]
18
19print(translate_to_syriac("Peace be with you."))"Translate the following Syriac text to English." and swap input/output.