아래로 당겨서 돌아가기
Question regarding Transformer's pipeline module [D]

Question regarding Transformer's pipeline module [D]

Question regarding Transformer's pipeline module [D]

from transformers import pipeline , DistilBertTokenizer , DistilBertModel model = DistilBertModel . from_pretrained ('distilbert-base-cased-distilled-squad') # Load a model that is already trained on Question Answering extractor = pipeline ("question-answering") def get_emotion_cause (text, emotion): question = f"Show the reason why the text convey {emotion} symptoms?" # The model extracts the 'cause' span from the text result = extractor(question = question, context = text) return result ['answ