-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example using model with huggingface pipeline
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Example of inference with these models using a huggingface pipeline.""" | ||
|
||
from transformers import pipeline | ||
|
||
# Available models | ||
# lrei/roberta-large-emolit | ||
# lrei/roberta-base-emolit | ||
# lrei/distilroberta-base-emolit | ||
MODEL = "lrei/roberta-large-emolit" | ||
|
||
|
||
classifier = pipeline( | ||
"text-classification", | ||
model=MODEL, | ||
device=None, | ||
) | ||
|
||
texts = ["This is so much fun!", | ||
"I want to go back home to my dogs, i'll be happy to go back to them."] | ||
|
||
|
||
print() | ||
results = classifier(texts, top_k=None, function_to_apply="sigmoid") | ||
for t, r in zip(texts, results): | ||
print(t) | ||
print(r) | ||
print("\n") |