[GH-ISSUE #101] AttributeError: 'DeepseekVLV2ForCausalLM' object has no attribute 'language_model' #83

Open
opened 2026-10-26 21:11:35 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @JhyOnya on GitHub (Feb 25, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-VL2/issues/101

AttributeError Traceback (most recent call last)
Cell In[2], line 13
10 inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)
12 # run the model to get the response
---> 13 outputs = vl_gpt.language_model.generate(
14 inputs_embeds=inputs_embeds,
15 attention_mask=prepare_inputs.attention_mask,
16 pad_token_id=tokenizer.eos_token_id,
17 bos_token_id=tokenizer.bos_token_id,
18 eos_token_id=tokenizer.eos_token_id,
19 max_new_tokens=512,
20 do_sample=False,
21 use_cache=True
22 )
24 answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
25 print(f"{prepare_inputs['sft_format'][0]}", answer)

File ~/.conda/envs/jhy_ds/lib/python3.10/site-packages/torch/nn/modules/module.py:1614, in Module.getattr(self, name)
1612 if name in modules:
1613 return modules[name]
-> 1614 raise AttributeError("'{}' object has no attribute '{}'".format(
1615 type(self).name, name))

AttributeError: 'DeepseekVLV2ForCausalLM' object has no attribute 'language_model'

Originally created by @JhyOnya on GitHub (Feb 25, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-VL2/issues/101 AttributeError Traceback (most recent call last) Cell In[2], line 13 10 inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs) 12 # run the model to get the response ---> 13 outputs = vl_gpt.language_model.generate( 14 inputs_embeds=inputs_embeds, 15 attention_mask=prepare_inputs.attention_mask, 16 pad_token_id=tokenizer.eos_token_id, 17 bos_token_id=tokenizer.bos_token_id, 18 eos_token_id=tokenizer.eos_token_id, 19 max_new_tokens=512, 20 do_sample=False, 21 use_cache=True 22 ) 24 answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True) 25 print(f"{prepare_inputs['sft_format'][0]}", answer) File ~/.conda/envs/jhy_ds/lib/python3.10/site-packages/torch/nn/modules/module.py:1614, in Module.__getattr__(self, name) 1612 if name in modules: 1613 return modules[name] -> 1614 raise AttributeError("'{}' object has no attribute '{}'".format( 1615 type(self).__name__, name)) AttributeError: 'DeepseekVLV2ForCausalLM' object has no attribute 'language_model'
Author
Owner

@extraordinary126 commented on GitHub (Feb 27, 2025):

try this
outputs = vl_gpt.language.generate(...)

<!-- gh-comment-id:2686718771 --> @extraordinary126 commented on GitHub (Feb 27, 2025): try this `outputs = vl_gpt.language.generate(...)`
Author
Owner

@JhyOnya commented on GitHub (Feb 27, 2025):

try this outputs = self.vl_gpt.language.generate(...)

Thanks, it works. Besides, I find that vl_gpt.generate is also works... I don't know why but it just works...hhh

<!-- gh-comment-id:2686738574 --> @JhyOnya commented on GitHub (Feb 27, 2025): > try this `outputs = self.vl_gpt.language.generate(...)` Thanks, it works. Besides, I find that ` vl_gpt.generate` is also works... I don't know why but it just works...hhh
Author
Owner

@HG731GZ commented on GitHub (Mar 24, 2025):

I met this problem too, and i tried

try this outputs = self.vl_gpt.language.generate(...)

get an error : name 'self' is not defined, i run it in jupyter notebook.

But when i delete 'self' and re-run, it works, i dont know why, it's wierd and makes me worried.

<!-- gh-comment-id:2747749634 --> @HG731GZ commented on GitHub (Mar 24, 2025): I met this problem too, and i tried > try this `outputs = self.vl_gpt.language.generate(...)` get an error : name 'self' is not defined, i run it in jupyter notebook. But when i delete 'self' and re-run, it works, i dont know why, it's wierd and makes me worried.
Author
Owner

@extraordinary126 commented on GitHub (Mar 27, 2025):

I met this problem too, and i tried

try this outputs = self.vl_gpt.language.generate(...)

get an error : name 'self' is not defined, i run it in jupyter notebook.

But when i delete 'self' and re-run, it works, i dont know why, it's wierd and makes me worried.

It's my mistake, the 'self' is there because I integrated this method into a class. You can remove 'self'.

<!-- gh-comment-id:2756297074 --> @extraordinary126 commented on GitHub (Mar 27, 2025): > I met this problem too, and i tried > > > try this `outputs = self.vl_gpt.language.generate(...)` > > get an error : name 'self' is not defined, i run it in jupyter notebook. > > But when i delete 'self' and re-run, it works, i dont know why, it's wierd and makes me worried. It's my mistake, the 'self' is there because I integrated this method into a class. You can remove 'self'.
Author
Owner

@orzgugu commented on GitHub (Apr 2, 2025):

试试这个 outputs = vl_gpt.language.generate(...)

Hello, have you encountered this problem, that is, deepseek-vl2-tiny can run normally, but deepseek-vl2-small and deepseek-vl2 output the input prompt?

<!-- gh-comment-id:2772323696 --> @orzgugu commented on GitHub (Apr 2, 2025): > 试试这个 `outputs = vl_gpt.language.generate(...)` Hello, have you encountered this problem, that is, deepseek-vl2-tiny can run normally, but deepseek-vl2-small and deepseek-vl2 output the input prompt?
Author
Owner

@changganyin commented on GitHub (Apr 22, 2025):

Hello, have you encountered this problem, that is, deepseek-vl2-tiny can run normally, but deepseek-vl2-small and deepseek-vl2 output the input prompt?

@orzgugu I have encountered the same problem, try to remove "<|ref|>" and "<|/ref|>" in "content". This worked for me. Hope this can help you. : )

conversation = [
    {
        "role": "<|User|>",
        "content": "<image>\nDescribe the image.", # remove <|ref|> and <|/ref|>
        "images": ["./example/fish.png"],
    },
    {"role": "<|Assistant|>", "content": ""},
]
<!-- gh-comment-id:2820318724 --> @changganyin commented on GitHub (Apr 22, 2025): > Hello, have you encountered this problem, that is, deepseek-vl2-tiny can run normally, but deepseek-vl2-small and deepseek-vl2 output the input prompt? @orzgugu I have encountered the same problem, try to remove "<|ref|>" and "<|/ref|>" in "content". This worked for me. Hope this can help you. : ) ``` python conversation = [ { "role": "<|User|>", "content": "<image>\nDescribe the image.", # remove <|ref|> and <|/ref|> "images": ["./example/fish.png"], }, {"role": "<|Assistant|>", "content": ""}, ] ```
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-VL2#83
No description provided.