Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions chapters/en/chapter2/3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.