GithubHelp home page GithubHelp logo

nlp-tasks's Introduction

NLP Tasks

以下為一些NLP的進階應用範例。

01 BERT_multiclass_TF_hub.ipynb

此範例說明如何使用TensorFlow Hub的BERT model來做multi-class的文章分類。[1]
訓練資料需要轉換成BERT可以接收的format,包含:

  • Tokenize文章中所有的單字以及標點符號。
  • 加上 [CLS] 和 [SEP] tokens 來標註文章的開始和結束。
  • 進一步將一些字分成 WordPieces (例: "calling" -> ["call", "##ing"])
  • 根據BERT的字典,將字mapping到字的index。
  • input_masks幫助區分tokens和padding elements,0代表padding elements。
  • segment_ids幫助區分不同的句子。因為在分類問題只有一個句子,所以所有的segment id都是一樣的。若有兩個句子時,第一個句子的所有字都會是0,第二個句子的所有字都會是1。

以下為將一篇文章轉成BERT格式的範例:
01
雖然此範例為英文文章分類,若要做中文分類,只要下載中文的model即可。[2][3]

02 BERT_QA.ipynb

此範例說明如何使用transformer的pre-trained BERT model來做question answering。[4]
輸入文章和問題即可得到答案。

03 BERT_QA_Chinese.ipynb

此範例說明如何使用中文的pre-trained BERT model來做question answering。[5]
輸入文章和問題即可得到答案。

References

[1] https://analyticsindiamag.com/step-by-step-guide-to-implement-multi-class-classification-with-bert-tensorflow/
[2] https://tfhub.dev/s?network-architecture=transformer&publisher=google
[3] https://tfhub.dev/google/bert_chinese_L-12_H-768_A-12/1
[4] https://huggingface.co/transformers/task_summary.html
[5] https://github.com/p208p2002/bert-question-answer

nlp-tasks's People

Contributors

openaifab avatar pttrazavi avatar

Watchers

James Cloos avatar

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.