Downloads · 30 days
21
14% of all-time downloads
haruyuu/viT5_han-vie_v1.1
viT5_han-vie_v1.1 is a translation model from haruyuu. Use it when you need text moved from one language to another. It is set up for transformers. The card lists the license as apache-2.0.
Finetuned model from viT5 for Chinese MMORPG translation.
Downloads · 30 days
21
14% of all-time downloads
All-time downloads
152
Public
Repo size
4.1 GB
Likes
0
Public
Click a slice to open those files.
.bin904 MB · 67%
From the Hugging Face model README
Finetuned model from viT5 for Chinese MMORPG translation.
Enhanced version from version 1.0 with larger dataset.
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("Vietnamese Translation:", translated_text) # 'Ai biết, nửa đêm về nhà phát hiện ra mình quên chìa khóa, trong nhà không có ai, lúc này nguyện vọng lớn nhất của ngươi là gì? Đáp án chính xác là gì?'
print("\nTruth:", truth) # 'Ai biết nửa đêm về nhà phát hiện mình quên chìa khoá , trong nhà lại không có ai thì lúc này muốn nhất là cái gì ? Câu trả lời là gì thế anh em ?'
from fastT5 import get_onnx_runtime_sessions, OnnxT5
from transformers import T5Config, AutoTokenizer, T5ForConditionalGeneration
quant_model_paths= tuple(['viT5_han-vie_v1-encoder-quantized.onnx',
'viT5_han-vie_v1-decoder-quantized.onnx',
'viT5_han-vie_v1-init-decoder-quantized.onnx'])
model_sessions = get_onnx_runtime_sessions(quant_model_paths)
model = OnnxT5('haruyuu/viT5_han-vie_v1.1', model_sessions)
input_text = mapping('谁知道 “ 你三更半夜回家发现自己忘记带钥匙,家里又没有其他人在,这时你最大的愿望是什么? ” 的正确答案是什么呀?')
input_ids = tokenizer.encode(input_text, return_tensors="pt")
translated_ids = model.generate(input_ids,
num_beams = 6,
max_length = 512,
bad_words_ids = [[6270]])
translated_text = tokenizer.decode(translated_ids[0], skip_special_tokens=True)
print("Vietnamese Translation:", translated_text) # 'Ai biết, nửa đêm về nhà phát hiện ra mình quên chìa khóa, trong nhà không có ai, lúc này nguyện vọng lớn nhất của ngươi là gì? Đáp án chính xác là gì?'
print("\nTruth:", truth) # 'Ai biết nửa đêm về nhà phát hiện mình quên chìa khoá , trong nhà lại không có ai thì lúc này muốn nhất là cái gì ? Câu trả lời là gì thế anh em ?'
450k rows of system notifications, names and conversations translated from Chinese MMORPG games.