Spaces:
Runtime error
Runtime error
Update
Browse files- react-qa/build/asset-manifest.json +3 -3
- react-qa/build/index.html +1 -1
- react-qa/build/static/js/{main.a8f287a8.js β main.2f618c79.js} +0 -0
- react-qa/build/static/js/{main.a8f287a8.js.LICENSE.txt β main.2f618c79.js.LICENSE.txt} +0 -0
- react-qa/build/static/js/{main.a8f287a8.js.map β main.2f618c79.js.map} +0 -0
- react-qa/package.json +1 -1
- react-qa/src/App.js +73 -44
- react-qa/src/index.js +0 -2
- server.py +1 -1
react-qa/build/asset-manifest.json
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
{
|
2 |
"files": {
|
3 |
"main.css": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/css/main.94510c01.css",
|
4 |
-
"main.js": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/main.
|
5 |
"static/js/787.e7ee5088.chunk.js": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/787.e7ee5088.chunk.js",
|
6 |
"index.html": "/embed/p208p2002/Transformer-QA-Decode-Visualize/index.html",
|
7 |
"main.94510c01.css.map": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/css/main.94510c01.css.map",
|
8 |
-
"main.
|
9 |
"787.e7ee5088.chunk.js.map": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/787.e7ee5088.chunk.js.map"
|
10 |
},
|
11 |
"entrypoints": [
|
12 |
"static/css/main.94510c01.css",
|
13 |
-
"static/js/main.
|
14 |
]
|
15 |
}
|
|
|
1 |
{
|
2 |
"files": {
|
3 |
"main.css": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/css/main.94510c01.css",
|
4 |
+
"main.js": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/main.2f618c79.js",
|
5 |
"static/js/787.e7ee5088.chunk.js": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/787.e7ee5088.chunk.js",
|
6 |
"index.html": "/embed/p208p2002/Transformer-QA-Decode-Visualize/index.html",
|
7 |
"main.94510c01.css.map": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/css/main.94510c01.css.map",
|
8 |
+
"main.2f618c79.js.map": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/main.2f618c79.js.map",
|
9 |
"787.e7ee5088.chunk.js.map": "/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/787.e7ee5088.chunk.js.map"
|
10 |
},
|
11 |
"entrypoints": [
|
12 |
"static/css/main.94510c01.css",
|
13 |
+
"static/js/main.2f618c79.js"
|
14 |
]
|
15 |
}
|
react-qa/build/index.html
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/embed/p208p2002/Transformer-QA-Decode-Visualize/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/embed/p208p2002/Transformer-QA-Decode-Visualize/logo192.png"/><link rel="manifest" href="/embed/p208p2002/Transformer-QA-Decode-Visualize/manifest.json"/><title>React App</title><script defer="defer" src="/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/main.
|
|
|
1 |
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/embed/p208p2002/Transformer-QA-Decode-Visualize/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/embed/p208p2002/Transformer-QA-Decode-Visualize/logo192.png"/><link rel="manifest" href="/embed/p208p2002/Transformer-QA-Decode-Visualize/manifest.json"/><title>React App</title><script defer="defer" src="/embed/p208p2002/Transformer-QA-Decode-Visualize/static/js/main.2f618c79.js"></script><link href="/embed/p208p2002/Transformer-QA-Decode-Visualize/static/css/main.94510c01.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
react-qa/build/static/js/{main.a8f287a8.js β main.2f618c79.js}
RENAMED
The diff for this file is too large to render.
See raw diff
|
|
react-qa/build/static/js/{main.a8f287a8.js.LICENSE.txt β main.2f618c79.js.LICENSE.txt}
RENAMED
File without changes
|
react-qa/build/static/js/{main.a8f287a8.js.map β main.2f618c79.js.map}
RENAMED
The diff for this file is too large to render.
See raw diff
|
|
react-qa/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
"web-vitals": "^2.1.4"
|
16 |
},
|
17 |
"scripts": {
|
18 |
-
"start": "react-scripts start",
|
19 |
"build": "react-scripts build",
|
20 |
"test": "react-scripts test",
|
21 |
"eject": "react-scripts eject"
|
|
|
15 |
"web-vitals": "^2.1.4"
|
16 |
},
|
17 |
"scripts": {
|
18 |
+
"start": "export REACT_APP_IN_DEV=true && react-scripts start",
|
19 |
"build": "react-scripts build",
|
20 |
"test": "react-scripts test",
|
21 |
"eject": "react-scripts eject"
|
react-qa/src/App.js
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
import { HlList, HlLayerContainer, HlLayer } from 'react-transformer-qa-decode-visualize'
|
2 |
import 'react-transformer-qa-decode-visualize/dist/index.css'
|
3 |
-
import {
|
4 |
const axios = require('axios').default;
|
5 |
function App() {
|
6 |
|
7 |
const [qa_data, set_qa_data] = useState([[]])
|
8 |
-
const [question,set_question] = useState("What's my name?")
|
9 |
-
const [context,set_context] = useState("My name is Clara and I live in Berkeley.")
|
10 |
|
11 |
let request_qa_data = () => {
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
question,
|
14 |
context
|
15 |
})
|
@@ -23,31 +28,35 @@ function App() {
|
|
23 |
<div style={{ width: 800, padding: 20 }}>
|
24 |
|
25 |
<h4>Question</h4>
|
26 |
-
<input
|
27 |
-
style={{ width: 600 }}
|
28 |
-
type="text"
|
29 |
value={question}
|
30 |
-
onChange={(e)=>{
|
31 |
set_question(e.target.value)
|
32 |
-
set_qa_data([[]])
|
|
|
|
|
|
|
|
|
33 |
}}
|
34 |
-
|
35 |
<br />
|
36 |
<h4>Context</h4>
|
37 |
-
<textarea
|
38 |
-
name=""
|
39 |
-
id=""
|
40 |
-
cols="80"
|
41 |
rows="8"
|
42 |
value={context}
|
43 |
-
onChange={(e)=>{
|
44 |
set_context(e.target.value)
|
45 |
set_qa_data([[]])
|
46 |
}}
|
47 |
/>
|
48 |
|
49 |
<br /><br />
|
50 |
-
<button
|
51 |
type="submit"
|
52 |
onClick={request_qa_data}
|
53 |
>Submit
|
@@ -55,36 +64,56 @@ function App() {
|
|
55 |
|
56 |
<br />
|
57 |
<hr />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
<h4>Context</h4>
|
71 |
-
<HlLayerContainer
|
72 |
-
context={context}>
|
73 |
-
<HlLayer
|
74 |
-
data={{
|
75 |
-
result: qa_data[0].slice(0, 5),
|
76 |
-
context: context
|
77 |
-
}}
|
78 |
-
color='yellow'
|
79 |
-
/>
|
80 |
-
<HlLayer
|
81 |
-
data={{
|
82 |
-
result: qa_data[0].slice(0, 1),
|
83 |
-
context: context
|
84 |
-
}}
|
85 |
-
color='orange'
|
86 |
-
/>
|
87 |
-
</HlLayerContainer >
|
88 |
|
89 |
</div>
|
90 |
);
|
|
|
1 |
import { HlList, HlLayerContainer, HlLayer } from 'react-transformer-qa-decode-visualize'
|
2 |
import 'react-transformer-qa-decode-visualize/dist/index.css'
|
3 |
+
import { useState } from 'react'
|
4 |
const axios = require('axios').default;
|
5 |
function App() {
|
6 |
|
7 |
const [qa_data, set_qa_data] = useState([[]])
|
8 |
+
const [question, set_question] = useState("What's my name?")
|
9 |
+
const [context, set_context] = useState("My name is Clara and I live in Berkeley.")
|
10 |
|
11 |
let request_qa_data = () => {
|
12 |
+
const { REACT_APP_IN_DEV = 'false' } = process.env;
|
13 |
+
let api_url = 'https://hf.space/embed/p208p2002/Transformer-QA-Decode-Visualize/question-answer'
|
14 |
+
if (REACT_APP_IN_DEV === 'true') {
|
15 |
+
api_url = 'http://127.0.0.1:7860/question-answer'
|
16 |
+
}
|
17 |
+
axios.post(api_url, {
|
18 |
question,
|
19 |
context
|
20 |
})
|
|
|
28 |
<div style={{ width: 800, padding: 20 }}>
|
29 |
|
30 |
<h4>Question</h4>
|
31 |
+
<input
|
32 |
+
style={{ width: 600 }}
|
33 |
+
type="text"
|
34 |
value={question}
|
35 |
+
onChange={(e) => {
|
36 |
set_question(e.target.value)
|
37 |
+
// set_qa_data([[]])
|
38 |
+
setTimeout(() => {
|
39 |
+
request_qa_data()
|
40 |
+
}, 20);
|
41 |
+
|
42 |
}}
|
43 |
+
/>
|
44 |
<br />
|
45 |
<h4>Context</h4>
|
46 |
+
<textarea
|
47 |
+
name=""
|
48 |
+
id=""
|
49 |
+
cols="80"
|
50 |
rows="8"
|
51 |
value={context}
|
52 |
+
onChange={(e) => {
|
53 |
set_context(e.target.value)
|
54 |
set_qa_data([[]])
|
55 |
}}
|
56 |
/>
|
57 |
|
58 |
<br /><br />
|
59 |
+
<button
|
60 |
type="submit"
|
61 |
onClick={request_qa_data}
|
62 |
>Submit
|
|
|
64 |
|
65 |
<br />
|
66 |
<hr />
|
67 |
+
{
|
68 |
+
qa_data.map((stride_qa_data, i) => {
|
69 |
+
stride_qa_data = stride_qa_data.slice(0, 5)
|
70 |
+
stride_qa_data = stride_qa_data.map((data) => {
|
71 |
+
|
72 |
+
if (data.global_context_start === 0 && data.global_context_end === 0) {
|
73 |
+
data.answer_span = "** NO_ANSWER **"
|
74 |
+
}
|
75 |
+
const answer_text = data.answer_span
|
76 |
+
data.answer_span = `logit:${data.start_logit.toFixed(2)}, ${data.end_logit.toFixed(2).padStart(4)} - ${answer_text}`
|
77 |
+
|
78 |
+
return data
|
79 |
+
})
|
80 |
+
return (
|
81 |
+
<div key={i}>
|
82 |
+
<div>
|
83 |
+
<h4>Transformer QA Model <small>(stride: {i + 1})</small></h4>
|
84 |
+
<p>{question}</p>
|
85 |
|
86 |
+
<HlList
|
87 |
+
data={{
|
88 |
+
result: stride_qa_data
|
89 |
+
}}
|
90 |
+
color='yellow' />
|
91 |
+
<hr />
|
92 |
+
</div>
|
93 |
+
|
94 |
+
<h4>Context</h4>
|
95 |
+
<HlLayerContainer
|
96 |
+
context={context}>
|
97 |
+
<HlLayer
|
98 |
+
data={{
|
99 |
+
result: stride_qa_data,
|
100 |
+
context: context
|
101 |
+
}}
|
102 |
+
color='yellow'
|
103 |
+
/>
|
104 |
+
<HlLayer
|
105 |
+
data={{
|
106 |
+
result: stride_qa_data.slice(0, 1),
|
107 |
+
context: context
|
108 |
+
}}
|
109 |
+
color='orange'
|
110 |
+
/>
|
111 |
+
</HlLayerContainer >
|
112 |
+
</div>
|
113 |
+
)
|
114 |
+
})
|
115 |
+
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
</div>
|
119 |
);
|
react-qa/src/index.js
CHANGED
@@ -6,9 +6,7 @@ import reportWebVitals from './reportWebVitals';
|
|
6 |
|
7 |
const root = ReactDOM.createRoot(document.getElementById('root'));
|
8 |
root.render(
|
9 |
-
<React.StrictMode>
|
10 |
<App />
|
11 |
-
</React.StrictMode>
|
12 |
);
|
13 |
|
14 |
// If you want to start measuring performance in your app, pass a function
|
|
|
6 |
|
7 |
const root = ReactDOM.createRoot(document.getElementById('root'));
|
8 |
root.render(
|
|
|
9 |
<App />
|
|
|
10 |
);
|
11 |
|
12 |
// If you want to start measuring performance in your app, pass a function
|
server.py
CHANGED
@@ -9,7 +9,7 @@ from pydantic import BaseModel
|
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("deepset/roberta-base-squad2")
|
11 |
model = AutoModelForQuestionAnswering.from_pretrained("deepset/roberta-base-squad2")
|
12 |
-
qahl = TransformerQADecode(model=model, tokenizer=tokenizer)
|
13 |
|
14 |
app = FastAPI()
|
15 |
app.mount("/static", StaticFiles(directory="react-qa/build/static"), name="static")
|
|
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("deepset/roberta-base-squad2")
|
11 |
model = AutoModelForQuestionAnswering.from_pretrained("deepset/roberta-base-squad2")
|
12 |
+
qahl = TransformerQADecode(model=model, tokenizer=tokenizer, is_squad_v2=True)
|
13 |
|
14 |
app = FastAPI()
|
15 |
app.mount("/static", StaticFiles(directory="react-qa/build/static"), name="static")
|