Ask the data
Ask a question in plain language. An AI model writes a database query, the query runs here in your browser on the HERD data (FY 2012 to FY 2024), and the model explains the result. You can always open the query to see exactly what was counted. AI can misread a question or write the wrong query, so check important numbers on the Trends or Compare pages.
Don't have one? Get a free Gemini key
- Go to Google AI Studio and sign in with a Google account.
- On a first visit, a key is created for you. Otherwise, click Create API Key and choose a project with no billing account. A project linked to billing is charged at paid rates.
- Copy the key, paste it in the box above, and click Use key.
Free keys need no credit card, but they have limits per minute and per day, and one question can use several requests. Google may also use what you send to improve its products, and its reviewers may read it, so don't enter anything sensitive.
Which AI model answers
Your key decides the model:
- Google Gemini key:
, the best model on Google's free tier. - Anthropic key:
. Billed per question. - OpenAI key:
. Billed per question. - University of Idaho MindRouter key:
.
Anthropic and OpenAI questions are billed to the account that owns the key, and a chat subscription doesn't include an API key.
How the key is handled
- Kept in this tab. The key is held in session storage and clears when the tab closes.
- No server of ours. This site is static files on GitHub Pages, so nothing here stores or sees your key.
- Sent only to its provider, chosen by prefix.
sk-ant-goes to Anthropic and othersk-keys go to OpenAI.mr2_goes to University of Idaho MindRouter through the AI4RA lakehouse proxy. Anything else is treated as a Google Gemini key. - Removed from links. A key passed as
?key=on any page is read once and removed from the address bar.
Answers come from NCSES HERD Survey public microdata, FY 2012-2024, nominal dollars, with institution type from the 2021 Carnegie Classification. Queries are read-only and run in your browser; only your question and the query results (plus any help documents the model reads to answer a question about using the site) are sent to the AI provider you chose.
The AI model never sees the database. It writes SQL; your browser runs it; the model reads the results and answers. This is the approach of Data Crawler Carl, an open-source AI data explorer from AI4RA, applied here to the HERD data.
- The model is told what the data look like. Before your first question it receives a description of the tables, every measure with its meaning and coverage, the institution types, and rules for answering: dollars are in whole dollars, report them with commas, say which measure and years were used, never state a number that was not in the results.
- It can read help documents when you ask for help. The model starts with only a table of contents of the site's help documents. If you ask how to build a pivot table or chart, how the data were put together, or how the projections were modeled, it asks for the one or two documents it needs, your browser fetches them, and it answers from their text. Each answer lists the documents it read.
- It writes a query. The model answers your question with SQL in a marked block, for example:
SELECT i.name, m.year, m.value AS rd_dollars FROM metrics m JOIN institution_latest i USING (inst_id) WHERE m.measure_id = 'source_all_r_d' AND i.state = 'ID' ORDER BY m.year
- Your browser checks and runs it. Only a single SELECT is allowed. Anything that could read files or web addresses, change data, load extensions or run more than one statement is refused. The query runs in DuckDB, a database engine running inside this page, against the same data as the rest of the site. Results are capped at 1,000 rows.
- The model reads the results. Up to 60 rows go back to the model, which explains them in plain language. If a query failed or returned the wrong thing, it can write a corrected one, up to three rounds per question. If it is still querying after three, it must answer using only numbers the queries returned, or say plainly that it could not get the answer; it never estimates or fills in missing numbers.
- Charts are data, not code. When a chart helps, the model describes it (chart type, a query, which columns go on each axis). The page checks that description, runs the query, and draws the chart itself. Ask for an animation and the model picks from the Animate tab's fixed menu (bar race, line race, moving scatter or map, with its short list of measures and counts); the page refuses anything off the menu. Nothing the model writes is run as code.
- You can see the work. Every answer has a Show the SQL panel with the exact query and its results, so you can check what was counted.
What leaves your browser
- Your questions, the description of the data from step 1, the query results, and any help documents the model asks for in step 2 go to the AI provider your key belongs to. The HERD data themselves stay in your browser.
- Your key stays in this browser tab (session storage) and is sent only to its own provider. A key passed in a link
(
?key=...on any page of the site, such asindex.html?key=...) is read once and removed from the address bar. The key box and its routing by key prefix come from Promptulus:mr2_keys go to University of Idaho MindRouter,sk-ant-to Anthropic, othersk-keys to OpenAI, anything else to Google Gemini.
Limits
- The model can misread a question or pick the wrong measure. Open Show the SQL and check important numbers on the Trends or Compare pages.
- Answers cover FY 2012 to FY 2024. Questions about the future are pointed to the projections on Trends and Compare.
- Answers depend on the model behind your key; larger models write better queries.
Code: docs/ask.html and docs/js/llm.js.