Edit model card

MT5-Small-FT-Chinese-Braille

📃 [Paper] • 💻 [Github] • 🤗 [Dataset] • ⚙️ [Model] • 🎬 [Demo]

This model is a fine-tuned version of the mt5-small model on the Chinese-Braille-10per-Tone dataset in https://huggingface.co/datasets/Violet-yo/Chinese-Braille-Dataset-10per-Tone. The training code can be found in the Github repository.

Inference

import evaluate
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

braille_text = "⠼⠓⠙⠁⠃⠉⠊ ⠓⠶⠞⠼ ⠚⠴⠺ ⠤ ⠘ ⠌⠢ ⠛⠊ ⠝⠩ ⠳⠬ ⠊⠓⠑ ⠛⠕⠛⠫ ⠵⠪ ⠵⠼⠛⠫ ⠟⠥⠅⠷⠐ ⠊⠛⠡ ⠃⠔ ⠌⠲⠛⠕ ⠛⠩⠱⠖ ⠙⠢ ⠟⠥⠅⠷⠇⠭ ⠃⠥⠟⠲ ⠱⠦⠇⠪⠐ ⠙⠧⠱ ⠃⠡ ⠍⠮⠳ ⠙⠖ ⠛⠕⠱⠼ ⠙⠢ ⠟⠼⠙⠥ ⠐⠆"
ground_truth = "841239\t黄腾 认为 : “ 这 几 年 由于 一些 国家 在 增加 出口 , 已经 把 中国 减少 的 出口量 补充 上来 , 但是 并 没有 到 过剩 的 程度 。\n"
model = AutoModelForSeq2SeqLM.from_pretrained("Violet-yo/mt5-small-ft-Chinese-Braille")
tokenizer = AutoTokenizer.from_pretrained("Violet-yo/mt5-small-ft-Chinese-Braille", use_fast=False)

inputs = tokenizer(
    braille_text, return_tensors="pt", max_length=280, padding=True, truncation=True
)
output_sequences = model.generate(
    input_ids=inputs["input_ids"],
    attention_mask=inputs["attention_mask"],
    max_new_tokens=300,
    num_beams=5,
)
translated_text = tokenizer.decode(output_sequences[0], skip_special_tokens=True)
print(f"{translated_text=}")
print(f"{ground_truth=}")
metric = evaluate.load("models/metrics/sacrebleu")
results = metric.compute(predictions=[translated_text], references=[[ground_truth]])
print(f"{results=}")

The output should be:

translated_text='841239 黄腾 认为 : “ 这 几 年 由于 一些 国家 在 增加 出口, 已经 把 中国 减少 的 出口量 补充 上来, 但是 并 没有 到 过剩 的 程度 。'
ground_truth='841239\t黄腾 认为 : “ 这 几 年 由于 一些 国家 在 增加 出口 , 已经 把 中国 减少 的 出口量 补充 上来 , 但是 并 没有 到 过剩 的 程度 。\n'
results={'score': 74.00206257221929, 'counts': [29, 25, 21, 17], 'totals': [32, 31, 30, 29], 'precisions': [90.625, 80.64516129032258, 70.0, 58.62068965517241], 'bp': 1.0, 'sys_len': 32, 'ref_len': 32}

Note that we didn't provide FastTokenizer because we added special tokens and FastTokenizer will output <UNK> tokens. Please set use_fast=False when loading the tokenizer.

Resources

Downloads last month
14
Safetensors
Model size
300M params
Tensor type
F32
·
Inference Examples
Inference API (serverless) is not available, repository is disabled.