Skip to main content
A Cache stores model responses so you can rerun a job using the same responses when the inputs match. This is useful when extending a study: matching calls can reuse earlier responses while new inputs receive new answers. A cache matches individual model calls using their prompts, model settings, and iteration. It differs from a saved Results object, which you reopen to analyze the already-collected dataset without running the job again.

Run with an explicit local cache

This example uses the test model, makes no paid model calls, and disables hosted execution, API proxying, and remote caching. It writes a cache file in the current directory.
The first run fills the empty cache; the second reuses its entry. Both return the fixed test answer in this example. Inspect second.select("cache_used.*") to see the reuse indicator; identical answer text alone would not tell you whether a new call occurred. saved_cache contains the entries written to feedback-cache.jsonl. Use a configured provider model in place of Model("test", ...) for real responses. Locally orchestrated execution can still call a remote provider and incur costs. An empty Cache starts without stored responses; it does not make a real model free or offline.

Preserve and reload

write_jsonl() and from_jsonl() provide a portable cache file. SQLite persistence is available through write_sqlite_db() and from_sqlite_db(). Load a saved cache and pass it to job.run(cache=cache) to reuse its responses. Save and load completed Results with results.save() and Results.load(); see Saving objects.

Fresh responses and remote cache

To request new model responses with local orchestration, pass a new Cache() together with disable_remote_inference=True and disable_remote_cache=True. For hosted execution, run(offload_execution=True, fresh=True) requests new responses. In this version, fresh=True alone does not bypass entries already in a supplied local cache. Expected Parrot’s remote cache is a separate hosted service. disable_remote_cache=True controls remote cache access; it does not disable local reuse or hosted execution by itself.

Common methods

To reuse the cache saved by the example above in another session:

Inspect, select, and combine entries

cache.select("model", "user_prompt", "output") returns a Dataset for inspection. to_scenario_list(), to_dataset(), and to_pandas() provide other representations. Each stored entry contains model parameters, system and user prompts, the raw model output, and iteration information. See Remote caching for downloading hosted entries by job UUID or cache key.