You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
My own task or dataset (give details below)
Reproduction
fromtransformersimportAutoModelForSeq2SeqLM, AutoTokenizertokenizer=AutoTokenizer.from_pretrained('t5-small')
model=AutoModelForSeq2SeqLM.from_pretrained('t5-small')
input='This is a dummy input.'decoder_start_text='But is should still work, because'input_ids=tokenizer.encode(input, return_tensors='pt')
decoder_start_ids=tokenizer.encode(decoder_start_text, add_special_tokens=False)
# This raises an error as attached belowoutputs=model.generate(
input_ids,
forced_decoder_ids=decoder_start_ids
)
# This is against the documentation but worksoutputs=model.generate(
input_ids,
forced_decoder_ids={i: idfori, idinenumerate(decoder_start_ids)}
)
Expected behavior
According to the documentation, GeneratorMixin.generate accepts a list of int for forced_decoder_ids . However, above reproduction raises the following error:
Hi @koreyou 👋 The documentation is indeed incorrect -- It accepts a list of pairs integers (List[List[int]]) that can be convertible to a Dict[int, int], containing the index and the token to be forced, correspondingly (e.g. this list of lists).
Would you like to open a PR to fix the documentation? 🤗
System Info
transformers
version: 4.23.0Who can help?
Text generation: @patrickvonplaten, @Narsil, @gante
Documentation: @sgugger, @stevhliu
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Expected behavior
According to the documentation,
GeneratorMixin.generate
accepts a list of int forforced_decoder_ids
. However, above reproduction raises the following error:It is clear that implementation is expecting
Dict[int, str]
as shown in here. Hence I believe that implementation and documentation are inconsistent.FYI, other functions in
GeneratorMixin
seems to expectList[int]
as in the documentation.The text was updated successfully, but these errors were encountered: