| hf_question_answer | R Documentation |
Answer a question from a supplied context passage using an extractive question-answering model via the Hugging Face Inference Providers API. The answer is a span extracted verbatim from the context. 'question' and 'context' are recycled to a common length (each may be length 1).
hf_question_answer(
question,
context,
model = hf_default_model("question_answer"),
token = NULL,
endpoint_url = NULL,
...
)
question |
Character vector of question(s). |
context |
Character vector of context passage(s) to answer from. |
model |
Character string. Model ID from the Hugging Face Hub. Append '":provider"' to select an inference provider. Default: "deepset/roberta-base-squad2". |
token |
Character string or NULL. API token for authentication. |
endpoint_url |
Character string or NULL. A custom Inference Endpoint URL. |
... |
Additional arguments (currently unused). |
A tibble with columns: question, answer, score, start, end.
https://huggingface.co/docs/inference-providers/tasks/question-answering
## Not run:
hf_question_answer(
question = "Where was Obama born?",
context = "Barack Obama was born in Honolulu, Hawaii."
)
# One context, several questions
hf_question_answer(
question = c("Who?", "Where?"),
context = "Ada Lovelace worked in London."
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.