Commit 0c6aa0e
feat: quant_ask_verified() API — built-in coherence check (#84)
New public API function that generates an answer from context and
automatically verifies it addresses the user's question:
char* quant_ask_verified(quant_ctx* ctx, const char* context,
const char* question, float* out_confidence);
How it works:
1. Generate answer from context + question (ANSWER/NONE format)
2. Self-check: if model says NONE → return NULL (conf=0.05)
3. Coherence check: "Is the EXACT question answered? YES or NO"
4. If coherence=NO → return NULL (conf=0.1)
5. If coherence=YES → return answer (conf=0.9)
This is the universal mechanism that took RLV from 15/20 to 19/20
on the 1.3MB large-doc benchmark. Now available to all applications.
Usage:
float confidence;
char* answer = quant_ask_verified(ctx, doc_text, "Who is X?", &confidence);
if (answer && confidence > 0.5) {
printf("Answer (%.0f%% confident): %s\n", confidence*100, answer);
quant_free_string(answer);
}
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 18cb518 commit 0c6aa0e
1 file changed
Lines changed: 84 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
17139 | 17147 | | |
17140 | 17148 | | |
17141 | 17149 | | |
| 17150 | + | |
| 17151 | + | |
| 17152 | + | |
| 17153 | + | |
| 17154 | + | |
| 17155 | + | |
| 17156 | + | |
| 17157 | + | |
| 17158 | + | |
| 17159 | + | |
| 17160 | + | |
| 17161 | + | |
| 17162 | + | |
| 17163 | + | |
| 17164 | + | |
| 17165 | + | |
| 17166 | + | |
| 17167 | + | |
| 17168 | + | |
| 17169 | + | |
| 17170 | + | |
| 17171 | + | |
| 17172 | + | |
| 17173 | + | |
| 17174 | + | |
| 17175 | + | |
| 17176 | + | |
| 17177 | + | |
| 17178 | + | |
| 17179 | + | |
| 17180 | + | |
| 17181 | + | |
| 17182 | + | |
| 17183 | + | |
| 17184 | + | |
| 17185 | + | |
| 17186 | + | |
| 17187 | + | |
| 17188 | + | |
| 17189 | + | |
| 17190 | + | |
| 17191 | + | |
| 17192 | + | |
| 17193 | + | |
| 17194 | + | |
| 17195 | + | |
| 17196 | + | |
| 17197 | + | |
| 17198 | + | |
| 17199 | + | |
| 17200 | + | |
| 17201 | + | |
| 17202 | + | |
| 17203 | + | |
| 17204 | + | |
| 17205 | + | |
| 17206 | + | |
| 17207 | + | |
| 17208 | + | |
| 17209 | + | |
| 17210 | + | |
| 17211 | + | |
| 17212 | + | |
| 17213 | + | |
| 17214 | + | |
| 17215 | + | |
| 17216 | + | |
| 17217 | + | |
| 17218 | + | |
| 17219 | + | |
| 17220 | + | |
| 17221 | + | |
| 17222 | + | |
| 17223 | + | |
| 17224 | + | |
17142 | 17225 | | |
17143 | 17226 | | |
17144 | 17227 | | |
| |||
0 commit comments