Inference Providers documentation
Table Question Answering
Table Question Answering
Table Question Answering (Table QA) is the answering a question about an information on a given table.
For more details about the table-question-answering
task, check out its dedicated page! You will find examples and related materials.
Recommended models
- microsoft/tapex-base: A table question answering model that is capable of neural SQL execution, i.e., employ TAPEX to execute a SQL query on a given table.
- google/tapas-base-finetuned-wtq: A robust table question answering model.
Explore all available models and find the one that suits you best here.
Using the API
Copied
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="hf-inference",
api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxx",
)
answer = client.question_answering(
query="How many stars does the transformers repository have?",
table={"Repository":["Transformers","Datasets","Tokenizers"],"Stars":["36542","4512","3934"],"Contributors":["651","77","34"],"Programming language":["Python","Python","Rust, Python and NodeJS"]},
model="google/tapas-base-finetuned-wtq",
)
API specification
Request
Headers | ||
---|---|---|
authorization | string | Authentication header in the form 'Bearer: hf_****' when hf_**** is a personal user access token with “Inference Providers” permission. You can generate one from your settings page. |
Payload | ||
---|---|---|
inputs* | object | One (table, question) pair to answer |
table* | object | The table to serve as context for the questions |
question* | string | The question to be answered about the table |
parameters | object | |
padding | enum | Possible values: do_not_pad, longest, max_length. |
sequential | boolean | Whether to do inference sequentially or as a batch. Batching is faster, but models like SQA require the inference to be done sequentially to extract relations within sequences, given their conversational nature. |
truncation | boolean | Activates and controls truncation. |
Response
Body | ||
---|---|---|
(array) | object[] | Output is an array of objects. |
answer | string | The answer of the question given the table. If there is an aggregator, the answer will be preceded by AGGREGATOR > . |
coordinates | array[] | Coordinates of the cells of the answers. |
cells | string[] | List of strings made up of the answer cell values. |
aggregator | string | If the model has an aggregator, this returns the aggregator. |