Let's experience BERT in about 30 minutes.

Purpose

I want to move BERT for a moment, I tried an example that seems to move in an instant.

Selected example

At the following site https://www.ai-shift.jp/techblog/281

Using BERT, ** solving the TOEIC Part 5 problem **, an example was shown. It was about 30 lines of code, so I tried moving it.

Creating a problem

As a fill-in-the-blank problem An English Primer for Python 「introducing Python」 O'Reilly Media,Inc (First Edition 2016-02-26 Third release) I quoted the sentence and made a hole for each sentence.

text is a sentence with one hole (* is a hole). candidate is a candidate to fill in the blanks. About 5 pieces.

Below, I made three questions.

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"]

Added 1 question. This is not a Python primer, but a tensorflow lite? Or something Run-time error message.

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

Result announcement!

** All questions are correct ** as follows.

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

Summary

I felt the high level of BERT. I thought of candidates other than the correct answer, but there was a slight difference in power with BERT. .. .. (I would like to try again in Japanese or think about another problem. It's a chat, but I think it's very easy to say "should" or "would". .. .. ) If you have any comments, please let us know.

Recommended Posts

Let's experience BERT in about 30 minutes.
Sort in Python. Next, let's think about the algorithm.
Understand in 10 minutes Selenium
Selenium running in 15 minutes
About __all__ in python
Let's introduce the library currently used by engineers with about 3 years of experience in Django
Let's use def in python
Think about architecture in python
Let's find pi in Python
About "for _ in range ():" in python
Start in 5 minutes GIMP Python-Fu