InstructionNER icon indicating copy to clipboard operation
InstructionNER copied to clipboard

Update for Running the code for testing the Model.

Open EISHKARAN opened this issue 2 years ago • 0 comments

If an issue is faced for the model not being run for the new test cases and throughs the error as shown below

`/content/InstructionNER/instruction_ner/model.py in predict(self, text, generation_kwargs, instruction, options)
     53             [instance.context], [instance.question], return_tensors="pt"
     54         ).input_ids
---> 55 
     56         with torch.no_grad():
     57             outputs = self.model.generate(input_ids, **generation_kwargs)

UnboundLocalError: local variable 'answer_spans' referenced before assignment`

Make the above changes in the model.py file as shown below.

In line 62-64 the line is as follows

` answer_spans = self.answer_formatter.format_answer_spans(
            context=instance.context, prediction=answer_raw, options=options
        )`

Change it to

' answer_spans = self.answer_formatter.format_answer_spans(
            context=test, prediction=answer_raw, options=options
        )'


Making this change will help you use the model on your own test cases.

EISHKARAN avatar Feb 14 '24 10:02 EISHKARAN