Views
No views yet

🇱🇹 First open-source Lithuanian translation model based on MiniCPM5 architecture.

1# Clone repository
2git clone https://huggingface.co/spaces/ZygAI/ZygAI-Translate-Lithuanian-DEMO
3cd ZygAI-Translate-Lithuanian-DEMO
4
5# Create and activate Python environment
6python -m venv env
7source env/bin/activate
8
9# Install dependencies and run
10pip install -r requirements.txt
11python app.py1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5base_model = "openbmb/MiniCPM5-1B"
6lora_model = "ZygAI/ZygAI-OSS-Translate-Lithuanian"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model)
9model = AutoModelForCausalLM.from_pretrained(base_model, dtype=torch.float16)
10model = PeftModel.from_pretrained(model, lora_model)
11model.eval()
12
13def translate(text):
14 prompt = f"### Instruction:\n{text}\n### Response:\n"
15 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
16 with torch.no_grad():
17 outputs = model.generate(**inputs, max_new_tokens=128)
18 result = tokenizer.decode(outputs[0], skip_special_tokens=True)
19 return result.split("### Response:\n")[-1]
20
21print(translate("Hello, how are you?"))
22# → Labas pasaulis
23print(translate("How are you?"))
24# → O kaip jūs?| Parameter | Value |
|---|---|
| Base model | openbmb/MiniCPM5-1B |
| Dataset | Helsinki-NLP/opus-100 (en-lt) |
| Training samples | 50,000 |
| Method | SFT + LoRA (PEFT) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| Epochs | 3 |
| Batch size | 4 |
| Max sequence length | 256 |
| Hardware | NVIDIA A100 SXM |
| Framework | TRL + Transformers |
1@software{vonwerra2020trl,
2 title = {{TRL: Transformers Reinforcement Learning}},
3 author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
4 license = {Apache-2.0},
5 url = {https://github.com/huggingface/trl},
6 year = {2020}
7}