LoginSignup
1
3

More than 3 years have passed since last update.

BERTを30分ぐらいでちょっと経験してみる。

Last updated at Posted at 2020-05-17

目的

BERTを、ちょっと、動かしてみたいと思い、
ぐぐって、一瞬で動きそうな例を試してみた。

選んだ例

以下のサイトで、
https://www.ai-shift.jp/techblog/281

BERTを使って、TOEICのPart 5の問題を解く、例が示されていた。
30行程度のコードだったので、これを動かしてみた。

問題の作成

穴埋め問題として、
Pythonの英語の入門書
「introducing Python」 O'Reilly Media,Inc (First Edition 2016-02-26 Third release)
の文章を引用し、1文に対して、穴を一個開けてみた。

textが1個穴の開いた(*が穴)文章。
candidateが穴埋めの候補。5個程度。

以下、3問作ってみた。

text = "In Python, a lambda function is an anonymous function * as a single statement."
candidate = ["experssion", "used", "expressed", "using", "known"]
text = "Truncating integer division * you an integer answer."
candidate = ["gives", "makes", "presents", "takes", "give"]
text = "What * you get if you typed the following?"
candidate = ["did", "will", "would", "do", "are"]

1問追加。これは、Pythonの入門書ではなくて、tensorflow lite?か何かの
実行時のエラーメッセージ。

text = "Model provided has model identifier 'TFL2', * be 'TFL3'"
candidate = ["can", "could", "would", "shall", "should"]

結果発表!

以下のとおり、全問正解

(3, 'expressed')
(0, 'gives')
(0, 'would')
(0, 'should')

まとめ

BERTのレベルの高さを感じた。
正解以外の候補は、ワタシが考えたが、ちょっと、BERTとの力の差がありました。。。(日本語で再度トライするか、別の問題を考えたいと思います。
雑談ですが、shouldとかwouldとか、とっても、簡単なんでしょうね。。。)
コメントなどあれば、お願いします。

追記(2021/2/14)

以下の記事を書いた

BERTとワタシで、論文『Attention Is All You Need』に対する読解力を、競ってみた(全20問)。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3