Giter VIP home page Giter VIP logo

vibert's People

Contributors

phuonglh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vibert's Issues

Cách sử dụng tokenizer của thư viện Transformers để encode input

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]

Encode & decode tiếng Việt có dấu

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?
image

Anh hướng dẫn giúp em nhé. Cảm ơn anh rất nhiều :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.