Using Hugging Face datasets in promptfoo evals

Teams that want public or gated Hugging Face datasets as promptfoo test cases need a repeatable load path, not a one-off script. This page covers the huggingface://datasets/ source, split and row choices, field mapping, access tokens and the checks that prove the loaded rows are what the eval expects.

On this page

How Hugging Face datasets feed promptfoo evals

A team with a labeled dataset on Hugging Face can use it directly as promptfoo test cases without exporting it to a file first. promptfoo loads these datasets through a huggingface://datasets/ source in the eval configuration, and each dataset row becomes one test case whose fields fill the prompt variables. For example (illustrative), a row with question and reference_answer columns fills a {{question}} placeholder in the prompt, while the reference answer stays available to assertions that compare the model output against it. The dataset is therefore an input to every run, so changes upstream reach the next eval.

The evals run on the machine where the CLI runs, and promptfoo talks to the model under test directly from there. The dataset is fetched into that same environment, so a laptop, CI runner or server that executes the eval needs a network path to Hugging Face and enough room for the data. Plan for three things: which machines may hold a copy of the dataset, whether your use matches the license and any gating terms shown on the dataset page, and where credentials for gated datasets live. Confirm how the token reaches the CLI process in each runner and developer environment before the first run, and keep it out of the configuration file your team commits.

Decide the dataset split, row count and revision before the suite is built, because each choice changes what the eval measures and which results can be compared over time. Keep each Hugging Face datasets source in the same reviewed configuration as the prompts and assertions, so a change to any of them shows up in version control. Exact option names and syntax for splits, row limits, field mapping and revision pinning can change between releases, so confirm them in the current promptfoo documentation and record the promptfoo version your team tested against.

What you need before pointing promptfoo at Hugging Face

Each card is a condition the eval host must meet before promptfoo can load a Hugging Face dataset. Work through them in order, since a provider or network problem is easier to find before the first full run than after a dataset download fails partway through.

promptfoo and Node.js versions

Install promptfoo from npm and pin the exact version your team tests against. The 0.124.1 release, published on 8 October 2026, requires Node.js 22.22.0 or newer, so check that Node.js version on every laptop and CI runner that runs the eval. Record the pinned version in your lockfile so an upgrade does not change how dataset loading behaves. Confirm the version you pin against the npm and GitHub release pages before you start.

npm package page

Hugging Face account and dataset access

Gated datasets only load for accounts that have been granted access, so sign in with the account the eval host will use and request access on the dataset page before the first run. Accept the dataset's access terms on that page and confirm the account can reach the split you plan to use. Prefer a named account per team where possible, so access can be removed when someone changes roles or leaves. Record which account owns the token so rotation has an owner.

Network egress from the eval host

The machine running promptfoo must reach Hugging Face to fetch dataset files, and it must also reach your model provider endpoints. Ask your network team which hostnames your proxy or firewall allows, then test both paths from the same host and user account that runs the eval. Restricted or air-gapped hosts need a documented way to stage dataset files in advance, so the run can be repeated later. Check proxy settings in CI runners separately from developer laptops.

Working provider configuration

Confirm the provider for the model under test works before you connect a dataset. A broken provider setup can look like a dataset problem, which slows down diagnosis. Start with a two-row sample from the dataset, one prompt and one assertion, and check that the output is graded as you expect. Keep the provider block in the same config file you will use for the full run so the two stay in step.

Token storage decision

Decide where the Hugging Face token lives before you write the config. Keep the token out of your config file and out of version control, and supply it through an environment variable or your CI secret store. Confirm in the promptfoo documentation which variable name your version reads for Hugging Face tokens, since a wrong name can cause an authentication error that looks like an access problem. Keep the dataset token separate from model provider keys, so one can be rotated without touching the other.

Dataset license and terms

Confirm the dataset license and terms of use before you load anything, because they govern what you may run through a model, store in eval results and share with reviewers. Read the license on the dataset card and check whether the terms restrict commercial use, redistribution or use with particular model providers. Record the license and the date you checked it alongside the eval config, so a reviewer can see what was permitted when the run happened. Ask your legal or compliance contact if the terms are unclear.

Configuring a Hugging Face dataset step by step

This sequence takes a public or gated Hugging Face dataset from an unconfirmed name to a small, verified eval run in promptfoo. Each step closes with a check you can repeat, so a wrong split, a missing token or a broken field mapping shows up before the full dataset loads. The result is a pinned, reviewed test configuration that loads a known number of rows.

  1. Pin the promptfoo version

    Record the exact promptfoo version your team tests against before you load any dataset, so an upgrade cannot change how the data loads without a deliberate decision. The engineer running the eval does this by installing a fixed version in the project and committing the lock file. The npm release 0.124.1 requires Node.js 22.22.0 or newer, so check the Node version on every runner first. Promptfoo on npm lists the published releases. Done when promptfoo --version prints the same number on every machine and CI runner that will run the eval.

  2. Confirm the dataset ID and access

    Copy the exact dataset ID from the Hugging Face dataset page, including the owner name, and note whether the dataset is public or gated. A gated dataset needs an access request approved for the account that runs the eval, plus a token available to the runner, so ask the data owner who holds that approval before you write the config. Store the token in your secrets manager, not in a config file committed to version control. Done when the person who will run the eval can open the dataset page while signed in as that account and see the data files without an access prompt.

  3. Add the Hugging Face entry to the test config

    In the test configuration, add an entry that uses the huggingface://datasets/ prefix followed by the dataset ID, for example huggingface://datasets/owner/dataset-name (illustrative). If your suite already splits tests across files, place the entry in the file for this suite so the change is easy to review. Confirm the exact syntax for your pinned version in the promptfoo documentation before you copy it. Done when promptfoo accepts the configuration without a parse or validation error on the pinned version.

  4. Select the split to evaluate

    Choose the split, such as train, validation or test, that matches the purpose of this eval, and set it using the option your pinned version documents. Use one split per suite so that repeated runs compare the same rows. If the dataset card does not explain which split holds reviewed cases, ask the data owner before you choose. Done when you have written down the split name and its row count as listed on the dataset page, so the check in the row limit step has a target to compare against.

  5. Set a row limit for the first run

    Cap the number of rows for the first run so a wrong field mapping or a missing token fails quickly, before a full split loads. Set the limit with the option your pinned version documents and confirm its syntax there. Then run the loader and count the cases it reports. If the limit is 10 (illustrative) and the output lists 10 cases, the limit applied. If it lists the full split size, the limit was not applied and the config needs a fix. Done when the loaded count equals the limit you set.

  6. Map dataset fields to prompt variables

    Map each dataset column to the prompt variable it fills, for example a question column feeding a question variable (illustrative), and map any expected-answer column to the assertion that uses it. Publishers set column names, so check them in the dataset viewer or a few sample rows before you write the mapping. Keep all mappings in one place so a renamed column becomes a single edit. Done when a dry run or single-case output shows the prompt filled with actual values from a dataset row and no empty variable placeholders.

  7. Run a small eval and verify results

    Run the eval with one provider and the row limit from the earlier step, so you can read each output by hand. Confirm that the number of test cases in the results matches the limit, that every row came from the split you chose, and that no row failed with a missing field or missing token error. Check a few outputs against their expected answers to confirm the assertions grade correctly. Done when the run completes with the expected count and every failure reflects answer quality, not configuration. Remove the row limit only after this check passes.

Mapping dataset fields to prompt variables

This table maps each Hugging Face dataset column to the prompt variable it fills, the assertion that checks it, and what to confirm about types and empty cells. Read each row as one field in your dataset, and treat the first column as the name you must match exactly in your prompt file. The main takeaway is that a name mismatch leaves a variable unfilled, so check names and empty values before trusting a run.

Dataset columnPrompt variableExpected value or assertion sourceNotes on types and nulls
questionVariable named question in the prompt templateNone; this is the input the model answersConfirm how an empty string is handled before the model call
expected_answerUsually none; add one only if the prompt needs the referenceAssertion source: any check that compares the output with this fieldNot used by the prompt unless referenced; confirm it loads as text
contextVariable named context, if the prompt uses supporting textNone, unless an assertion checks that the answer uses the contextLong text is common; confirm any trimming the loader applies
labelVariable named label, for classification promptsAssertion source for exact-match or category checksInteger labels may arrive as text; confirm the type in the release you run
rubric_scoreNumeric value referenced by the prompt or a grader, if anyAssertion threshold, referenced by name in the assertionNumbers may load as strings; confirm before comparing them numerically
Unused column, such as id or source_urlNo variable; the column is not referenced in the promptNone, unless an assertion or report field refers to itConfirm whether unused columns are kept as metadata for reporting
Misspelled or renamed columnVariable stays unfilled because the names do not matchAssertion referencing the old name also loses its valuePrompt does not receive the value; confirm what the rendered prompt shows

How a Hugging Face row becomes a test case

The walk starts on the eval host, where the config files name a huggingface://datasets/ source and the promptfoo CLI requests rows. Hugging Face sits across the first trust boundary: a public dataset needs no token, while a gated one needs a token the CLI can read. Returned rows pass through the chosen split and row limit, then field mapping turns columns into prompt variables. The provider under test sits across the second boundary, so every rendered prompt leaves the host. Assertions grade the outputs, and results stay in the local store. Check what crosses each boundary and where the token lives.

Data leaves the eval host at the dataset request and the provider call.

Choosing splits and limiting rows for fast, repeatable evals

The split you load decides what your score means. A train split and a test split answer different questions: the train split is data a model or prompt was tuned against, so a high score there mostly measures memorization, while a held-out test split is closer to how the application behaves on inputs it has not seen. If you read failures from a dataset and adjust prompts until they pass, that same dataset cannot also serve as your final quality gate. Decide before the first run which split is the regression gate and which one you tune against, then record that decision as a comment in the config file. Load the dataset with the huggingface://datasets/ prefix, and confirm in the promptfoo documentation for your version the exact split option name and its accepted values, because this page does not establish them.

Row limits keep first runs cheap and fast. A public dataset can hold thousands of rows, and each row multiplies provider calls, assertion checks and any LLM-as-a-judge grading, so a small sample lets you confirm that field mapping, prompt variables and assertions behave as intended before you pay for a full run. Confirm the row limit option name for your promptfoo version, and confirm whether the loader takes the first rows of a split or a sampled subset. Also ask whether row ordering is deterministic in that version. If ordering can change between runs, the same config may test different rows each time, and the scores stop being comparable.

A limited sample must be fixed and recorded, or later runs will not compare like with like. Once you settle on a split and limit, treat that combination as a versioned test set: keep the dataset identifier, split, limit and any offset or seed option in the config under version control, and note the promptfoo version and the model under test in each eval's description. If you later raise the limit, change the split or pin a different dataset revision, label the result as a new baseline and do not set it beside earlier scores. Ask the team that owns the eval whether the upstream dataset can change under the same identifier, because an update on Hugging Face can shift the sample even when your config has not changed.

Keeping gated dataset tokens and sensitive rows under control

Gated Hugging Face datasets bring access tokens, and often personal or regulated rows, into your eval runs. The controls below cover where the token lives, how far it reaches, what data leaves your network, and how results stay traceable. Each card is a decision your team should make and record before the first shared run.

Keep tokens out of configs

Store the Hugging Face token in your CI secret store or a vault, and have the run read it from the environment at execution time. Never write it into the promptfoo config file, because that file is committed to version control, shared across teams and copied into pull requests. Check the repository history and recent forks for any token that was committed by mistake, and rotate any token that has appeared in one.

Scope the token to the dataset

Create a dedicated token for the eval job instead of reusing a personal account token. Use a read-only token, and confirm that the account behind it has been granted access to each gated dataset the suite loads. Gated datasets usually need an access request approved by the dataset owner, so a token from an account without that approval may fail the run. Limit the token's scope to what the dataset needs, and revoke it when the eval owner leaves the team or the suite is retired.

Check rows for regulated data

Every row you load is sent to the model provider as part of the prompt, and graders may send row content again. Before the first run, review the columns the mapping passes into prompt variables, and decide whether personal, health, financial or other regulated fields may leave your network under your provider agreement. Drop or pseudonymize fields the eval does not need, and use the row limit to keep samples small. Ask your privacy or compliance lead to sign off on the dataset and provider pair, and record that decision with the suite.

Record the dataset revision

A result is only reproducible if you know which snapshot of the dataset produced it. Hugging Face datasets can change over time, so pin the revision the suite should load and write it into the config or run notes next to the split and row limit. Confirm how your promptfoo version selects a revision for a huggingface://datasets/ source, because the syntax for pinning may differ between releases. Re-run a baseline when you change the revision so score shifts are not blamed on the model.

Restrict who edits dataset sources

The dataset path, split and row limit decide what the suite tests, so a change to any of them changes the meaning of every past score. Treat them as controlled settings: keep them in files with protected branches and required reviewers, and assign code owners to the config directory. Review changes that switch a dataset, widen a split or raise a row limit as carefully as changes to assertions. Confirm with your Git host how owner approval and branch protection are configured for these files, since the available controls depend on your hosting plan.

Keep token handling off the server

The self-hosted promptfoo server stores data in a local SQLite database, has no built-in authentication or SSO, and is not recommended for production use. Do not rely on it to hide tokens, restrict who views a run, or separate teams. Token handling should work without it, so the server never becomes the only place a credential is managed. If your team uses the server anyway, check that run output, logs and stored results contain no token values, and read the self-hosting guide before deploying it for a team.

Self-hosting guide

Why Hugging Face dataset loads fail in promptfoo

This table maps the most common Hugging Face dataset load failures in promptfoo to their likely causes and fixes. Read each row by matching the symptom you see, then check the cause in your config and environment before changing anything. Error messages change between releases, so confirm the exact text against your installed promptfoo version before acting on it.

SymptomLikely causeFix
Access error when loading a gated datasetNo Hugging Face token is set, or access to the dataset was never granted to your accountRequest access on the dataset page, then set a read token in the environment where the eval runs
Results come from an unexpected splitThe split is not named, or the name does not match a split listed on the dataset pageName the split you need explicitly and check the split names on the dataset page
Fewer rows than the dataset holdsA row limit in the config caps how many rows loadReview the limit setting, remove it for a full run, and confirm the row count matches the split
Prompt variables render emptyDataset column names do not match the variable names used in your prompt or test mappingList the dataset columns, then map each one to the variable name your prompt expects
Load stalls or fails with a network error on the eval hostA proxy or firewall blocks outbound requests to Hugging FaceConfirm outbound access with your network team, and set the proxy settings your environment requires
Load fails before any test runsNode.js is older than the minimum version the promptfoo release requiresUpgrade to Node.js 22.22.0 or newer, the minimum stated for promptfoo 0.124.1 on npm, then rerun

Public versus gated datasets: what changes in the setup

For a public dataset, the setup work is mostly about the network path and the terms check. The eval host needs outbound HTTPS access to Hugging Face so promptfoo can read the dataset through the huggingface://datasets/ prefix. A public dataset usually does not require a token, but confirm that for each dataset before you rely on it.

  • Outbound network path: Allow the eval host, and any proxy it uses, to reach Hugging Face. Test from the same host and user that will run the eval, not from a developer laptop.
  • Dataset card and license: Read the license, the intended use and any stated limitations on the dataset card. Keep a link or a copy with the eval repository.
  • Approver for the terms: Name the person who signs off on each dataset's use. In regulated work this is usually a legal, privacy or data governance contact.
  • Run record: Record the dataset name, the split and the date you pulled it, so a later run can be compared against the same rows.
  • CI egress: Confirm that CI runners have the same outbound path. A pull that works on a laptop can fail on a locked-down runner.

Check with Hugging Face which access model applies to each dataset you plan to use, because a dataset that looks public can still carry conditions.

What Hugging Face dataset work costs and needs from your team

Does the promptfoo part of Hugging Face dataset loading cost anything?

The promptfoo side is free for teams using the Community edition, which includes all LLM evaluation features and all model providers and integrations. Loading a dataset with the huggingface://datasets/ prefix is part of running evals, so it should fall within that free set, but confirm that the loader and the Hugging Face access behavior you need are covered in the promptfoo version you pin. Check the current edition details on the pricing page. Your ongoing costs are the model API usage each eval run generates, which your model provider bills, plus any account or token management your organization requires. Any paid partner work is quoted separately from a written scope.

What makes a Hugging Face dataset integration take more effort?

Effort rises with the number of datasets, how far their fields differ from the prompt variables you need, and how many access steps sit in front of them. The main drivers are:

  • Number of datasets, each with its own splits, row limits and field names
  • Field mapping complexity, especially nested fields, several columns feeding one variable, or values that need cleaning first
  • Gated access approvals, which the dataset owner controls and which can add waiting time
  • CI integration, where tokens, caching and pinned versions must work in unattended runs
  • Review of sensitive rows, when a sample contains personal or regulated data and someone must approve what reaches test runs

A single public dataset with plain columns is the smallest case. Ask any partner to break its estimate down by these drivers.

How long does a first Hugging Face dataset setup take?

The duration depends on the written scope, so no fixed number applies across engagements. A scope covering one public dataset with a few fields to map moves faster than one covering several gated datasets, CI wiring and a review of sensitive rows. Ask the quote to show which items the timeline covers, such as access requests, field mapping, a validation run on your sample, CI integration and handover notes. Gated datasets add a wait the owner controls, so ask how the plan handles approval delays and who on your side must follow up. Most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, so the timeline becomes a commitment you can hold the partner to.

What do we need to provide for a Hugging Face dataset project?

Your team provides four things, and the work slows down without any one of them.

  • Repository access to the promptfoo configuration, the CI pipeline and the secret store where the token will live
  • Dataset access decisions, including which datasets are approved, who requests gated access and whose account holds it
  • A token owner, meaning a named person or service account responsible for the Hugging Face token, its scope and its rotation
  • A sample of rows, reviewed by a domain owner, so the field mapping can be validated before full runs

Name these owners in the quote. If your organization restricts which external data can enter test runs, the dataset decisions must come from the people who can approve that use.

Can our own engineers set up a Hugging Face dataset in promptfoo?

Yes, for a single public dataset with straightforward columns, a team that already runs promptfoo can usually do the work in-house. The setup steps on this page cover the huggingface://datasets/ prefix, choosing a split, limiting rows and mapping fields to prompt variables, and the checks in those steps show whether the loaded rows match what you expected. Consider a partner when you have gated datasets that need access approvals, several datasets with different schemas, CI runs that must use a token safely, or sensitive rows that need review before they reach a model. Your team can still handle those steps, but they are easier to get wrong without a second reviewer. DeployOpen implements these setups inside your own cloud accounts, data centers or air-gapped networks.

What should we ask for in a quote for dataset work?

Ask for a quote built from a written scope that names each dataset, its access route and the owner of each approval. The quote should list deliverables you can check, such as a working loader configuration per dataset, a field mapping document, a validation run on your sample, CI integration and handover notes. Ask which items are one-time work, such as the first setup, and which recur, such as dataset refreshes, promptfoo version upgrades and token rotation, and whether a retainer covers them. Confirm what you must provide and how the plan changes if gated access is delayed, including the effect on the schedule and cost. Ask which promptfoo version and edition the work targets and how loaders are tested against it. DeployOpen does not publish a price list, so the quote follows from the written scope.

How DeployOpen scopes Hugging Face dataset evals

DeployOpen approaches Hugging Face datasets in promptfoo evals as a scoped piece of work inside your own evaluation setup. We agree in writing which datasets, splits, row limits and field mappings are in scope, then build and document the loader configuration so your team can rerun it. Engagements are fixed-scope, and ongoing support is available as a retainer.

How we scope

  • Inventory each dataset, its license terms, whether it is public or gated, and who holds the access token.
  • Fix the split, row limit and field-to-variable mapping for each eval before any config is written.
  • Put these choices in the written scope, with the named datasets and the eval suites they feed.

How we build

  • Write the huggingface://datasets/ references in promptfoo config files, using the agreed split and row limit.
  • Map dataset columns to prompt variables and check each mapping against a sample of loaded rows.
  • Keep access tokens in environment variables or your secrets store, never in committed config files.

How we hand over

  • Deliver the config files, a dataset register and a short runbook covering split, limit and token setup.
  • Walk through a test run with your team so they can load a dataset and read the results themselves.
  • Record the dataset versions and revisions used in each eval so later runs can be compared fairly.

How we support

  • Offer ongoing support as a retainer for dataset refreshes, config changes and promptfoo upgrades.
  • Re-check loader settings when a dataset owner changes its splits, schema or access terms.
  • Confirm with your security team whether gated dataset access and token handling need review before rollout.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.