From 93203ebc20e3b8b3f7399d524f12c5197ca9200f Mon Sep 17 00:00:00 2001 From: Omar El-Sayed Date: Sat, 13 Sep 2025 08:28:55 +0300 Subject: [PATCH] docs: Fix contradiction in padding explanation (Ch. 2) The section "Why is all of this necessary?" contained a logical contradiction. It showed two tokenized sequences of different lengths but then claimed the resulting array was "already of rectangular shape." This change corrects the text to accurately state that the sequences are of different lengths and cannot be directly converted to a tensor without padding. It also removes a misleading code snippet that would raise an error if executed. This improves the clarity and correctness of the course material. --- chapters/en/chapter2/3.mdx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/chapters/en/chapter2/3.mdx b/chapters/en/chapter2/3.mdx index cf6309eb1..a11cdc8b9 100644 --- a/chapters/en/chapter2/3.mdx +++ b/chapters/en/chapter2/3.mdx @@ -277,21 +277,11 @@ encoded_sequences = [ ] ``` -This is a list of encoded sequences: a list of lists. Tensors only accept rectangular shapes (think matrices). This "array" is already of rectangular shape, so converting it to a tensor is easy: +This is a list of encoded sequences: a list of lists. As you can see, the lengths of the tokenized outputs are different. Tensors require a "rectangular" shape (like a matrix), so you won't be able to convert this list of lists directly to a tensor. To resolve this, you need to use padding, as we saw earlier. -```py -import torch - -model_inputs = torch.tensor(encoded_sequences) -``` - -### Using the tensors as inputs to the model[[using-the-tensors-as-inputs-to-the-model]] +### Using the tensors as inputs to the model [[using-the-tensors-as-inputs-to-the-model]] -Making use of the tensors with the model is extremely simple — we just call the model with the inputs: - -```py -output = model(model_inputs) -``` +Making use of the tensors with the model is extremely simple... While the model accepts a lot of different arguments, only the input IDs are necessary. We'll explain what the other arguments do and when they are required later, but first we need to take a closer look at the tokenizers that build the inputs that a Transformer model can understand.