fpt-corp / vibert Goto Github PK
View Code? Open in Web Editor NEWVietnamese BERT pre-trained model of FPT.AI
Vietnamese BERT pre-trained model of FPT.AI
Khi chạy đoạn code bên dưới thì em nhận được list id của các từ đã bị bỏ dấu so với câu đầu vào. Em muốn hỏi cách để encode và sử dụng thư viện cho đúng ạ. Em mong muốn encoded_ids là [2, 9, 10, 11, 3]. Em cảm ơn mọi người đã giải đáp ạ.
import torch
from transformers import AutoTokenizer, AutoModel
if __name__ == "__main__":
#model_name = "FPTAI/velectra-base-discriminator-cased"
model_name = "FPTAI/vibert-base-cased"
tokenizer = AutoTokenizer.from_pretrained(model_name)
vocab = tokenizer.get_vocab()
id2token = {idx: token for token, idx in vocab.items()}
word_ids = [9, 10, 11]
sent = tokenizer.decode(word_ids)
print(sent) # có là và
encoded_ids = tokenizer.encode(sent)
for word_id in encoded_ids:
print(word_id, id2token[word_id])
# 2 [CLS]
# 382 co
# 523 la
# 391 va
# 3 [SEP]
Dear anh @phuonglh ,
Em đang tìm hiểu cách sử dụng viBERT để làm thực nghiệm cho luận văn TN, em thấy trên cả git này lẫn huggingface đều không có sample code hướng dẫn encode & decode nên viết thử 1 đoạn encode & decode bằng AutoTokenizer và AutoModel, kết quả là nó chạy nhưng khi decode lại thì lại ra chuỗi tiếng Việt không dấu. Vậy không biết làm như nào để vẫn giữ được tiếng Việt có dấu vậy anh?
Anh hướng dẫn giúp em nhé. Cảm ơn anh rất nhiều :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.