docs: Fix contradiction and misleading code in Chapter 2 Models section #1075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there!
I noticed a small but important error in the "Models" section of Chapter 2 of the course. This PR corrects it.
The Problem:
In the subsection "Why is all of this necessary?", the text demonstrates tokenizing two sentences that result in lists of different lengths. However, the following paragraph incorrectly states:
This "array" is already of rectangular shape, so converting it to a tensor is easy:
import torch
model_inputs = torch.tensor(encoded_sequences)
This is a contradiction, and the code snippet would fail, which could be confusing for learners.
The Solution:
I've updated the text to correctly identify that the lists are of different lengths and therefore require padding to be converted into a rectangular tensor. I also removed the erroneous code snippet.
This change makes the explanation clearer, more accurate, and reinforces the importance of the padding concept discussed just before this section.
Thanks for maintaining this wonderful course