Python/TA
python: pytorch,transformer , pipline , 提问解答사용해보기
최무회
2020. 8. 13. 18:18
In [6]:
from __future__ import print_function
import ipywidgets as widgets
from transformers import pipeline
print('success')
In [7]:
nlp_sentence_classif = pipeline('sentiment-analysis')
nlp_sentence_classif('Such a nice weather outside !')
Out[7]:
In [12]:
nlp_token_class = pipeline('ner')
nlp_token_class('Hugging Face is a French company based in New-York.')
Out[12]:
In [13]:
nlp_qa = pipeline('question-answering')
nlp_qa(context='Hugging Face is a French company based in New-York.', question='Where is based Hugging Face ?')
Out[13]:
In [16]:
dir(pipeline)
Out[16]:
In [ ]:
from transformers import BertForSequenceClassification
model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
model.train()