Spaces:
Runtime error
Runtime error
Sean MacAvaney
commited on
Commit
β’
9889763
1
Parent(s):
29d8be8
update
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from pyterrier_doc2query import Doc2Query
|
3 |
|
4 |
-
doc2query = Doc2Query()
|
5 |
|
6 |
def df2code(df):
|
7 |
rows = []
|
@@ -28,6 +29,10 @@ doc2query({df2code(input)})
|
|
28 |
'''
|
29 |
return (doc2query(input), code)
|
30 |
|
|
|
|
|
|
|
|
|
31 |
gr.Interface(
|
32 |
predict,
|
33 |
inputs=[gr.Dataframe(
|
@@ -37,33 +42,33 @@ gr.Interface(
|
|
37 |
row_count=1,
|
38 |
wrap=True,
|
39 |
label='Pipeline Input',
|
40 |
-
value=
|
41 |
), gr.Dropdown(
|
42 |
choices=['macavaney/doc2query-t5-base-msmarco'],
|
43 |
value='macavaney/doc2query-t5-base-msmarco',
|
44 |
label='Model',
|
45 |
interactive=False,
|
46 |
), gr.Checkbox(
|
47 |
-
value=
|
48 |
label="Append",
|
49 |
), gr.Slider(
|
50 |
minimum=1,
|
51 |
maximum=10,
|
52 |
-
value=
|
53 |
step=1.,
|
54 |
label='# Queries'
|
55 |
)],
|
56 |
outputs=[gr.Dataframe(
|
57 |
headers=["docno", "text", "querygen"],
|
58 |
datatype=["str", "str", "str"],
|
59 |
-
col_count=
|
60 |
row_count=1,
|
61 |
wrap=True,
|
62 |
label='Pipeline Output',
|
63 |
-
value=
|
64 |
), gr.Markdown()],
|
65 |
title="π PyTerrier: Doc2Query",
|
66 |
description=open('README.md', 'rt').read().split('---\n')[-1],
|
67 |
allow_flagging='never',
|
68 |
css="table.font-mono td { white-space: pre-line; }",
|
69 |
-
).launch()
|
|
|
1 |
+
import pandas as pd
|
2 |
import gradio as gr
|
3 |
from pyterrier_doc2query import Doc2Query
|
4 |
|
5 |
+
doc2query = Doc2Query('macavaney/doc2query-t5-base-msmarco', append=True, num_samples=5)
|
6 |
|
7 |
def df2code(df):
|
8 |
rows = []
|
|
|
29 |
'''
|
30 |
return (doc2query(input), code)
|
31 |
|
32 |
+
example_inp = pd.DataFrame([
|
33 |
+
{'docno': '0', 'text': 'The presence of communication amid scientific minds was equally important to the success of the Manhattan Project as scientific intellect was. The only cloud hanging over the impressive achievement of the atomic researchers and engineers is what their success truly meant; hundreds of thousands of innocent lives obliterated.'}
|
34 |
+
])
|
35 |
+
|
36 |
gr.Interface(
|
37 |
predict,
|
38 |
inputs=[gr.Dataframe(
|
|
|
42 |
row_count=1,
|
43 |
wrap=True,
|
44 |
label='Pipeline Input',
|
45 |
+
value=example_inp,
|
46 |
), gr.Dropdown(
|
47 |
choices=['macavaney/doc2query-t5-base-msmarco'],
|
48 |
value='macavaney/doc2query-t5-base-msmarco',
|
49 |
label='Model',
|
50 |
interactive=False,
|
51 |
), gr.Checkbox(
|
52 |
+
value=doc2query.append,
|
53 |
label="Append",
|
54 |
), gr.Slider(
|
55 |
minimum=1,
|
56 |
maximum=10,
|
57 |
+
value=doc2query.num_samples,
|
58 |
step=1.,
|
59 |
label='# Queries'
|
60 |
)],
|
61 |
outputs=[gr.Dataframe(
|
62 |
headers=["docno", "text", "querygen"],
|
63 |
datatype=["str", "str", "str"],
|
64 |
+
col_count=3,
|
65 |
row_count=1,
|
66 |
wrap=True,
|
67 |
label='Pipeline Output',
|
68 |
+
value=doc2query(example_inp),
|
69 |
), gr.Markdown()],
|
70 |
title="π PyTerrier: Doc2Query",
|
71 |
description=open('README.md', 'rt').read().split('---\n')[-1],
|
72 |
allow_flagging='never',
|
73 |
css="table.font-mono td { white-space: pre-line; }",
|
74 |
+
).launch(share=False)
|