Skip to content

Update 3.mdx#1158

Open
Karthika-ps wants to merge 2 commits intohuggingface:mainfrom
Karthika-ps:patch-1
Open

Update 3.mdx#1158
Karthika-ps wants to merge 2 commits intohuggingface:mainfrom
Karthika-ps:patch-1

Conversation

@Karthika-ps
Copy link

This change fixes a small but important technical inconsistency in Chapter 2, Section 3 regarding tensor creation from tokenized sequences.

The current example shows two encoded sequences of different lengths being directly converted into a PyTorch tensor and describes them as “already of rectangular shape.” In practice, PyTorch tensors require rectangular (uniform-length) inputs, and attempting to convert ragged sequences without padding raises a ValueError.

This update clarifies that padding is required before conversion and aligns the example with actual PyTorch behavior and the tokenizer-based workflow introduced earlier in the section. The revised explanation helps avoid confusion for readers who try to run the code verbatim and reinforces the correct mental model: tokenization can produce variable-length sequences, but padding is necessary when creating tensors or passing inputs to a model.

This change fixes a small but important technical inconsistency in Chapter 2, Section 3 regarding tensor creation from tokenized sequences.

The current example shows two encoded sequences of different lengths being directly converted into a PyTorch tensor and describes them as “already of rectangular shape.” In practice, PyTorch tensors require rectangular (uniform-length) inputs, and attempting to convert ragged sequences without padding raises a ValueError.

This update clarifies that padding is required before conversion and aligns the example with actual PyTorch behavior and the tokenizer-based workflow introduced earlier in the section. The revised explanation helps avoid confusion for readers who try to run the code verbatim and reinforces the correct mental model: tokenization can produce variable-length sequences, but padding is necessary when creating tensors or passing inputs to a model.
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Fix line wrapping to satisfy quality check
Copy link
Author

@Karthika-ps Karthika-ps left a comment

Choose a reason for hiding this comment

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

Fix line wrapping to satisfy quality check

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.

2 participants

Comments