22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

For a complete list of available tasks, please check HuggingFace’s

pipeline [212] documentation.

Let’s run the first sentence of our training set through the sentiment analysis

pipeline:

sentence = train_dataset[0]['sentence']

print(sentence)

print(sentiment(sentence))

Output

And, so far as they knew, they were quite right.

[{'label': 'POSITIVE', 'score': 0.9998356699943542}]

Positive, indeed!

If you’re curious about which model is being used under the hood, you can check

the SUPPORTED_TASKS dictionary. For sentiment analysis, it uses the distilbertbase-uncased-finetuned-sst-2-english

model:

from transformers.pipelines import SUPPORTED_TASKS

SUPPORTED_TASKS['sentiment-analysis']

Output

{'impl': transformers.pipelines.text_classification

.TextClassificationPipeline,

'tf': None,

'pt': types.AutoModelForSequenceClassification,

'default': {'model': {'pt': 'distilbert-base-uncased-finetuned-sst-

2-english',

'tf': 'distilbert-base-uncased-finetuned-sst-2-english'}}}

"What about text generation?" Fine-Tuning with HuggingFace | 1003

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!