Skip to content

Fix Week 14 BERT large lab: history key names, val_loss scalar, optimizer TODO guidance#15

Merged
raminmohammadi merged 1 commit into
raminmohammadi:mainfrom
ahnaf015:fix/lab14-large-issues
Jun 12, 2026
Merged

Fix Week 14 BERT large lab: history key names, val_loss scalar, optimizer TODO guidance#15
raminmohammadi merged 1 commit into
raminmohammadi:mainfrom
ahnaf015:fix/lab14-large-issues

Conversation

@ahnaf015

Copy link
Copy Markdown
Contributor

Three fixes so the Week 14 BERT large lab runs after TF/transformers version drift:

  • plot_training_history (helpers.py): per-output loss keys are now named after the model outputs (start_logits/end_logits) instead of the label columns (start_positions/end_positions). Updated the 6 history keys so plotting no longer raises KeyError.

  • main(): pass a scalar to test_model_loss instead of the full per-epoch val_loss list, using history.history['val_loss'][-1]. Fixes TypeError: '<=' not supported between 'list' and 'float'.

  • create_qa_model: clarified the optimizer TODO so students don't fall back to the 1e-3 default learning rate, with guidance on the expected init_lr magnitude (around 2e-5 to 5e-5).

Copilot AI review requested due to automatic review settings June 11, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates BERT QA training visualization and notebook scaffolding to align with current metric naming and improve assignment guidance/readability.

Changes:

  • Update plot_training_history to use *_logits_loss history keys.
  • Reformat notebook JSON (cell metadata/layout) and adjust a validation-loss test call to use the final epoch value.
  • Add/adjust inline instructional text (learning rate guidance).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
Labs/Week_14/BERT/helpers.py Switches plotted metric keys from *_positions_loss to *_logits_loss to match current training outputs.
Labs/Week_14/BERT/Assignment.ipynb Notebook JSON restructuring plus small logic/text edits (final val_loss passed to test; guidance text).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to +60
plt.plot(history.history['start_logits_loss'],
label='Start Position Training Loss')
plt.plot(history.history['val_start_positions_loss'],
plt.plot(history.history['val_start_logits_loss'],
Comment on lines +69 to +71
plt.plot(history.history['end_logits_loss'],
label='End Position Training Loss')
plt.plot(history.history['val_end_positions_loss'],
plt.plot(history.history['val_end_logits_loss'],
# 4. Combined Metrics
plt.subplot(2, 2, 4)
metrics = ['loss', 'start_positions_loss', 'end_positions_loss']
metrics = ['loss', 'start_logits_loss', 'end_logits_loss']
"id": "_ulwVvROU3EJ"
},
"source": [
"**Relection**\n",
}
},
"source": [
"In order to pass this test, **achieve validation loss atleast less than 2**."
@raminmohammadi raminmohammadi merged commit ab9cad9 into raminmohammadi:main Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants