| hf_generate | R Documentation |
Generate text from a prompt using a language model via the Inference Providers API.
hf_generate(
prompt,
model = hf_default_model("generate"),
max_new_tokens = 50,
temperature = 1,
top_p = NULL,
token = NULL,
endpoint_url = NULL,
...
)
prompt |
Character vector of text prompt(s) to generate from. |
model |
Character string. Model ID from Hugging Face Hub. Default: "meta-llama/Llama-3.1-8B-Instruct". |
max_new_tokens |
Integer. Maximum number of tokens to generate. Default: 50. |
temperature |
Numeric. Sampling temperature (0-2). Default: 1.0. |
top_p |
Numeric. Nucleus sampling parameter. Default: NULL. |
token |
Character string or NULL. API token for authentication. |
endpoint_url |
Character string or NULL. A custom Inference Endpoint URL. The endpoint must support the chat completions format. |
... |
Additional parameters passed to the model. |
A tibble with columns: prompt, generated_text
## Not run:
# Simple text generation
hf_generate("Once upon a time in a land far away,")
# With different model
hf_generate("The future of AI is", model = "meta-llama/Llama-3-8B-Instruct:together")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.