InternVL icon indicating copy to clipboard operation
InternVL copied to clipboard

How to get hidden_states

Open JCSTARS opened this issue 8 months ago • 2 comments

When I add output_hidden_states=True in generation config to get model hidden_states. It'snot working. After digging into modeling_internvl_chat.py, I found that the output_hidden_states seems cannot pass into self.language_model.generate. Is there some other ways?

generation_config = dict(max_new_tokens=4, do_sample=True, output_hidden_states=True) response = model.chat(tokenizer, pixel_values, question, generation_config)

JCSTARS avatar Apr 03 '25 03:04 JCSTARS

Hi,

Please try set "output_hidden_states": true, in config.json.

yuecao0119 avatar Apr 11 '25 11:04 yuecao0119

Hi @yuecao0119! I also need to get hidden states from v3 models. How should I modify the config? Can I do it without forking the official hf repo? Thanks!

P.S. I tried to supply output_hidden_states=True to the AutoConfig, but model.generate still returns just token indexes, not dict with hidden states.

Howuhh avatar Apr 16 '25 09:04 Howuhh