Knowledge Graph — Coursera NotesAcademic disciplinesInformation Technology / Computer ScienceArtificial IntelligenceLarge Language ModelsFoundation Models

Hugging Face Transformers

service · part of Foundation Models

A library providing pretrained models and tools for natural language processing tasks.

It also includes the Trainer and TrainingArguments classes for fine-tuning, and simplifies loading models and adapting them to specific tasks.

BertForSequenceClassification is a BERT model variant with a classification head for sequence classification tasks. It can be loaded with a specified number of labels (num_labels) and used for fine-tuning with PEFT.

model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=3)

TrainingArguments configures training parameters such as output directory, number of epochs, batch size, evaluation strategy, and learning rate. It is passed to the Trainer to control the fine-tuning process.

training_args = TrainingArguments(
    output_dir='./results',
    num_train_epochs=3,
    per_device_train_batch_size=16,
    evaluation_strategy="epoch",
)

Trainer is a Hugging Face class that handles training and evaluation loops. It takes a model, training arguments, and datasets, and provides methods like train() and evaluate() for fine-tuning and performance assessment.

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_data,
    eval_dataset=val_data,
)
trainer.train()

Inside Hugging Face Transformers (4)

Connections

This is the text view of an interactive 3D knowledge graph — open this page with JavaScript enabled to explore it visually.

🧠 Knowledge Graph

Select a node

The owner's editing tools — shown here so you can see how the graph is grown, but read-only.

Click a bubble to drill in · click again to collapse · drag to move around