cacheverifier 0.9.0__tar.gz → 0.9.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/CHANGELOG.md +15 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/PKG-INFO +53 -35
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/README.md +52 -34
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/__init__.py +1 -1
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/pyproject.toml +2 -2
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/.github/workflows/ci.yml +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/.github/workflows/publish.yml +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/.gitignore +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/LICENSE +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/__main__.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/_healthcheck/__init__.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/_healthcheck/_base_models.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/_healthcheck/_finetune.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/_healthcheck/cli.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/_inference.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/client.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/integrations/__init__.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/integrations/_cold_start.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/integrations/_reporting.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/integrations/gptcache.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/integrations/langchain.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/local.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/cacheverifier/py.typed +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/examples/gptcache_example.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/examples/quickstart.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/tests/test_client.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/tests/test_gptcache_integration.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/tests/test_healthcheck.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/tests/test_langchain_integration.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/tests/test_local.py +0 -0
- {cacheverifier-0.9.0 → cacheverifier-0.9.1}/tests/test_reporting.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
Documentation only; no code changes.
|
|
6
|
+
|
|
7
|
+
- README opens with what the verifier checks and how it decides: a fine-tuned
|
|
8
|
+
cross-encoder scores each (question, cached answer) pair against a
|
|
9
|
+
threshold, with no LLM call. An LLM is involved only if you pass one as
|
|
10
|
+
`judge=`.
|
|
11
|
+
- Quickstart: the free tier's monthly verify calls are stated, and the
|
|
12
|
+
example no longer labels the same `verification_id` twice (the second label
|
|
13
|
+
gets a 409).
|
|
14
|
+
- Fine-tuning: the 20-row minimum and the ~1,000-row caveat no longer read as
|
|
15
|
+
contradicting each other.
|
|
16
|
+
- The package description says the same.
|
|
17
|
+
|
|
3
18
|
## 0.9.0
|
|
4
19
|
|
|
5
20
|
The integrations can report the hits they didn't serve. Until now they never
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cacheverifier
|
|
3
|
-
Version: 0.9.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.9.1
|
|
4
|
+
Summary: Check whether a semantic-cache hit is right for the question before serving it: a fine-tuned cross-encoder, no LLM call. Hosted API or local scoring; LangChain and GPTCache integrations.
|
|
5
5
|
Project-URL: Homepage, https://www.cacheverifier.com
|
|
6
6
|
Project-URL: Documentation, https://www.cacheverifier.com/docs
|
|
7
7
|
Project-URL: Source, https://github.com/imxinchengyou/cacheverifier-python
|
|
@@ -43,32 +43,40 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
[](https://pypi.org/project/cacheverifier/)
|
|
44
44
|
[](https://pypi.org/project/cacheverifier/)
|
|
45
45
|
|
|
46
|
-
Python client for **[CacheVerifier](https://www.cacheverifier.com)
|
|
47
|
-
|
|
48
|
-
then keeps your cache right after launch.
|
|
46
|
+
Python client for **[CacheVerifier](https://www.cacheverifier.com)**, which checks whether
|
|
47
|
+
a semantic-cache hit is actually right for the new question before you serve it.
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
A semantic cache matches on how *similar* two questions look, so "can I cancel my order?"
|
|
50
|
+
can get the cached answer to "can I change my order?". CacheVerifier looks at the new
|
|
51
|
+
question and the cached answer together and returns approve or reject, in tens of
|
|
52
|
+
milliseconds. It sits on top of the cache you already run.
|
|
53
|
+
|
|
54
|
+
**How it decides.** A small cross-encoder model, fine-tuned on your own feedback, scores
|
|
55
|
+
each (question, cached answer) pair. There is **no LLM call** and nothing is generated: the
|
|
56
|
+
verdict is a score compared with a threshold. An LLM only enters the picture if *you* choose
|
|
57
|
+
one, for example as the optional `judge=` that labels hits your cache didn't serve (see
|
|
58
|
+
[LangChain](#reporting-hits-that-werent-served)).
|
|
59
|
+
|
|
60
|
+
- **Verify the uncertain hits.** Call `verify()` on the candidates in the similarity "gray
|
|
61
|
+
zone", where a plain threshold match might be wrong, so a match that is *close but wrong*
|
|
62
|
+
doesn't become a silent error.
|
|
53
63
|
- **Know your real error rate.** Randomized audits of approved hits give a conservative
|
|
54
|
-
(Clopper-Pearson) upper bound on how often a served answer is wrong, measured on your
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
retrained on your feedback automatically.
|
|
64
|
+
(Clopper-Pearson) upper bound on how often a served answer is wrong, measured on your traffic, not a benchmark.
|
|
65
|
+
- **Set a risk target.** Conformal Risk Control can report a threshold that keeps wrong
|
|
66
|
+
reuses under a target you set, and the audits can check it on later traffic. It is a
|
|
67
|
+
report (`verify()` doesn't apply it), holds only while traffic resembles the calibration
|
|
68
|
+
data, and covers only the hits you send to `verify()`. An optional online (ACI) threshold
|
|
69
|
+
does change decisions, following what the audits find.
|
|
70
|
+
- **Catch drift.** When traffic moves away from what the verifier learned, the dashboard
|
|
71
|
+
flags it; on Team and Scale you also get a webhook alert and it is retrained on your
|
|
72
|
+
feedback automatically.
|
|
64
73
|
- **Know which entries to fix.** `entries_to_refresh()` lists the cache entries your
|
|
65
74
|
feedback reported stale, or wrong more often than right, with your own cache keys.
|
|
66
75
|
- **Run it in your stack.** On Managed plans, `LocalVerifier` scores with your fine-tuned
|
|
67
|
-
model
|
|
76
|
+
model on your own machines: no network hop, your texts stay with you, nothing metered.
|
|
68
77
|
|
|
69
|
-
CacheVerifier does **not** run your cache or do similarity search
|
|
70
|
-
its own lookup first
|
|
71
|
-
zone", where a plain threshold match might be wrong.
|
|
78
|
+
CacheVerifier does **not** run your cache or do similarity search: your cache backend does
|
|
79
|
+
its own lookup first.
|
|
72
80
|
|
|
73
81
|
| | answers | examples |
|
|
74
82
|
|---|---|---|
|
|
@@ -99,8 +107,8 @@ are opt-in.
|
|
|
99
107
|
|
|
100
108
|
## Quickstart
|
|
101
109
|
|
|
102
|
-
Get a free API key at <https://www.cacheverifier.com
|
|
103
|
-
entries to refresh
|
|
110
|
+
Get a free API key at <https://www.cacheverifier.com>: 20,000 verify calls a month,
|
|
111
|
+
fine-tuning, audits and entries to refresh, no card.
|
|
104
112
|
|
|
105
113
|
```python
|
|
106
114
|
from cacheverifier import CacheVerifier
|
|
@@ -110,19 +118,24 @@ cv = CacheVerifier(api_key="cv_...")
|
|
|
110
118
|
query = "can I change the delivery address after my parcel ships"
|
|
111
119
|
candidate = "You can change the delivery address any time before the parcel ships." # from your cache
|
|
112
120
|
|
|
113
|
-
result = cv.verify(query, candidate)
|
|
121
|
+
result = cv.verify(query, candidate, similarity_score=0.86)
|
|
114
122
|
if result.approved:
|
|
115
|
-
answer = candidate # verified hit
|
|
123
|
+
answer = candidate # verified hit: skip the LLM call
|
|
116
124
|
else:
|
|
117
|
-
answer = call_your_llm(query) # not trustworthy
|
|
118
|
-
if result.audit: # a randomized audit of an approval: report
|
|
119
|
-
cv.feedback(query, candidate, # the cached answer
|
|
125
|
+
answer = call_your_llm(query) # not trustworthy: fall through
|
|
126
|
+
if result.audit: # a randomized audit of an approval: report
|
|
127
|
+
cv.feedback(query, candidate, # whether the cached answer was right
|
|
120
128
|
was_correct=same_answer(answer, candidate),
|
|
121
129
|
verification_id=result.verification_id)
|
|
130
|
+
```
|
|
122
131
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
Every other label you have is worth sending too, whenever you learn it (a thumbs-down, a
|
|
133
|
+
reopened ticket, a reviewer's call). Label the cached candidate, not the fresh LLM answer:
|
|
134
|
+
was it right for this query? Each `verification_id` takes one label (a second one gets a
|
|
135
|
+
409), so an audit you already reported is done.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
cv.feedback(query, candidate, was_correct=False, similarity_score=0.86,
|
|
126
139
|
verification_id=result.verification_id)
|
|
127
140
|
```
|
|
128
141
|
|
|
@@ -298,9 +311,10 @@ for e in cv.entries_to_refresh():
|
|
|
298
311
|
|
|
299
312
|
## Fine-tuning
|
|
300
313
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
314
|
+
Train a verifier on your own gray-zone labels. The service accepts a job from 20 feedback
|
|
315
|
+
rows, but on the hardest data fine-tuning was often a net negative below ~1,000 (see the
|
|
316
|
+
[research](https://github.com/imxinchengyou/CacheVerifier)); `dry_run()` and the Health
|
|
317
|
+
Check tell you whether it helps on yours before anything is deployed.
|
|
304
318
|
|
|
305
319
|
```python
|
|
306
320
|
job = cv.finetune() # or cv.finetune(target_risk=0.01, cost_ratio=5.0)
|
|
@@ -451,6 +465,10 @@ verdict
|
|
|
451
465
|
|
|
452
466
|
Non-2xx responses raise `CacheVerifierError` (`.status_code`, `.detail`).
|
|
453
467
|
|
|
468
|
+
Monitoring endpoints without a client method yet (`GET /v1/monitor/risk`,
|
|
469
|
+
`/v1/monitor/audited-crc-threshold`, `/v1/monitor/judge-agreement`) are in the
|
|
470
|
+
[API reference](https://www.cacheverifier.com/docs).
|
|
471
|
+
|
|
454
472
|
## License
|
|
455
473
|
|
|
456
474
|
MIT — see [`LICENSE`](LICENSE). (The [research repository](https://github.com/imxinchengyou/CacheVerifier)
|
|
@@ -4,32 +4,40 @@
|
|
|
4
4
|
[](https://pypi.org/project/cacheverifier/)
|
|
5
5
|
[](https://pypi.org/project/cacheverifier/)
|
|
6
6
|
|
|
7
|
-
Python client for **[CacheVerifier](https://www.cacheverifier.com)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
Python client for **[CacheVerifier](https://www.cacheverifier.com)**, which checks whether
|
|
8
|
+
a semantic-cache hit is actually right for the new question before you serve it.
|
|
9
|
+
|
|
10
|
+
A semantic cache matches on how *similar* two questions look, so "can I cancel my order?"
|
|
11
|
+
can get the cached answer to "can I change my order?". CacheVerifier looks at the new
|
|
12
|
+
question and the cached answer together and returns approve or reject, in tens of
|
|
13
|
+
milliseconds. It sits on top of the cache you already run.
|
|
14
|
+
|
|
15
|
+
**How it decides.** A small cross-encoder model, fine-tuned on your own feedback, scores
|
|
16
|
+
each (question, cached answer) pair. There is **no LLM call** and nothing is generated: the
|
|
17
|
+
verdict is a score compared with a threshold. An LLM only enters the picture if *you* choose
|
|
18
|
+
one, for example as the optional `judge=` that labels hits your cache didn't serve (see
|
|
19
|
+
[LangChain](#reporting-hits-that-werent-served)).
|
|
20
|
+
|
|
21
|
+
- **Verify the uncertain hits.** Call `verify()` on the candidates in the similarity "gray
|
|
22
|
+
zone", where a plain threshold match might be wrong, so a match that is *close but wrong*
|
|
23
|
+
doesn't become a silent error.
|
|
14
24
|
- **Know your real error rate.** Randomized audits of approved hits give a conservative
|
|
15
|
-
(Clopper-Pearson) upper bound on how often a served answer is wrong, measured on your
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
retrained on your feedback automatically.
|
|
25
|
+
(Clopper-Pearson) upper bound on how often a served answer is wrong, measured on your traffic, not a benchmark.
|
|
26
|
+
- **Set a risk target.** Conformal Risk Control can report a threshold that keeps wrong
|
|
27
|
+
reuses under a target you set, and the audits can check it on later traffic. It is a
|
|
28
|
+
report (`verify()` doesn't apply it), holds only while traffic resembles the calibration
|
|
29
|
+
data, and covers only the hits you send to `verify()`. An optional online (ACI) threshold
|
|
30
|
+
does change decisions, following what the audits find.
|
|
31
|
+
- **Catch drift.** When traffic moves away from what the verifier learned, the dashboard
|
|
32
|
+
flags it; on Team and Scale you also get a webhook alert and it is retrained on your
|
|
33
|
+
feedback automatically.
|
|
25
34
|
- **Know which entries to fix.** `entries_to_refresh()` lists the cache entries your
|
|
26
35
|
feedback reported stale, or wrong more often than right, with your own cache keys.
|
|
27
36
|
- **Run it in your stack.** On Managed plans, `LocalVerifier` scores with your fine-tuned
|
|
28
|
-
model
|
|
37
|
+
model on your own machines: no network hop, your texts stay with you, nothing metered.
|
|
29
38
|
|
|
30
|
-
CacheVerifier does **not** run your cache or do similarity search
|
|
31
|
-
its own lookup first
|
|
32
|
-
zone", where a plain threshold match might be wrong.
|
|
39
|
+
CacheVerifier does **not** run your cache or do similarity search: your cache backend does
|
|
40
|
+
its own lookup first.
|
|
33
41
|
|
|
34
42
|
| | answers | examples |
|
|
35
43
|
|---|---|---|
|
|
@@ -60,8 +68,8 @@ are opt-in.
|
|
|
60
68
|
|
|
61
69
|
## Quickstart
|
|
62
70
|
|
|
63
|
-
Get a free API key at <https://www.cacheverifier.com
|
|
64
|
-
entries to refresh
|
|
71
|
+
Get a free API key at <https://www.cacheverifier.com>: 20,000 verify calls a month,
|
|
72
|
+
fine-tuning, audits and entries to refresh, no card.
|
|
65
73
|
|
|
66
74
|
```python
|
|
67
75
|
from cacheverifier import CacheVerifier
|
|
@@ -71,19 +79,24 @@ cv = CacheVerifier(api_key="cv_...")
|
|
|
71
79
|
query = "can I change the delivery address after my parcel ships"
|
|
72
80
|
candidate = "You can change the delivery address any time before the parcel ships." # from your cache
|
|
73
81
|
|
|
74
|
-
result = cv.verify(query, candidate)
|
|
82
|
+
result = cv.verify(query, candidate, similarity_score=0.86)
|
|
75
83
|
if result.approved:
|
|
76
|
-
answer = candidate # verified hit
|
|
84
|
+
answer = candidate # verified hit: skip the LLM call
|
|
77
85
|
else:
|
|
78
|
-
answer = call_your_llm(query) # not trustworthy
|
|
79
|
-
if result.audit: # a randomized audit of an approval: report
|
|
80
|
-
cv.feedback(query, candidate, # the cached answer
|
|
86
|
+
answer = call_your_llm(query) # not trustworthy: fall through
|
|
87
|
+
if result.audit: # a randomized audit of an approval: report
|
|
88
|
+
cv.feedback(query, candidate, # whether the cached answer was right
|
|
81
89
|
was_correct=same_answer(answer, candidate),
|
|
82
90
|
verification_id=result.verification_id)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Every other label you have is worth sending too, whenever you learn it (a thumbs-down, a
|
|
94
|
+
reopened ticket, a reviewer's call). Label the cached candidate, not the fresh LLM answer:
|
|
95
|
+
was it right for this query? Each `verification_id` takes one label (a second one gets a
|
|
96
|
+
409), so an audit you already reported is done.
|
|
83
97
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
cv.feedback(query, candidate, was_correct=candidate_was_right, similarity_score=0.86,
|
|
98
|
+
```python
|
|
99
|
+
cv.feedback(query, candidate, was_correct=False, similarity_score=0.86,
|
|
87
100
|
verification_id=result.verification_id)
|
|
88
101
|
```
|
|
89
102
|
|
|
@@ -259,9 +272,10 @@ for e in cv.entries_to_refresh():
|
|
|
259
272
|
|
|
260
273
|
## Fine-tuning
|
|
261
274
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
275
|
+
Train a verifier on your own gray-zone labels. The service accepts a job from 20 feedback
|
|
276
|
+
rows, but on the hardest data fine-tuning was often a net negative below ~1,000 (see the
|
|
277
|
+
[research](https://github.com/imxinchengyou/CacheVerifier)); `dry_run()` and the Health
|
|
278
|
+
Check tell you whether it helps on yours before anything is deployed.
|
|
265
279
|
|
|
266
280
|
```python
|
|
267
281
|
job = cv.finetune() # or cv.finetune(target_risk=0.01, cost_ratio=5.0)
|
|
@@ -412,6 +426,10 @@ verdict
|
|
|
412
426
|
|
|
413
427
|
Non-2xx responses raise `CacheVerifierError` (`.status_code`, `.detail`).
|
|
414
428
|
|
|
429
|
+
Monitoring endpoints without a client method yet (`GET /v1/monitor/risk`,
|
|
430
|
+
`/v1/monitor/audited-crc-threshold`, `/v1/monitor/judge-agreement`) are in the
|
|
431
|
+
[API reference](https://www.cacheverifier.com/docs).
|
|
432
|
+
|
|
415
433
|
## License
|
|
416
434
|
|
|
417
435
|
MIT — see [`LICENSE`](LICENSE). (The [research repository](https://github.com/imxinchengyou/CacheVerifier)
|
|
@@ -19,7 +19,7 @@ Research behind it: https://github.com/imxinchengyou/CacheVerifier
|
|
|
19
19
|
from cacheverifier.client import CacheVerifier, CacheVerifierError, ShadowVerdict, VerifyResult
|
|
20
20
|
from cacheverifier.local import LocalVerifier, ModelCheckFailed
|
|
21
21
|
|
|
22
|
-
__version__ = "0.9.
|
|
22
|
+
__version__ = "0.9.1"
|
|
23
23
|
__all__ = [
|
|
24
24
|
"CacheVerifier",
|
|
25
25
|
"CacheVerifierError",
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cacheverifier"
|
|
7
|
-
version = "0.9.
|
|
8
|
-
description = "
|
|
7
|
+
version = "0.9.1"
|
|
8
|
+
description = "Check whether a semantic-cache hit is right for the question before serving it: a fine-tuned cross-encoder, no LLM call. Hosted API or local scoring; LangChain and GPTCache integrations."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
11
11
|
license = { text = "MIT" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|