
Constitutional AI critique-revise loop (Kamath Ch 5)
Source:R/kamath_llm2_native.R
morie_kamath_constitutional_ai_loop.RdCritique then revise once per principle, in order.
Examples
A <- matrix(c(1, 0, 2, 1), 2)
B <- diag(2)
x <- c(1, 2, 3, 4)
y <- morie_kamath_ch4_krona_efficient(A, B, x)$y
morie_kamath_constitutional_ai_loop("r0", list("p1", "p2"), function(st,
p, y, cr) paste(st, p, y, sep = ":"))
#> $estimate
#> [1] "revise:p2:revise:p1:r0"
#>
#> $revised_response
#> [1] "revise:p2:revise:p1:r0"
#>
#> $initial_response
#> [1] "r0"
#>
#> $history
#> $history[[1]]
#> $history[[1]]$principle
#> [1] "p1"
#>
#> $history[[1]]$critique
#> [1] "critique:p1:r0"
#>
#> $history[[1]]$response_before
#> [1] "r0"
#>
#> $history[[1]]$response_after
#> [1] "revise:p1:r0"
#>
#>
#> $history[[2]]
#> $history[[2]]$principle
#> [1] "p2"
#>
#> $history[[2]]$critique
#> [1] "critique:p2:revise:p1:r0"
#>
#> $history[[2]]$response_before
#> [1] "revise:p1:r0"
#>
#> $history[[2]]$response_after
#> [1] "revise:p2:revise:p1:r0"
#>
#>
#>
#> $n_revisions
#> [1] 2
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "Constitutional AI critique-revise loop (Kamath Ch 5)"
#>