Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconIdatlassian-flag_on
panelIcon:flag_on:
panelIconText:flag_on:
bgColor#FFEBE6

There are function(s) to be completed in this section!

...

In this part of the assignment, you’ll complete the train_model function in train.py, which trains a BERT-based model for intent classification and slot filling. This task will deepen your understanding of the training process, how loss functions work for multi-task learning, and how to use backpropagation to optimize a model.

Note

Under utils folder make a folder called checkpoints for your checkpoints.

Do not add your model-checkpoint to github, do not try and push it. It is too big. Add it to your gitignore file or skip it when committing. At the end of the course we will tell you how to upload everything.

...

Understanding Training

For more general and preliminary information check out: Preliminaries and Quiz Materials.

  1. What is Training?

    • Training is the process of optimizing a model to make better predictions by minimizing a loss function.

    • For your BERT-based model:

      • Intent Classification: Predict the intent of a user query (e.g., addFilter or recipeRequest).

      • Slot Filling: Assign BIO tags to each token in the query (e.g., B-shortTimeKeyWord for "fast").

  2. How Does the Training Loop Work?

    • Forward Pass: The input data flows through the model to generate predictions.

    • Loss Calculation: The predictions are compared with ground truth labels to calculate the loss.

    • Backward Pass (Backpropagation): The model adjusts its weights based on the loss to improve predictions in the next iteration.

  3. What Are We Optimizing?

    • Intent Loss: Measures how well the model predicts the intent.

    • Slot Loss: Measures how well the model predicts slot tags for each token.

  4. Why Do We Use Two Loss Functions?

    • Your model performs two tasks simultaneously, so you need separate losses for each task. These are combined to train the model in a balanced way.

...

Steps to Complete the train_model Function

The train_model function is incomplete, and your task is to fill in the missing pieces. This function is the backbone of the training process for a dual-task model that handles intent classification and slot filling. Through this exercise, you’ll learn how to integrate loss functions, perform forward passes, and optimize a model’s weights effectively.

...