Spaces:
Runtime error
Runtime error
Julien Simon
commited on
Commit
·
54c2f4d
1
Parent(s):
cc07d78
Update
Browse files- app.py +25 -13
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -22,32 +22,40 @@ pipe_tapas = pipeline(
|
|
| 22 |
)
|
| 23 |
|
| 24 |
|
| 25 |
-
def process(query, file,
|
| 26 |
table = pd.read_csv(file.name, header=0).astype(str)
|
| 27 |
table = table[:rows]
|
| 28 |
result_tapex = pipe_tapex(table=table, query=query)
|
| 29 |
result_tapas = pipe_tapas(table=table, query=query)
|
| 30 |
-
return result_tapex["answer"], result_tapas["answer"]
|
| 31 |
|
| 32 |
|
| 33 |
# Inputs
|
| 34 |
query_text = gr.Text(label="Enter a question")
|
| 35 |
-
input_file = gr.File(label="Upload a CSV file", type="
|
| 36 |
rows_slider = gr.Slider(label="Number of rows")
|
| 37 |
|
| 38 |
# Output
|
| 39 |
answer_text_tapex = gr.Text(label="TAPEX answer")
|
| 40 |
answer_text_tapas = gr.Text(label="TAPAS answer")
|
| 41 |
|
| 42 |
-
description =
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
iface = gr.Interface(
|
| 53 |
theme="huggingface",
|
|
@@ -63,7 +71,11 @@ iface = gr.Interface(
|
|
| 63 |
"default_file.csv",
|
| 64 |
20,
|
| 65 |
],
|
| 66 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
["What is the average number of wins?", "default_file.csv", 20],
|
| 68 |
],
|
| 69 |
allow_flagging="never",
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
|
| 25 |
+
def process(query, file, rows=20):
|
| 26 |
table = pd.read_csv(file.name, header=0).astype(str)
|
| 27 |
table = table[:rows]
|
| 28 |
result_tapex = pipe_tapex(table=table, query=query)
|
| 29 |
result_tapas = pipe_tapas(table=table, query=query)
|
| 30 |
+
return result_tapex["answer"], result_tapas["answer"]
|
| 31 |
|
| 32 |
|
| 33 |
# Inputs
|
| 34 |
query_text = gr.Text(label="Enter a question")
|
| 35 |
+
input_file = gr.File(label="Upload a CSV file", type="filepath")
|
| 36 |
rows_slider = gr.Slider(label="Number of rows")
|
| 37 |
|
| 38 |
# Output
|
| 39 |
answer_text_tapex = gr.Text(label="TAPEX answer")
|
| 40 |
answer_text_tapas = gr.Text(label="TAPAS answer")
|
| 41 |
|
| 42 |
+
description = (
|
| 43 |
+
"This Space lets you ask questions on CSV documents with Microsoft "
|
| 44 |
+
"[TAPEX-Large](https://huggingface.co/microsoft/tapex-large-finetuned-wtq) "
|
| 45 |
+
"and Google [TAPAS-Large](https://huggingface.co/google/tapas-large-finetuned-wtq). "
|
| 46 |
+
"Both have been fine-tuned on the "
|
| 47 |
+
"[WikiTableQuestions](https://huggingface.co/datasets/wikitablequestions) dataset. \n\n"
|
| 48 |
+
"A sample file with football statistics is available in the repository: \n\n"
|
| 49 |
+
"* Which team has the most wins? Answer: Manchester City FC\n"
|
| 50 |
+
"* Which team has the most wins: Chelsea, Liverpool or Everton? Answer: "
|
| 51 |
+
"Liverpool\n"
|
| 52 |
+
"* Which teams have scored less than 40 goals? Answer: Cardiff City FC, "
|
| 53 |
+
"Fulham FC, Brighton & Hove Albion FC, Huddersfield Town FC\n"
|
| 54 |
+
"* What is the average number of wins? Answer: 16 (rounded)\n\n"
|
| 55 |
+
"You can also upload your own CSV file. Please note that maximum sequence "
|
| 56 |
+
"length for both models is 1024 tokens, so you may need to limit the number "
|
| 57 |
+
"of rows in your CSV file. Chunking is not implemented yet."
|
| 58 |
+
)
|
| 59 |
|
| 60 |
iface = gr.Interface(
|
| 61 |
theme="huggingface",
|
|
|
|
| 71 |
"default_file.csv",
|
| 72 |
20,
|
| 73 |
],
|
| 74 |
+
[
|
| 75 |
+
"Which teams have scored less than 40 goals?",
|
| 76 |
+
"default_file.csv",
|
| 77 |
+
20
|
| 78 |
+
],
|
| 79 |
["What is the average number of wins?", "default_file.csv", 20],
|
| 80 |
],
|
| 81 |
allow_flagging="never",
|
requirements.txt
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
transformers
|
| 2 |
torch
|
|
|
|
|
|
|
|
|
| 1 |
transformers
|
| 2 |
torch
|
| 3 |
+
gradio
|
| 4 |
+
pandas
|