Repository navigation
Commit ef12e33
committed
FEAT: Add LayaRefusalScorer, a local CPU refusal scorer
Adds a true/false refusal scorer that runs on the machine running PyRIT,
with no API call and no per-response cost.
The scorer puts the refusal question to Laya (Convai Innovations, Apache 2.0),
an encoder that answers typed questions in one forward pass, takes the
representation Laya forms of each answer option rather than its own verdict,
and reads that with a logistic head trained on PyRIT's own human-labeled
refusal rows. The head is trained on first use from the pinned datasets, so
no opaque weights file ships and the whole model is reproducible from the
repository at a pinned dataset and checkpoint state.
Trained on refusal.csv and evaluated on refusal_extra.csv it is right on
96.9 percent of rows, and 91.4 percent the other way round. Excluding rows
whose response text also appears in training gives 97.5 percent of 40 rows
and 91.2 percent of 68 rows. SelfAskRefusalScorer with GPT-4o reaches 97 to
98 percent on the same rows. Laya's own verdict without the trained head
agrees with the labels on 53 to 71 percent of rows depending on the order
its answer options are presented in, so both orders are averaged and the
trained head is what makes it usable.
Scoring is two forward passes, about a second per response on CPU.1 parent 58f4883 commit ef12e33
5 files changed
Lines changed: 842 additions & 1 deletion
File tree
- doc/code/scoring
- pyrit/score
- true_false
- tests/unit/score
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
511 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
512 | 538 | | |
513 | 539 | | |
514 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
293 | 319 | | |
294 | 320 | | |
295 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| 188 | + | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
| |||
0 commit comments