Quantifying the Carbon Emissions of Machine Learning
Paper • 1910.09700 • Published • 45
How to use argilla/end2end_agnews with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="argilla/end2end_agnews") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("argilla/end2end_agnews")
model = AutoModelForSequenceClassification.from_pretrained("argilla/end2end_agnews")This model has been created with Argilla, trained with Transformers.
Training the model using the ArgillaTrainer:
# Load the dataset:
dataset = FeedbackDataset.from_argilla("...")
# Create the training task:
def formatting_func(sample):
text = sample["text"]
label = sample["label"][0]["value"]
return(text, label)
task = TrainingTask.for_text_classification(formatting_func=formatting_func)
# Create the ArgillaTrainer:
trainer = ArgillaTrainer(
dataset=dataset,
task=task,
framework="transformers",
model="bert-base-cased",
)
trainer.update_config({
"evaluation_strategy": "epoch",
"logging_dir": "./logs",
"logging_steps": 1,
"num_train_epochs": 1,
"output_dir": "textcat_model_transformers",
"use_mps_device": true
})
trainer.train(output_dir="None")
You can test the type of predictions of this model like so:
trainer.predict("This is awesome!")