tensorflow / tensorflow/text

Is `preserve_unused_token` working when calling `bert_vocab_from_dataset`?

Open
#985 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.3k
Forks
379
Avg merge
3h 30m
Merged PRs (30d)
8

Description

If I got it right, then this command:

bert_vocab.bert_vocab_from_dataset(
    dataset=tf.data.Dataset.from_tensor_slices(['I am [unused1].']),
    vocab_size=100,
    reserved_tokens=[],
    bert_tokenizer_params=dict(lower_case=False, preserve_unused_token=True),
    learn_params = None
)

should return [unused1] as a token, but rather I get

['.', '1', 'I', '[', ']', 'a', 'd', 'e', 'm', 'n', 's', 'u', '##.', '##1', '##I', '##[', '##]', '##a', '##d', '##e', '##m', '##n', '##s', '##u']

which is exactly what was expected if preserve_unused_token was being ignored.

Am I doing something wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided bert_vocab.bert_vocab_from_dataset reproducer with the shown dataset and tokenizer parameters. Trace how preserve_unused_token is handled during vocabulary generation, and compare the result with the expected inclusion of [unused1]; done means confirming whether the behavior is intentional or identifying the relevant fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.