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
Download code/src/metrics.py from igandarillas/supcon: direct link, hf CLI and curl.
- Browser
- Download file 670 Bytes
-
https://huggingface.co/igandarillas/supcon/resolve/main/code/src/metrics.py
- Command line
-
hf download hf://igandarillas/supcon/code/src/metrics.py
-
curl -L -o metrics.py https://huggingface.co/igandarillas/supcon/resolve/main/code/src/metrics.py
670 Bytes
| 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} |