nicknochnack / QnA-Web-App-with-React-and-Tensorflow.JS

Final code from the QnA Web App with React and Tensorflow.JS YouTube video

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Q&A with fixed passage

Andredenise opened this issue · comments

Hey, this is an awesome repository! I wanted to make my own q&a web app and this ideal. I was just wondering ifyou could help me to change the code a bit so that you can just ask questions about a fixed text that is also not visible on the web app. More precise that you only have a question box in which you can ask questions about a certain text that is already specified in the code.

Thanks in advance!

To have a fixed text you can just manually set the text in model.findAnswers() to whatever text you want.

const answerQuestion = async (e) => {
  if (e.which === 13 && model !== null ){
    console.log('Question submitted.')
    const question = questionRef.current.value

    const answers = await model.findAnswers(question, __YOURTEXT__)

    setAnswer(answers); 
    console.log(answers)
  }  
}

And then remove textarea and passageRef from the code so that the user only ask questions.

This doesn't work with long passages as it works with short ones. How do I create such model?

There is max context you can provide to BERT models.

Here are some alternative approaches you can try to get around it.
https://stackoverflow.com/a/58643108

Some additional info that may be helpful:
google-research/bert#27
https://github.com/mim-solutions/bert_for_longer_texts