Created
November 17, 2024 23:16
-
-
Save freedomtowin/500159ba690541039664a9800c78b71c to your computer and use it in GitHub Desktop.
Example of creating a Gist using Python
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
from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
import torch | |
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english") | |
model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english") | |
sentences = ["I love this movie!", "It was okay."] | |
# Tokenize and pad | |
encoded_input = tokenizer(sentences, padding=True, return_tensors="pt") | |
print(encoded_input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment