Auditing AI-assisted annotation#
Question: how would we evaluate a proposed annotation procedure independently of its fluent explanations?
This tiny fixture contains fabricated responses, instructor-assigned reference labels, and deliberately fabricated assistant outputs. No model produced these outputs, and their scores are not empirical AI performance claims. The task is to identify whether a respondent explicitly reports difficulty sleeping. Treat this as a measurement exercise, not diagnosis.
Before seeing the labels, write your own coding rule. Reference labels also need scrutiny: real annotation should include independent coding, disagreement adjudication, and an evaluation sample separate from prompt development.
course_path <- if(file.exists("../R/course.R")) "../R/course.R" else "book/R/course.R"
source(course_path)
set.seed(432)
d <- data.frame(
text=c("I cannot get to sleep.","I sleep soundly.","No difficulty falling asleep.","I wake repeatedly and cannot return to sleep.","My friend has insomnia, but I sleep well.","I do not have insomnia.","Lately falling asleep takes hours.","I read about sleep problems.","I sleep badly, despite feeling tired.","I never said I could not sleep.","I have no trouble sleeping.","I lie awake most nights."),
reference=c(1,0,0,1,0,0,1,0,1,0,0,1),
fabricated_A=c(1,0,1,1,1,1,1,1,1,1,0,1),
fabricated_B=c(1,0,0,1,0,0,1,0,1,1,0,1),
negation_or_other_context=c(FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE))
stopifnot(!anyNA(d),!anyDuplicated(d$text))
d
score <- function(pred) mean(pred==d$reference)
c(A=score(d$fabricated_A),B=score(d$fabricated_B))
table(predicted=d$fabricated_A,reference=d$reference)
| text | reference | fabricated_A | fabricated_B | negation_or_other_context |
|---|---|---|---|---|
| <chr> | <dbl> | <dbl> | <dbl> | <lgl> |
| I cannot get to sleep. | 1 | 1 | 1 | FALSE |
| I sleep soundly. | 0 | 0 | 0 | FALSE |
| No difficulty falling asleep. | 0 | 1 | 0 | TRUE |
| I wake repeatedly and cannot return to sleep. | 1 | 1 | 1 | FALSE |
| My friend has insomnia, but I sleep well. | 0 | 1 | 0 | TRUE |
| I do not have insomnia. | 0 | 1 | 0 | TRUE |
| Lately falling asleep takes hours. | 1 | 1 | 1 | FALSE |
| I read about sleep problems. | 0 | 1 | 0 | TRUE |
| I sleep badly, despite feeling tired. | 1 | 1 | 1 | FALSE |
| I never said I could not sleep. | 0 | 1 | 1 | TRUE |
| I have no trouble sleeping. | 0 | 0 | 0 | TRUE |
| I lie awake most nights. | 1 | 1 | 1 | FALSE |
- A
- 0.583333333333333
- B
- 0.916666666666667
reference
predicted 0 1
0 2 0
1 5 5
Inspect failures and paired uncertainty#
Do not treat this deliberately constructed sample as representative. A paired bootstrap keeps both procedures on the same sampled cases. With so few cases, intervals will be coarse and cannot support broad performance claims.
d[d$fabricated_A!=d$reference,c("text","reference","fabricated_A")]
aggregate(cbind(error_A=as.integer(d$fabricated_A!=d$reference),error_B=as.integer(d$fabricated_B!=d$reference)),list(context=d$negation_or_other_context),mean)
improvement <- as.integer(d$fabricated_B==d$reference)-as.integer(d$fabricated_A==d$reference)
bootstrap <- replicate(1000,mean(sample(improvement,length(improvement),replace=TRUE)))
c(difference_in_accuracy=mean(improvement),quantile(bootstrap,c(.025,.975)))
| text | reference | fabricated_A | |
|---|---|---|---|
| <chr> | <dbl> | <dbl> | |
| 3 | No difficulty falling asleep. | 0 | 1 |
| 5 | My friend has insomnia, but I sleep well. | 0 | 1 |
| 6 | I do not have insomnia. | 0 | 1 |
| 8 | I read about sleep problems. | 0 | 1 |
| 10 | I never said I could not sleep. | 0 | 1 |
| context | error_A | error_B |
|---|---|---|
| <lgl> | <dbl> | <dbl> |
| FALSE | 0.0000000 | 0.0000000 |
| TRUE | 0.8333333 | 0.1666667 |
- difference_in_accuracy
- 0.333333333333333
- 2.5%
- 0.0833333333333333
- 97.5%
- 0.583333333333333
Independent exercise#
Create a new set of ambiguous examples before running a live model. Obtain independent human codes, adjudicate disagreements, and hold a final set aside while developing the prompt. Report agreement, error categories, subgroup sample sizes, refusals, and invalid outputs. If responses from the same author recur, resample or split at author level.
For live use, record source IDs, permitted data access, model identifier, prompt, settings, date, raw responses, parsed labels, and failure handling. Repeat a subset to assess stability. Do not revise reference labels to agree with the model. A small constructed fixture tests a failure mode; it does not estimate population accuracy.
sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.7.7
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] fansi_1.0.3 crayon_1.5.1 digest_0.6.29
[4] utf8_1.2.2 IRdisplay_1.1 repr_1.1.4
[7] lifecycle_1.0.1 jsonlite_1.8.0 evaluate_0.15
[10] pillar_1.8.0 rlang_1.0.6 cli_3.3.0
[13] uuid_1.1-0 vctrs_0.4.1 IRkernel_1.3.0.9000
[16] tools_4.2.1 glue_1.6.2 fastmap_1.1.0
[19] compiler_4.2.1 base64enc_0.1-3 pbdZMQ_0.3-7
[22] htmltools_0.5.3