viT5_han-vie_v1.1 / README.md
haruyuu's picture
Update README.md
5cc0c75
|
raw
history blame
2.01 kB
metadata
license: apache-2.0
language:
  - vi
  - zh
metrics:
  - bleu
library_name: transformers
pipeline_tag: translation

viT5 for Sino-Vietnamese transliteration

Finetuned model from viT5 for Chinese MMORPG translation.

Model Description

Enhanced version from version 1.0 with larger dataset.

Uses

Default

Step 1: Map all Chinese word from original text to Sino-Vietnamese with map.json file

with open('map.json', encoding = 'utf-8') as f:
    map = json.load(f)
global map

def mapping(text):
    for i in text:
        try:
            x = ' ' + map[i] + ' '
            text = text.replace(i, x)
        except:
            continue
    return text.strip()

input_text = mapping('“ 早就知道叶微情是卧底了,于是将计就计,想要趁机嫁祸。 ” 的正确证物是:')

Step 2: Load model and generate

from transformers import T5ForConditionalGeneration, T5Tokenizer

model = T5ForConditionalGeneration.from_pretrained('haruyuu/viT5_han-vie_v1.1')
tokenizer = T5Tokenizer.from_pretrained('haruyuu/viT5_han-vie_v1.1')

input_ids = tokenizer.encode(input_text, return_tensors="pt")
translated_ids = model.generate(input_ids)
translated_text = tokenizer.decode(translated_ids[0], skip_special_tokens=True)

print("Chinese Input:", input_text)
print("\nVietnamese Translation:", translated_text)

Training Data

450k rows of system notifications, names and conversations translated from Chinese MMORPG games.