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.
Explore all available models and find the one that suits you best here.
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="hf-inference",
api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxx",
)
result = client.table_question_answering(
inputs={
"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",
)| 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. |
| 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. |