cd /news/developer-tools/chapter-3-questions · home topics developer-tools article
[ARTICLE · art-75137] src=discuss.huggingface.co ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Chapter 3 questions

Hugging Face tokenizer code in the Chapter 3 course notebook fails because the Datasets library now returns a Column object instead of a plain Python list when indexing by column name, breaking the tokenizer's expected input format. The minimal fix is to wrap dataset column access with `list()` to convert the column to a `list[str]`, as documented in the tokenizer API. The notebook uses the MRPC dataset for sentence-pair classification, where the actual task requires tokenizing both sentences together for BERT.

read2 min views1 publishedJul 27, 2026
Chapter 3 questions
Image: Discuss (auto-discovered)

In terms of code, just list()

will fix it.

Why the notebook code fails now

Root cause

The tokenizer expects text inputs like:

str

list[str]

  • batched text-pair inputs built from those

That is how the tokenizer API is documented today. (Hugging Face)

But dataset column access is no longer best thought of as “always a plain Python list.” Current Datasets docs explicitly say that **indexing by column name first returns a **Column

object. (Hugging Face)

So this line:

tokenizer(raw_datasets["train"]["sentence1"])

can fail because the tokenizer sees a dataset column object, not a plain Python list[str]

.

Background: why this is confusing

Older Datasets docs described dataset["sentence1"]

as returning a Python list of values. (Hugging Face)

Current docs describe column-first indexing as returning a Column

object. (Hugging Face)

That difference explains why:

  • older examples could work as written
  • current environments can reject the same code
  • the course notebook looks reasonable, but still breaks in practice

So the real background is API/documentation drift across library versions and implementations, not that your code idea was conceptually wrong. (Hugging Face)

Why this notebook uses two sentences at all

This dataset is MRPC, a sentence-pair classification task. Each example has:

sentence1

sentence2

  • a label telling whether they are paraphrases

The course explains that for BERT, the correct pair format is:

[CLS] sentence1 [SEP] sentence2 [SEP]

and that token_type_ids

distinguish the first sentence from the second. (GitHub)

So even when the notebook first tokenizes sentence1

and sentence2

separately, that is only an introductory step. The actual task is to tokenize the pair together. (GitHub)

Minimal fix for the notebook

The smallest code change is to convert each dataset column to a plain list.

Replace this

tokenized_sentences_1 = tokenizer(raw_datasets["train"]["sentence1"])
tokenized_sentences_2 = tokenizer(raw_datasets["train"]["sentence2"])

With this

tokenized_sentences_1 = tokenizer(list(raw_datasets["train"]["sentence1"]))
tokenized_sentences_2 = tokenizer(list(raw_datasets["train"]["sentence2"]))

And replace this:

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

with this:

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

Why this works

list(...)

converts the dataset column into the kind of container the tokenizer is documented to accept: a plain list[str]

. (Hugging Face)

── more in #developer-tools 4 stories · sorted by recency
── more on @hugging face 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/chapter-3-questions] indexed:0 read:2min 2026-07-27 ·