Skip to contents

Ask a question in plain language about a data frame, using a table question-answering model (such as TAPAS) via the Hugging Face Inference Providers API. The data frame is converted to the string-cell format the API expects; all values are coerced to character.

Usage

hf_table_question_answer(
  query,
  table,
  model = hf_default_model("table_question_answer"),
  token = NULL,
  endpoint_url = NULL,
  ...
)

Arguments

query

Character vector of question(s) to ask about the table.

table

A data frame to query.

model

Character string. Model ID from the Hugging Face Hub. Append `":provider"` to select an inference provider. Default: "google/tapas-base-finetuned-wtq".

token

Character string or NULL. API token for authentication.

endpoint_url

Character string or NULL. A custom Inference Endpoint URL.

...

Additional arguments (currently unused).

Value

A tibble with columns: query, answer, aggregator, cells (a list-column of the source cells the answer was drawn from).

Examples

if (FALSE) { # \dontrun{
sales <- data.frame(
  product = c("Widgets", "Gadgets", "Gizmos"),
  revenue = c(120, 80, 50)
)
hf_table_question_answer("Which product had the highest revenue?", sales)
hf_table_question_answer("What is the total revenue?", sales)
} # }