riturajpandey739 commited on
Commit
c7cde66
·
verified ·
1 Parent(s): 839d57c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -22
README.md CHANGED
@@ -59,25 +59,3 @@ result = classifier(text)
59
  # Output the result
60
  print(result)
61
  # Example Output: [{'label': 'LABEL_2', 'score': 0.9976001381874084}]
62
-
63
- #### OR
64
-
65
- from transformers import GPT2Tokenizer, GPT2ForSequenceClassification
66
- import torch
67
-
68
- # Load the model and tokenizer
69
- tokenizer = GPT2Tokenizer.from_pretrained("riturajpandey739/gpt2-sentiment-analysis-tweets")
70
- model = GPT2ForSequenceClassification.from_pretrained("riturajpandey739/gpt2-sentiment-analysis-tweets")
71
-
72
- # Tokenize the input text
73
- input_text = "This is a fantastic product! I highly recommend it."
74
- inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
75
-
76
- # Get model predictions
77
- with torch.no_grad():
78
- logits = model(**inputs).logits
79
-
80
- # Get the predicted class (0, 1, 2 for Negative, Neutral, Positive)
81
- predicted_class = torch.argmax(logits, dim=-1).item()
82
-
83
- print(f"Predicted Label: {predicted_class}")
 
59
  # Output the result
60
  print(result)
61
  # Example Output: [{'label': 'LABEL_2', 'score': 0.9976001381874084}]