Spaces:
Runtime error
Runtime error
Create app3.py
Browse files
app3.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# prepare table + question
|
| 5 |
+
data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]}
|
| 6 |
+
table = pd.DataFrame.from_dict(data)
|
| 7 |
+
question = "how many movies does Leonardo Di Caprio 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
|