Text Classification
Transformers
PyTorch
Safetensors
Polish
roberta
feature-extraction
text-embeddings-inference
Instructions to use hplisiecki/polemo_intensity with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hplisiecki/polemo_intensity with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="hplisiecki/polemo_intensity")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("hplisiecki/polemo_intensity") model = AutoModel.from_pretrained("hplisiecki/polemo_intensity", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -62,25 +62,23 @@ First run
|
|
| 62 |
|
| 63 |
```bash
|
| 64 |
git clone https://huggingface.co/hplisiecki/polemo_intensity
|
|
|
|
| 65 |
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
```python
|
|
|
|
| 71 |
from transformers import AutoTokenizer
|
| 72 |
-
import torch
|
| 73 |
-
|
| 74 |
-
# Load the tokenizer
|
| 75 |
-
tokenizer = AutoTokenizer.from_pretrained("hplisiecki/polemo-intensity")
|
| 76 |
-
|
| 77 |
-
# Load the model
|
| 78 |
-
model = Model.from_pretrained("hplisiecki/polemo-intensity")
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
inputs = tokenizer("This is a test input.", return_tensors="pt")
|
| 82 |
outputs = model(inputs['input_ids'], inputs['attention_mask'])
|
| 83 |
|
| 84 |
# Print out the emotion ratings
|
| 85 |
for emotion, rating in zip(['Happiness', 'Sadness', 'Anger', 'Disgust', 'Fear', 'Pride', 'Valence', 'Arousal'], outputs):
|
| 86 |
-
print(f"{emotion}: {rating.item()}")
|
|
|
|
|
|
| 62 |
|
| 63 |
```bash
|
| 64 |
git clone https://huggingface.co/hplisiecki/polemo_intensity
|
| 65 |
+
```
|
| 66 |
|
| 67 |
+
in order to clone the repository. Because of the custom model class, this model cannot be run with the usual huggingface Model setups.
|
| 68 |
|
| 69 |
+
Proceed as follows:
|
|
|
|
| 70 |
|
| 71 |
```python
|
| 72 |
+
from polemo_intensity.model_script import Model
|
| 73 |
from transformers import AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
model_directory = "polemo_intensity" # Update this path
|
| 76 |
+
model = Model.from_pretrained(model_directory)
|
| 77 |
+
tokenizer = AutoTokenizer.from_pretrained(model_directory)
|
| 78 |
inputs = tokenizer("This is a test input.", return_tensors="pt")
|
| 79 |
outputs = model(inputs['input_ids'], inputs['attention_mask'])
|
| 80 |
|
| 81 |
# Print out the emotion ratings
|
| 82 |
for emotion, rating in zip(['Happiness', 'Sadness', 'Anger', 'Disgust', 'Fear', 'Pride', 'Valence', 'Arousal'], outputs):
|
| 83 |
+
print(f"{emotion}: {rating.item()}")
|
| 84 |
+
```
|