stanfordnlp/wikitablequestions
Updated • 1.35k • 35
How to use thealper2/tapas-wtq with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("table-question-answering", model="thealper2/tapas-wtq") # Load model directly
from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("thealper2/tapas-wtq")
model = AutoModelForTableQuestionAnswering.from_pretrained("thealper2/tapas-wtq", device_map="auto")google/tapas-base fine-tuned on WikiTableQuestions for table question answering with cell selection and aggregation (NONE / SUM / AVERAGE / COUNT).
Denotation accuracy is the fraction of questions whose predicted answer matches the gold answer after normalisation; it is the metric used for model selection.
| Split | Examples | Denotation acc. | Exact match | Cell selection acc. | Aggregation acc. |
|---|---|---|---|---|---|
| validation | 2483 | 0.3178 | 0.3178 | 0.2715 | 0.7412 |
import pandas as pd
from transformers import TapasForQuestionAnswering, TapasTokenizer
repo = "thealper2/tapas-wtq"
tokenizer = TapasTokenizer.from_pretrained(repo)
model = TapasForQuestionAnswering.from_pretrained(repo)
table = pd.DataFrame(
{"City": ["Paris", "Berlin", "Madrid"], "Population": ["2148000", "3645000", "3223000"]}
).astype(str)
inputs = tokenizer(table=table, queries=["Which city has the largest population?"],
return_tensors="pt")
outputs = model(**inputs)
coords, agg = tokenizer.convert_logits_to_predictions(
inputs, outputs.logits.detach(), outputs.logits_aggregation.detach()
)
print([table.iat[c] for c in coords[0]], agg)
learning_rate: 5e-05num_train_epochs: 4.0per_device_train_batch_size: 16gradient_accumulation_steps: 2weight_decay: 0.01warmup_ratio: 0.1lr_scheduler_type: linearmax_seq_length: 512seed: 42The full configuration is included as training_config.json, the per-step
training history as history.json.
Base model
google/tapas-base