Instructions to use rendchevi/roberta-per-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rendchevi/roberta-per-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="rendchevi/roberta-per-v0.1")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("rendchevi/roberta-per-v0.1") model = AutoModelForSequenceClassification.from_pretrained("rendchevi/roberta-per-v0.1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
def scaling(x, min_x, max_x, r1, r2):
# Scale data x (n_samples x 1) to [r1, r2]
x_s = x
x_s = (x_s - min_x) * (r2 - r1) / (max_x - min_x)
x_s = r1 + x_s
return x_s
def descaling(x_s, min_x, max_x, r1, r2):
# Re-scale data x (n_samples x 1) to [min_x, max_x]
x = x_s
x = (x - r1) * (max_x - min_x) / (r2 - r1) + min_x
return x
# Inference example
with torch.no_grad():
x = "They are equally important, absolutely, and just as real as each other."
x = tokenizer([x], return_tensors="pt", add_special_tokens=True, padding=True)
y_hat = model(**x.to(device)).logits
y_hat = torch.tanh(y_hat).cpu()
l_hat = descaling(y_hat, 1, 7, -1, 1)[0].numpy()
print(l_hat)
# [C, O, E, A, S]
# [6.0583944 4.4941516 1.6538751 5.5261126 4.725995 ]
- Downloads last month
- 4