Instructions to use igandarillas/supcon with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use igandarillas/supcon with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="igandarillas/supcon")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("igandarillas/supcon") model = AutoModelForMaskedLM.from_pretrained("igandarillas/supcon", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 670 Bytes
0797029 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import numpy as np
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
def compute_metrics_bce(eval_pred):
logits, labels = eval_pred
logits[logits>=0.5] = 1
logits[logits<0.5] = 0
predictions = logits.reshape(-1)
labels = labels.reshape(-1)
accuracy = accuracy_score(labels, predictions)
f1 = f1_score(labels, predictions, pos_label=1, average='binary')
precision = precision_score(labels, predictions, pos_label=1, average='binary')
recall = recall_score(labels, predictions, pos_label=1, average='binary')
return {"accuracy": accuracy, "f1": f1, "precision": precision, "recall": recall} |