InstructionNER
InstructionNER copied to clipboard
Update for Running the code for testing the Model.
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.