Spaces:
Runtime error
Runtime error
Sean MacAvaney
commited on
Commit
β’
adbdb15
1
Parent(s):
506b8cf
updage
Browse files
README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.7
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: PyTerrier Doc2Query
|
3 |
+
emoji: π
|
4 |
+
colorFrom: #F25F5C
|
5 |
+
colorTo: #6096BA
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.7
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
This is a demonstration of [PyTerrier's Doc2Query package](https://github.com/terrierteam/pyterrier_doc2query). Doc2Query generates
|
13 |
+
queries for a document, which can then be appended to a document's text before indexing to boost important terms and add missing terms.
|
14 |
+
|
15 |
+
Try it below!
|
app.py
CHANGED
@@ -12,15 +12,16 @@ def df2code(df):
|
|
12 |
{rows}
|
13 |
])'''
|
14 |
|
15 |
-
def predict(input, append):
|
16 |
doc2query.append = append
|
|
|
17 |
code = f'''
|
18 |
**Code:**
|
19 |
|
20 |
```python
|
21 |
import pandas as pd
|
22 |
from pyterrier_doc2query import Doc2Query
|
23 |
-
doc2query = Doc2Query(append={append})
|
24 |
doc2query({df2code(input)})
|
25 |
```
|
26 |
'''
|
@@ -39,6 +40,12 @@ gr.Interface(
|
|
39 |
), gr.Checkbox(
|
40 |
value=False,
|
41 |
label="Append",
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
)],
|
43 |
outputs=[gr.Dataframe(
|
44 |
headers=["docno", "text", "querygen"],
|
@@ -50,5 +57,6 @@ gr.Interface(
|
|
50 |
value=[["[docno]", "[text]", "[querygen]"]],
|
51 |
), gr.Markdown()],
|
52 |
title="PyTerrier: Doc2Query",
|
|
|
53 |
allow_flagging='never',
|
54 |
).launch()
|
|
|
12 |
{rows}
|
13 |
])'''
|
14 |
|
15 |
+
def predict(input, append, num_samples):
|
16 |
doc2query.append = append
|
17 |
+
doc2query.num_samples = num_samples
|
18 |
code = f'''
|
19 |
**Code:**
|
20 |
|
21 |
```python
|
22 |
import pandas as pd
|
23 |
from pyterrier_doc2query import Doc2Query
|
24 |
+
doc2query = Doc2Query(append={append}, num_samples={num_samples})
|
25 |
doc2query({df2code(input)})
|
26 |
```
|
27 |
'''
|
|
|
40 |
), gr.Checkbox(
|
41 |
value=False,
|
42 |
label="Append",
|
43 |
+
), gr.Slider(
|
44 |
+
minimum=1,
|
45 |
+
maximum=10,
|
46 |
+
value=3,
|
47 |
+
step=1.,
|
48 |
+
label='# Queries'
|
49 |
)],
|
50 |
outputs=[gr.Dataframe(
|
51 |
headers=["docno", "text", "querygen"],
|
|
|
57 |
value=[["[docno]", "[text]", "[querygen]"]],
|
58 |
), gr.Markdown()],
|
59 |
title="PyTerrier: Doc2Query",
|
60 |
+
description=open('README.md', 'rt').read().split('---\n')[-1],
|
61 |
allow_flagging='never',
|
62 |
).launch()
|