table_questions2 / app3.py
king007's picture
Duplicate from king007/table_questions
082cde2
raw history blame
No virus
512 Bytes
from transformers import pipeline
import pandas as pd
# prepare table + question
data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]}
table = pd.DataFrame.from_dict(data)
question = "how many movies does Leonardo Di Caprio 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