allenai / allennlp-demo

Code for the AllenNLP demo.
https://demo.allennlp.org
Apache License 2.0
195 stars 80 forks source link

Insufficient answer highlighting #187

Open IDIDIR opened 5 years ago

IDIDIR commented 5 years ago

Response from /predict/machine-comprehension:

...
'best_span': [60, 60],
'best_span_str': 'Two',
...

When processing on python, the passage is divided into elements (words and symbols) by a special algorithm. The result returns the position of the word in the passage. When the found word is highlighted on the client's side (demo\src\components\demos\ReadingComprehension.js), the following occurs:

const start = passage.indexOf(best_span_str);
const head = passage.slice(0, start);
const tail = passage.slice(start + best_span_str.length);

Accordingly, if there is a duplicate response to the original, it highlights the wrong value. need to repeat the algorithm of splitting into elements but in the opposite direction. Are there any options?

Samples: Correct: https://demo.allennlp.org/reading-comprehension/Njg5MDY2 Incorrect https://demo.allennlp.org/reading-comprehension/Njg5MDY1

matt-gardner commented 5 years ago

We have fixed this for the NAQANet model, but the BiDAF visualization still uses the old UI. We have access to the predicted span indices, they just aren't used. Basically, this code needs to be updated to be like this code.

Contributions welcome!