Safetensors
gemma2

Model Card for GaMS2-27B-GRPO-Translator

GaMS2-27B-GRPO-Translator is a fine-tuned version of GaMS2-27B model, specialized for English to Slovene translation. The model was specilaized through 3 training phases (each phase trained a LoRA adapter):

  • SFT on 1000 high-quality English to Slovene translation examples (this stage trained the model to use proper chat template).
  • DPO on approximately 1500 on-policy examples (the DPO was used to fix the errors such as incorrect formating, truncation and failing to stop)
  • GRPO on 100k examples (the main training stage - different reward functions, such as COMET, length score and language score).

image/png

Basic information

  • Developed by: team of researchers at the University of Ljubljana, Faculty for Computer and Information Science. Team members: Domen Vreš, Nikola Sekulovski, Dario Vajda, Iztok Lebar Bajec and Marko Robnik-Šikonja.
  • Languages: Specialized for English to Slovene translation
  • Base model: cjvt/GaM2-27B
  • License: Gemma

Usage

The model can be used as a standard chat/instruct model. It uses the same chat template as cjvt/GaMS2-27B-Instruct

Prompt

We trained the model using the following translation prompt. We suggest the same prompt is used during the inference.

Si profesionalni prevajalec iz angleščine v slovenščino. Tvoja naloga je ustvariti visoko kakovostne prevode, ki so naravni, tekoči in natančni. Izogibaj se dobesednim prevodom, ki zvenijo nenaravno. Upoštevaj kontekst, idiome in kulturne reference. Ne dodajaj nobenih dodatnih informacij ali komentarjev, samo prevod.

Prevedi podano angleško besedilo v slovenščino.

{{ English text }}

Transformers library

The model can be run through pipeline API using the following code:

from transformers import pipeline
model_id = "cjvt/GaMS2-27B-GRPO-Translator"
model = pipeline(
    "text-generation",
    model=model_id,
    device_map="cuda" # replace with "mps" to run on a Mac device
)
# Example of response generation
prompt_template = "Si profesionalni prevajalec iz angleščine v slovenščino. Tvoja naloga je ustvariti visoko kakovostne prevode, ki so naravni, tekoči in natančni. Izogibaj se dobesednim prevodom, ki zvenijo nenaravno. Upoštevaj kontekst, idiome in kulturne reference. Ne dodajaj nobenih dodatnih informacij ali komentarjev, samo prevod.\n\nPrevedi podano angleško besedilo v slovenščino."
english_text = "This is the text to translate."
message = [{"role": "user", "content": f"{prompt_template}\n\n{english_text}"}]
response = model(message, max_new_tokens=512)
print("Transltion:", response[0]["generated_text"][-1]["content"])

vLLM library

The model is supported in vLLM the same way as GaMS2-27B-Instruct (and Gemma 2). Example vLLM code:

from vllm import LLM, SamplingParams
model = LLM("cjvt/GaMS2-27B-GRPO-Translator")
sampling_params = SamplingParams(
    n=1,
    temperature=0.2,
    top_p=0.9,
    max_tokens=1024
)
prompt_template = "Si profesionalni prevajalec iz angleščine v slovenščino. Tvoja naloga je ustvariti visoko kakovostne prevode, ki so naravni, tekoči in natančni. Izogibaj se dobesednim prevodom, ki zvenijo nenaravno. Upoštevaj kontekst, idiome in kulturne reference. Ne dodajaj nobenih dodatnih informacij ali komentarjev, samo prevod.\n\nPrevedi podano angleško besedilo v slovenščino."
english_text = "This is the text to translate."
message = [{"role": "user", "content": f"{prompt_template}\n\n{english_text}"}]
response = model.chat(messages, sampling_params)
print("Translation:", response[0].outputs[0].text)

NOTE: We observed the degradation in performance when using this model with FlashInfer and ROCM Attention. We strongly advice usage of FlashAttention 2 (on majority of devices) or 3 (on Hopper devices).

Downloads last month
-
Safetensors
Model size
27B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for cjvt/GaMS2-27B-GRPO-Translator

Base model

cjvt/GaMS2-27B
Finetuned
(1)
this model

Collection including cjvt/GaMS2-27B-GRPO-Translator