Skip to content

Commit

Permalink
example using model with huggingface pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
lrei committed Sep 26, 2023
1 parent d6ee442 commit 7340f91
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pipeline_example.py
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")

0 comments on commit 7340f91

Please sign in to comment.