search-app / table-question.py
kblmike's picture
listing question
a5b2f6f
from transformers import pipeline
import pandas as pd
# prepare table + question
data = {"Neighborhood": ["Upper East Side", "Soho", "Upper West Side"], "Number of Apartments": ["87", "53", "69"]}
table = pd.DataFrame.from_dict(data)
question = "how many apartments does Upper East Side have?"
# pipeline model
# Note: you must to install torch-scatter first.
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
# result
print(tqa(table=table, query=query)['cells'][0])
#53