Spaces:
Runtime error
Runtime error
listing question
Browse files- table-question.py +16 -0
table-question.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# prepare table + question
|
5 |
+
data = {"Neighborhood": ["Upper East Side", "Soho", "Upper West Side"], "Number of Apartments": ["87", "53", "69"]}
|
6 |
+
table = pd.DataFrame.from_dict(data)
|
7 |
+
question = "how many apartments does Upper East Side have?"
|
8 |
+
|
9 |
+
# pipeline model
|
10 |
+
# Note: you must to install torch-scatter first.
|
11 |
+
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
12 |
+
|
13 |
+
# result
|
14 |
+
|
15 |
+
print(tqa(table=table, query=query)['cells'][0])
|
16 |
+
#53
|