alex-shvets commited on
Commit
fd36f4b
·
verified ·
1 Parent(s): 5b42daa

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +10 -6
README.md CHANGED
@@ -27,17 +27,21 @@ Here is how to use this model:
27
  >>> from transformers import pipeline
28
  >>> model_name = "roberta-large-emopillars-contextual"
29
  >>> threshold = 0.5
30
- >>> emotions = ["admiration", "amusement", "anger", "annoyance", "approval", "caring", "confusion",
31
- >>> "curiosity", "desire", "disappointment", "disapproval", "disgust", "embarrassment",
32
- >>> "excitement", "fear", "gratitude", "grief", "joy", "love", "nervousness", "optimism",
33
- >>> "pride", "realization", "relief", "remorse", "sadness", "surprise", "neutral"]
 
 
34
  >>> label_to_emotion = dict(zip(list(range(len(emotions))), emotions))
35
  >>> device = torch.device("cuda" if torch.cuda.is_available() else "CPU")
36
  >>> pipe = pipeline("text-classification", model=model_name, truncation=True,
37
  >>> return_all_scores=True, device=-1 if device.type=="cpu" else 0)
38
  >>> # input in a format f"{context} {character}: \"{utterance}\""
39
- >>> utterances_in_contexts = ["A user watched a video of a musical performance on YouTube. This user expresses an opinion and thoughts. User: \"Ok is it just me or is anyone else getting goosebumps too???\"",
40
- >>> "User: \"Sorry\", Conversational agent: \"Sorry for what??\", User: \"Don’t know what to do\""]
 
 
41
  >>> outcome = pipe(utterances_in_contexts)
42
  >>> dominant_classes = [
43
  >>> [prediction for prediction in example if prediction['score'] >= threshold]
 
27
  >>> from transformers import pipeline
28
  >>> model_name = "roberta-large-emopillars-contextual"
29
  >>> threshold = 0.5
30
+ >>> emotions = [
31
+ >>> "admiration", "amusement", "anger", "annoyance", "approval", "caring", "confusion",
32
+ >>> "curiosity", "desire", "disappointment", "disapproval", "disgust", "embarrassment",
33
+ >>> "excitement", "fear", "gratitude", "grief", "joy", "love", "nervousness", "optimism",
34
+ >>> "pride", "realization", "relief", "remorse", "sadness", "surprise", "neutral"
35
+ >>> ]
36
  >>> label_to_emotion = dict(zip(list(range(len(emotions))), emotions))
37
  >>> device = torch.device("cuda" if torch.cuda.is_available() else "CPU")
38
  >>> pipe = pipeline("text-classification", model=model_name, truncation=True,
39
  >>> return_all_scores=True, device=-1 if device.type=="cpu" else 0)
40
  >>> # input in a format f"{context} {character}: \"{utterance}\""
41
+ >>> utterances_in_contexts = [
42
+ >>> "A user watched a video of a musical performance on YouTube. This user expresses an opinion and thoughts. User: \"Ok is it just me or is anyone else getting goosebumps too???\"",
43
+ >>> "User: \"Sorry\", Conversational agent: \"Sorry for what??\", User: \"Don’t know what to do\""
44
+ >>> ]
45
  >>> outcome = pipe(utterances_in_contexts)
46
  >>> dominant_classes = [
47
  >>> [prediction for prediction in example if prediction['score'] >= threshold]