Downloads · 30 days
12
6% of all-time downloads
Akaash1/NLP_mt5
NLP_mt5 is a text generation model from Akaash1. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This model converts Khmer number words to digits using a fine-tuned mT5-small model.
Downloads · 30 days
12
6% of all-time downloads
All-time downloads
190
Public
Parameters
300M
1.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.2 GB · 100%
From the Hugging Face model README
This model converts Khmer number words to digits using a fine-tuned mT5-small model.
from transformers import MT5ForConditionalGeneration, MT5Tokenizer
# Load model and tokenizer
model_name = "Akaash1/NLP_mt5"
tokenizer = MT5Tokenizer.from_pretrained(model_name)
model = MT5ForConditionalGeneration.from_pretrained(model_name)
# Normalize Khmer number words
text = "វ័យ ត្រឹម ដប់ ប្រាំបី ឆ្នាំ"
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, num_beams=4, max_length=256)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result) # Output: វ័យ ត្រឹម 18 ឆ្នាំ
import torch
from transformers import MT5ForConditionalGeneration, MT5Tokenizer
class KhmerITN:
def __init__(self, model_name="Akaash1/NLP_mt5"):
self.tokenizer = MT5Tokenizer.from_pretrained(model_name)
self.model = MT5ForConditionalGeneration.from_pretrained(model_name)
self.device = "cuda" if torch.cuda.is_available() else "cpu"
self.model.to(self.device)
self.model.eval()
def normalize(self, text, num_beams=4):
inputs = self.tokenizer(text, return_tensors="pt", max_length=256, truncation=True)
inputs = {k: v.to(self.device) for k, v in inputs.items()}
with torch.no_grad():
outputs = self.model.generate(**inputs, num_beams=num_beams, max_length=256)
return self.tokenizer.decode(outputs[0], skip_special_tokens=True)
# Use it
itn = KhmerITN()
result = itn.normalize("ឆ្នាំ ពីរ ពាន់ ដប់ ប្រាំបី")
print(result) # Output: ឆ្នាំ 2013
| Input (Khmer words) | Output (with digits) |
|---|---|
| វ័យ ត្រឹម ដប់ ប្រាំបី ឆ្នាំ | វ័យ ត្រឹម 18 ឆ្នាំ |
| ឆ្នាំ ពីរ ពាន់ ដប់ ប្រាំបី | ឆ្នាំ 2013 |
| តារា វ័យ សាមសិប បួន ឆ្នាំ | តារា វ័យ 34 ឆ្នាំ |
| មាន សរុប ម្ភៃ មួយ នាក់ | មាន សរុប 21 នាក់ |
| ក្នុង រយៈពេល ដប់ ឆ្នាំ | ក្នុង រយៈពេល 10 ឆ្នាំ |
The model can convert various Khmer number expressions:
If you use this model, please cite:
@misc{khmer-itn-mt5,
title={Khmer Inverse Text Normalization using mT5},
author={Your Name},
year={2024},
url={https://huggingface.co/Akaash1/NLP_mt5}
}
[Your Name]
For questions or feedback, please open an issue on the model repository.