Update README.md
Browse files
README.md
CHANGED
|
@@ -23,16 +23,24 @@ tags:
|
|
| 23 |
## How to Use
|
| 24 |
|
| 25 |
```python
|
|
|
|
| 26 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 27 |
|
| 28 |
-
# Load model and tokenizer from Hugging Face Hub
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained("harixn/IN-finbert")
|
| 30 |
model = AutoModelForSequenceClassification.from_pretrained("harixn/IN-finbert")
|
| 31 |
|
| 32 |
-
# Example inference
|
| 33 |
text = "The stock price of XYZ surged today."
|
| 34 |
inputs = tokenizer(text, return_tensors="pt")
|
| 35 |
outputs = model(**inputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```
|
| 37 |
|
| 38 |
## Training Data
|
|
|
|
| 23 |
## How to Use
|
| 24 |
|
| 25 |
```python
|
| 26 |
+
import torch
|
| 27 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 28 |
|
|
|
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained("harixn/IN-finbert")
|
| 30 |
model = AutoModelForSequenceClassification.from_pretrained("harixn/IN-finbert")
|
| 31 |
|
|
|
|
| 32 |
text = "The stock price of XYZ surged today."
|
| 33 |
inputs = tokenizer(text, return_tensors="pt")
|
| 34 |
outputs = model(**inputs)
|
| 35 |
+
|
| 36 |
+
# Get probabilities
|
| 37 |
+
probs = torch.softmax(outputs.logits, dim=1)
|
| 38 |
+
print("Probabilities:", probs)
|
| 39 |
+
|
| 40 |
+
# Get predicted class
|
| 41 |
+
pred_class = torch.argmax(probs, dim=1).item()
|
| 42 |
+
classes = ["negative", "neutral", "positive"]
|
| 43 |
+
print("Predicted class:", classes[pred_class])
|
| 44 |
```
|
| 45 |
|
| 46 |
## Training Data
|