-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
61 lines (61 loc) · 2.12 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TensorFlow.js Text Similarity Example</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder"></script>
<!-- <script src="https://cdn.jsdelivr.net/gh/hchiam/[email protected]/tfjs-stuff.js"></script> -->
<script src="tfjs-stuff.js"></script>
<script src="index.js"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/hchiam/[email protected]/style.css"
/>
<link rel="stylesheet" href="style.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
</head>
<body>
<h2>Sentence 1:</h2>
<input id="sentence1" type="text" value="How are you?" />
<h2>Sentence 2:</h2>
<input
id="input"
type="text"
placeholder="Enter a sentence here."
value="Hi, how are you?"
/>
<p>
<button id="get-similarity" onclick="getSimilarityOfInput()">
Calculate similarity
</button>
<i
id="spinner"
class="fa fa-spinner fa-spin"
style="visibility: hidden"
></i>
</p>
<div id="output" style="visibility: hidden">
<h2>Similarity:</h2>
<p id="similarity"></p>
<p>
This tool could possibly be used to check whether a free-form answer
closely matches the expected answer in meaning. For best results, you
probably should constrain responses to short sentences (i.e. short
answer questions only). For faster results, you might want to call
back-end code that runs a Python/PyTorch script that has been
pre-compiled to C. Reference for this demo:
<a
href="https://github.com/hchiam/text-similarity-test"
target="_blank"
rel="noopener noreferrer"
>https://github.com/hchiam/text-similarity-test</a
>
</p>
</div>
</body>
</html>