--- tags: - translation - text2text-generation model-index: - name: flan-t5-base-opus-en-id-id-en results: [] license: apache-2.0 language: - en - id - multilingual metrics: - sacrebleu widget: - text: "translate Indonesia to English: Hai, Bagaimana kabarmu?" example_title: "tl_id2en_v1" - text: "translate to English: Hai, Bagaimana kabarmu?" example_title: "tl_id2en_v2" - text: "hey apa yang kamu lakukan terhadapnya ? in English" example_title: "tl_id2en_v3" - text: "translate English to Indonesia: Hello, How are you today?" example_title: "tl_en2id_v1" - text: "translate to Indonesia: Hello, How are you today?" example_title: "tl_en2id_v2" --- # flan-t5-base-opus-en-id-id-en This model consist to be Translator in multimodal Indonesia and English only. # Model Details ## Model Description - **Model type:** Language model - **Language(s) (NLP):** English, Indonesian - **License:** Apache 2.0 # Usage ## Using the Pytorch model ### Running the model on a CPU
Click to expand ```python from transformers import T5Tokenizer, T5ForConditionalGeneration tokenizer = T5Tokenizer.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en") model = T5ForConditionalGeneration.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en") input_text = "translate English to Indonesia: How old are you?" input_ids = tokenizer(input_text, return_tensors="pt").input_ids outputs = model.generate(input_ids) print(tokenizer.decode(outputs[0])) ```
### Running the model on a GPU
Click to expand ```python # pip install accelerate from transformers import T5Tokenizer, T5ForConditionalGeneration tokenizer = T5Tokenizer.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en") model = T5ForConditionalGeneration.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en", device_map="auto") input_text = "translate English to Indonesia: How old are you?" input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda") outputs = model.generate(input_ids) print(tokenizer.decode(outputs[0])) ```
### Running the model on a GPU using different precisions #### FP16
Click to expand ```python # pip install accelerate import torch from transformers import T5Tokenizer, T5ForConditionalGeneration tokenizer = T5Tokenizer.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-ene") model = T5ForConditionalGeneration.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en", device_map="auto", torch_dtype=torch.float16) input_text = "translate English to Indonesia: How old are you?" input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda") outputs = model.generate(input_ids) print(tokenizer.decode(outputs[0])) ```
#### INT8
Click to expand ```python # pip install bitsandbytes accelerate from transformers import T5Tokenizer, T5ForConditionalGeneration tokenizer = T5Tokenizer.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en") model = T5ForConditionalGeneration.from_pretrained("muvazana/flan-t5-base-opus-en-id-id-en", device_map="auto", load_in_8bit=True) input_text = "translate English to Indonesia: How old are you?" input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda") outputs = model.generate(input_ids) print(tokenizer.decode(outputs[0])) ```
### Training results | Training Loss | Epoch | Step | Validation Loss | Score | Counts | Totals | Precisions | Bp | Sys Len | Ref Len | Gen Len | |:-------------:|:-----:|:-----:|:---------------:|:-------:|:-----------------------:|:------------------------:|:--------------------------------------------------------------------------------:|:------:|:-------:|:-------:|:-------:| | 1.6959 | 0.55 | 4000 | 1.5776 | 30.6542 | [4414, 2368, 1345, 733] | [7417, 6417, 5426, 4519] | [59.511932047997846, 36.9019791179679, 24.78805750092149, 16.220402743969906] | 1.0 | 7417 | 7354 | 10.77 | | 1.4378 | 1.11 | 8000 | 1.4527 | 32.3772 | [4526, 2538, 1483, 834] | [7567, 6567, 5576, 4666] | [59.81234306858729, 38.647784376427595, 26.596126255380202, 17.873981997428203] | 1.0 | 7567 | 7354 | 10.885 | | 1.3904 | 1.66 | 12000 | 1.3961 | 33.8978 | [4558, 2559, 1494, 836] | [7286, 6286, 5295, 4383] | [62.55833104584134, 40.70951320394528, 28.21529745042493, 19.073693817020306] | 0.9907 | 7286 | 7354 | 10.569 | | 1.3035 | 2.21 | 16000 | 1.3758 | 34.9471 | [4609, 2628, 1546, 880] | [7297, 6297, 5306, 4392] | [63.16294367548308, 41.73415912339209, 29.136826234451565, 20.036429872495447] | 0.9922 | 7297 | 7354 | 10.591 | | 1.2994 | 2.77 | 20000 | 1.3685 | 35.0259 | [4617, 2627, 1550, 883] | [7288, 6288, 5297, 4382] | [63.350713501646545, 41.777989821882954, 29.261846328110252, 20.150616157005935] | 0.991 | 7288 | 7354 | 10.556 | ### Framework versions - Transformers 4.29.2 - Pytorch 2.0.1 - Datasets 2.13.1 - Tokenizers 0.13.3