# Incorrect logits shape for GIT model

**URL:** <https://discuss.huggingface.co/t/incorrect-logits-shape-for-git-model/103832>\
**Category:** 🤗Transformers\
**Created:** [August 24, 2024, 6:23pm UTC](https://discuss.huggingface.co/t/incorrect-logits-shape-for-git-model/103832 "2024-08-24T18:23:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![souradipp76](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/souradipp76/32/30841_2.png) [@souradipp76](https://discuss.huggingface.co/u/souradipp76)\
**Post date:** [August 24, 2024, 6:23pm UTC](https://discuss.huggingface.co/t/incorrect-logits-shape-for-git-model/103832/1 "2024-08-24T18:23:27Z")

</div>

Hi,  
I am trying to use GIT multimodal model (microsoft/git-base-textvqa) for Visual Question Answering. The shape of logits from the output of the forward function is not (batch\_size, sequence\_length, config.vocab\_size) as mentioned in the documentation ([GIT](https://huggingface.co/docs/transformers/main/en/model_doc/git#transformers.GitForCausalLM.forward)). Is this a bug ? Kindly help.

Code to reproduce the issue is given below:

```auto
from transformers import AutoProcessor, AutoModelForCausalLM
from huggingface_hub import hf_hub_download
from PIL import Image

processor = AutoProcessor.from_pretrained("microsoft/git-base-textvqa")
model = AutoModelForCausalLM.from_pretrained("microsoft/git-base-textvqa")

file_path = hf_hub_download(repo_id="nielsr/textvqa-sample", filename="bus.png", repo_type="dataset")
image = Image.open(file_path).convert("RGB")

pixel_values = processor(images=image, return_tensors="pt").pixel_values

question = "what does the front of the bus say at the top?"

input_ids = processor(text=question, add_special_tokens=False).input_ids
input_ids = [processor.tokenizer.cls_token_id] + input_ids
input_ids = torch.tensor(input_ids).unsqueeze(0)
print(input_ids.shape) # torch.Size([1, 13])

output = model(pixel_values=pixel_values, input_ids=input_ids)
logits = output.logits
print(logits.shape) # torch.Size([1, 914, 30522])

```

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [August 26, 2024, 2:01pm UTC](https://discuss.huggingface.co/t/incorrect-logits-shape-for-git-model/103832/2 "2024-08-26T14:01:35Z")

</div>

Answered here: [Incorrect logits shape for GIT model (microsoft/git-base-textvqa) · Issue #33107 · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/issues/33107#issuecomment-2309574239)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [August 27, 2024, 2:01am UTC](https://discuss.huggingface.co/t/incorrect-logits-shape-for-git-model/103832/3 "2024-08-27T02:01:46Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
