1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

自然言語処理をtransformersでやってみた。

Last updated at Posted at 2020-04-04

自然言語のライブラリのtransformersで遊んでみた。
https://huggingface.co/transformers/main_classes/pipelines.html
https://github.com/huggingface/transformers

"I am happy"を入力するとポジティブと出力されました。

$pip install -q transformers

str = "I am happy"
nlp_sentence_classif(str)

[{'label': 'POSITIVE', 'score': 0.9998802}]

質問にも答えられます。
'I am a student who likes computer science.'という文章に対して'What do you like?'と質問すると'computer science'と返ってくる。

nlp = pipeline('question-answering')
nlp({
    'question': 'What do you like?',
    'context': 'I am a student who likes computer science.'
})

{'answer': 'computer science.',
 'end': 41,
 'score': 0.978939160814079,
 'start': 25}

いいですね。

このライブラリはデフォルトでなんのモデルを使っているのか探し出せなかった。(~_~メ)

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?