Skip to main content

cacheverifier

CI PyPI Python

Python client for CacheVerifier — a hosted API that verifies semantic-cache hits. Given a query and a candidate cached answer, it approves or rejects serving that answer from cache, so a similarity match that is close but wrong doesn't become a silent error in your app.

CacheVerifier does not run your cache or do similarity search. Your cache backend does its own lookup first; you call verify() only on the candidates in the similarity "gray zone", where a plain threshold match might be wrong.

Install

pip install cacheverifier
# with the GPTCache adapter:
pip install "cacheverifier[gptcache]"

Requires Python 3.9+. The only runtime dependency is httpx.

Quickstart

Get a free API key at https://www.cacheverifier.com (self-serve verify and fine-tuning are free forever, no card).

from cacheverifier import CacheVerifier

cv = CacheVerifier(api_key="cv_...")

query = "how do I cancel my subscription"
candidate = "Go to Settings > Billing > Pause subscription for a month."  # from your cache

result = cv.verify(query, candidate)
if result.approved:
    answer = candidate                       # verified hit — skip the LLM call
else:
    answer = call_your_llm(query)            # not trustworthy — fall through

# Later, once you know if it was actually right (thumbs-down, reopened ticket, ...):
cv.feedback(query, answer, was_correct=True, similarity_score=0.86)

verify() returns a VerifyResult:

field meaning
approved serve the cached answer (True) or fall through (False)
score / threshold approved is score >= threshold
model_version "stock", "v<id>" (fine-tuned), or "cold_start_fail_closed"
latency_ms server-side inference time

GPTCache

Drop the verifier into a GPTCache pipeline as its similarity evaluator — no fork required:

from gptcache import cache
from cacheverifier.integrations.gptcache import CacheVerifierEvaluation

evaluator = CacheVerifierEvaluation(api_key="cv_...")
cache.init(similarity_evaluation=evaluator, ...)

# when you learn a served hit's real outcome:
evaluator.report_feedback(query, answer, was_correct=False, similarity_score=0.9)

See examples/gptcache_example.py.

Fine-tuning

Once you have ~20+ feedback rows (the service found fine-tuning is often a net negative below ~1,000 on the hardest data — see the research), train a verifier on your own gray-zone labels:

job = cv.finetune()                       # or cv.finetune(target_risk=0.01, cost_ratio=5.0)
job = cv.get_finetune_job(job["id"])      # poll until status == "done"
print(job["auc_baseline"], job["auc_tuned"])

# a model can finish as "held_for_review" — promote it explicitly:
if job.get("result_model_version"):
    cv.activate_model_version(job["result_model_version"])

cv.dry_run([...]) reports the same baseline-vs-tuned AUC on examples you pass directly, without writing anything or deploying a model.

API surface

method endpoint
verify(query, candidate_answer) POST /v1/verify
verify_batch(pairs) POST /v1/verify/batch
feedback(...) / feedback_batch(items) POST /v1/feedback / /batch
finetune(...) / dry_run(examples, ...) POST /v1/finetune/jobs / /dry-run
get_finetune_job(id) / list_finetune_jobs() GET /v1/finetune/jobs[/id]
activate_model_version(id) POST /v1/finetune/model-versions/{id}/activate
drift_status() GET /v1/monitor/drift-status
gray_zone_threshold() GET /v1/monitor/gray-zone-threshold
usage() / savings() GET /v1/usage/status / /savings

Non-2xx responses raise CacheVerifierError (.status_code, .detail).

License

MIT — see LICENSE. (The research repository is separately licensed; this client is not.)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacheverifier-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cacheverifier-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file cacheverifier-0.1.0.tar.gz.

File metadata

  • Download URL: cacheverifier-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cacheverifier-0.1.0.tar.gz
Algorithm Hash digest
SHA256 501f20a72ffaaa99a39da6b74445044ddd7124be306465281ae18a39b5e7139e
MD5 5c610eead82d3c5d0678f2c041004f2f
BLAKE2b-256 cb9837b631c43170beae2fefe292aa2717d197eb47509d832201779bbf71bfb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cacheverifier-0.1.0.tar.gz:

Publisher: publish.yml on imxinchengyou/cacheverifier-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cacheverifier-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cacheverifier-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cacheverifier-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 581ab1d379d8f217b7ca113e3b24f62ea8e47be4c5601d5d7b21aa49f6eb6773
MD5 5d7b113d23d2479678730b1ebdff8815
BLAKE2b-256 dcba26c71336d61436d35189a4d56649e96b08e40d66c30446972de17bd8fb62

See more details on using hashes here.

Provenance

The following attestation bundles were made for cacheverifier-0.1.0-py3-none-any.whl:

Publisher: publish.yml on imxinchengyou/cacheverifier-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page