# TypeError: DebertaV2ForQuestionAnswering object argument after \*\* must be a mapping, not Tensor

**URL:** <https://discuss.huggingface.co/t/typeerror-debertav2forquestionanswering-object-argument-after-must-be-a-mapping-not-tensor/12815>\
**Category:** Beginners\
**Created:** [December 14, 2021, 2:24pm UTC](https://discuss.huggingface.co/t/typeerror-debertav2forquestionanswering-object-argument-after-must-be-a-mapping-not-tensor/12815 "2021-12-14T14:24:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pushpalatha](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@pushpalatha](https://discuss.huggingface.co/u/pushpalatha)\
**Post date:** [December 14, 2021, 2:24pm UTC](https://discuss.huggingface.co/t/typeerror-debertav2forquestionanswering-object-argument-after-must-be-a-mapping-not-tensor/12815/1 "2021-12-14T14:24:14Z")

</div>

Hi,

Iam getting the above type error in my inference code where i input the file contents as context and query to predict answers on a custom dataset trained and evaluated using deberat-v2-xlarge model.  
I have divided the contents of file into chunks of size 512(max\_len handled by model).  
answer\_start\_scores = self.model(\*\*chunk)[0]  
answer\_end\_scores = self.model(\*\*chunk)[1]

when i run my inference code on N txt files, my inference code can process only 4 text files and i get the below error.pls let me know how to resolve this error

ERROR:

Traceback (most recent call last):  
File “contract\_final\_updated.py”, line 291, in   
final=reader.get\_answer(ques)#model inference on input(question,context)  
File “contract\_final\_updated.py”, line 91, in get\_answer  
answer\_start\_scores = self.model(\*\*chunk)[0]  
TypeError: DebertaV2ForQuestionAnswering object argument after \*\* must be a mapping, not Tensor

The function get\_answer()

def get\_answer(self,ques):  
if self.chunked:  
answer = ‘’  
for k, chunk in self.inputs.items():

```
            #to code for finding N best predictions
            nbest = 3
            answer_start_scores = self.model(**chunk)[0]
            answer_end_scores = self.model(**chunk)[1]
            #print('answer_start_scores',answer_start_scores)#similar to start_logits calculated in get_answer_update()
            #print(torch.topk(answer_start_scores.flatten(),3).indices)

            best_indices_start = torch.topk(answer_start_scores,3).indices#to get best 3 start indices,similar to start_indexes
            best_indices_end = torch.topk(answer_end_scores,3).indices#to get best 3 end indices,similar to end_indexes

            answer_start_scores = answer_start_scores[0].detach().numpy()
            answer_end_scores = answer_end_scores[0].detach().numpy()
```

---

<div class="post-metadata">

**Author:** ![hvenance](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@hvenance](https://discuss.huggingface.co/u/hvenance)\
**Post date:** [February 16, 2023, 3:55pm UTC](https://discuss.huggingface.co/t/typeerror-debertav2forquestionanswering-object-argument-after-must-be-a-mapping-not-tensor/12815/2 "2023-02-16T15:55:54Z")

</div>

> [@pushpalatha](#):
>
> `wer_end_`

Did you find any way to handle large sentences and divide them into chunks of size 512, that correctly works?
