

TITLE
force_words_ids not working

COMMENTS
3

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
### System Info

```shell
No inception occurs.
```


### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [X] 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

from transformers import (GPT2LMHeadModel, GPT2Tokenizer, GPT2Config)

m = GPT2LMHeadModel.from_pretrained('gpt2')
t = GPT2Tokenizer.from_pretrained('gpt2')

prompt = "I drink cocacola."
input = t(prompt, return_tensors="pt")

bad_words = t("alcohol", add_prefix_space=True, add_special_tokens=False).input_ids
force_words = t("very sweet", add_prefix_space=True, add_special_tokens=False).input_ids
print("bad_words: ", bad_words)
print("force_words: ", force_words)

gen = m.generate(**input, do_sample=True, temperature=0.9, num_beams = 10, top_p=1.0, bad_words_ids = [bad_words], force_words_ids=[force_words], max_length=100)

gen = t.batch_decode(gen)
if_exist_very = 'very' in gen
if_exist_sweet = 'sweet' in gen
print("gen: ", gen)
print("if_exist_very: ", if_exist_very)
print("if_exist_sweet: ", if_exist_sweet)

### Expected behavior

```shell
Hi,

I tried to use generate() with force_words_ids. But it does not work. bad_words_ids seems to work though.


Here are the outputs:
gen:  ["I drink cocacola. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't drink coca. I don't"]
if_exist_very:  False
if_exist_sweet:  False
```
