Skip to content

Conversation

jieyao-MilestoneHub
Copy link

Description

Fix tokenizer input in the MRPC preprocessing example.
In recent versions, raw_datasets["train"]["sentence1"] and ["sentence2"] are datasets.arrow_dataset.Column objects, which must be converted to Python lists before tokenization.


Change

# Before
tokenized_dataset = tokenizer(
    raw_datasets["train"]["sentence1"],
    raw_datasets["train"]["sentence2"],
    padding=True,
    truncation=True,
)

# After
tokenized_dataset = tokenizer(
    list(raw_datasets["train"]["sentence1"]),
    list(raw_datasets["train"]["sentence2"]),
    padding=True,
    truncation=True,
)
# or
tokenized_dataset = tokenizer(
    raw_datasets["train"].data["sentence1"].to_pylist(),
    raw_datasets["train"].data["sentence2"].to_pylist(),
    padding=True,
    truncation=True,
)

Impact

Prevents

ValueError: text input must be of type `str`, `list[str]`, or `list[list[str]]`

and ensures compatibility with transformers ≥4.56 and datasets ≥3.0.

@jieyao-MilestoneHub
Copy link
Author

Hi @thliang01 — I noticed this tokenizer input issue in the zh-TW course file.
Could you please help review and confirm if the fix looks correct? Thank you! 🙏

@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.

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