haotian-liu / LLaVA

[NeurIPS'23 Oral] Visual Instruction Tuning (LLaVA) built towards GPT-4V level capabilities and beyond.
https://llava.hliu.cc
Apache License 2.0
20.22k stars 2.23k forks source link

[Usage] TypeError: LlavaLlamaForCausalLM.forward() got an unexpected keyword argument 'cache_position' #1448

Open segalinc opened 6 months ago

segalinc commented 6 months ago

Describe the issue

Reference issue https://github.com/huggingface/transformers/issues/29426

I also encountered this error with transformers >4.38.2 when trying new LLavaLama3 from https://huggingface.co/xtuner/llava-llama-3-8b-v1_1-hf/discussions/1 I need to use tranformers > 4.39.2 for my work and llava requires 4.37 which is quite old by now. would it be possible to adjust the code and update it to latest versions?

zucchini-nlp commented 5 months ago

Hey! This should be solvable by popping the cache_position from inputs in this method.

inputs.pop("cache_position")

The error is raised because calling "super()" returns kwargs that are not used in the custom model's forward.

SWHL commented 5 months ago

@zucchini-nlp It works!

tseven commented 4 months ago

This fixed the issue for me as well, thanks!