huggingface / huggingface/course

Small inconsistency in Chapter 2, Part 3 example

Open Beginner friendly
#1,269 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
MDX
Stars
4.2k
Forks
1.4k
Avg merge
13m
Merged PRs (30d)
1

Description

I noticed a small inconsistency at the end of Chapter 2, Part 3.

The example shows:

encoded_sequences = [
[...], # length 16
[...], # length 8
]

model_inputs = torch.tensor(encoded_sequences)

Since the two sequences have different lengths, torch.tensor(encoded_sequences) will raise an error because tensors require all rows to have the same length.

A simple fix would be to make encoded_sequences rectangular by padding the shorter sequence before converting it to a tensor. This would make the example consistent with the explanation.

Thanks for the great course!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in Chapter 2, Part 3 and locate the example containing encoded_sequences and torch.tensor(encoded_sequences). Verify the sequence lengths and update the example so the sequences are rectangular before tensor conversion; done means the example matches the explanation and no longer raises a shape error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.