Skip to content

Instantly share code, notes, and snippets.

@vincenttzc
vincenttzc / trainer_train_predict.py
Last active April 26, 2024 08:29
Huggingface Trainer train and predict
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score
import torch
from transformers import TrainingArguments, Trainer
from transformers import BertTokenizer, BertForSequenceClassification
from transformers import EarlyStoppingCallback