BERT QnA
by tikosar
HTML
<!-- Load TensorFlow.js. This is required to use the qna model. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
<!-- Load the qna model. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/qna"></script>
<!-- Use the script tag to place your code or use an external .js file -->
<script>
async function test() {
// Define question and answer as simple strings
var searchText = 'We believe cats are the real stars of YouTube.'
var question = 'What is important to YouTube?' // Cats!
// Load the model asynchronously using the "then" keyword.
const model = await qna.load()
// Call model.findAnwers() with the question and passage as parameters
const answers = await model.findAnswers(question, searchText)
console.log('Answers: ', answers)
}
test()
</script>