Getting the error: "ValueError: The following model_kwargs are not used by the model:....."
Author: Pranav110500
Pull request: no

Hello @ArthurZucker, I found you to be active in the issues section hence I have tagged you. I needed some help with this error I am facing. So I am basically re-implementing a particular research paper's code, available on their github page with the link:- https://github.com/XiangLi1999/ContrastiveDecoding

When I run the commands with the proper environment with all necessary libraries installed, I get the following error:-

**valueError: The following `model_kwargs` are not used by the model: ['min_prob', 'student_lm', 'teacher_student', 'model_kwargs_student', 'st_coef', 'tokenizer', 'student_min_prob', 'student_temperature', 'use_cap_student', 'use_switch'] (note: typos in the generate arguments will also show up in this list)**

I found somewhere online that if I downgraded my transformers version from the current latest one to 4.21.0 it would work and it did, but in that case I am unable to then implement the code using 2 new transformer models like Mistral or LLaMa2. I wanted to know how to work around this issue and resolve it. My main query is how can the code be altered in the run_generation.py (from the repo) file so that it works for the latest version of transformers. A secondary query is regarding how to use newer models like Mistral with the older transformers version (for the older version when I run the code's command with mistral replacing gpt2xl which is in their code I get the error: Keyerror: "Mistral").

I need some help urgently for this, and would appreciate any input regarding this matter from your side. At the same time if there's anyone else whom I can coordinate with for this, please do let me know of thme. I'll be grateful from any assistance from your end. Thanks.

Comments:
@ArthurZucker @younesbelkada Can either of you provide any insights on this? If additional info is needed to explain the issue further do let me know. Will be really glad for any assistance from you.

Hey 🤗  thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co/) instead? I'm sure the community will be of help!

In the mean time, you absolutely cannot use any new model with the old transformers, it's simply because you are missing 1m lines of code. 
The issue that you have should be easily debugged: generate does not accept kwargs that are not used by the model. The model's signature should either add this kwargs, or remove them as a whole. 
You should place breakpoints and debug step by step. 

@ArthurZucker thanks for responding. Sure I will open my question on the forum to get additional help thanks for suggesting that. 
I just have another small query regarding what you've said and the error. If generate doesnt accept the kwargs in the given code in run_generation.py, why is it that it is working on the older transformers version without this error? Like in a sense would it mean that the model does accept the args and only the older version accepts this? OR is it that in the older version case it just overrides the error and are these args are still not used in the case?

>is it that in the older version case it just overrides the error and are these args are still not used in the case?

that is the correct answer. We decided to add an error to make sure nothing get's silently ignored! 

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.