Skip to content

use_fast=False when loading OPT's tokenizer? #23768

Description

@jiangwangyi

System Info

platform==Ubuntu 18.04.01
python==3.10
transformers==4.29.1

Who can help?

@sgugger @stevhliu @mk

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

It is shown in the OPT model documentation (in Tips) that it is required to pass use_fast=False when loading a OPT tokenizer, as OPT tokenizer will add </s> to the beginning of every prompt.

I made a trial:

>>> import transformers
>>> tokenizer = transformers.AutoTokenizer.from_pretrained("facebook/opt-1.3b", use_fast=False)
>>> tokenizer_fast = transformers.AutoTokenizer.from_pretrained("facebook/opt-1.3b", use_fast=True)
>>> text = "I like you."
>>> tokenizer(text)
>>> {'input_ids': [2, 100, 101, 47, 4], 'attention_mask': [1, 1, 1, 1, 1]}
>>> tokenizer_fast(text)
>>> {'input_ids': [2, 100, 101, 47, 4], 'attention_mask': [1, 1, 1, 1, 1]}

</s> is correctly added and no difference is observed.

Expected behavior

Is the tips wrong or in some other cases use_fast=Fast is actually required?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions