Skip to content

Commit

Permalink
separate edit generator from applicator to retain provenance
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed May 18, 2023
1 parent de879ea commit b818e76
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private fun constructScoringFunction(): (Edit) -> Float {
println("Top 100 most common tokens: ${tokenCounts.toList().sortedByDescending { it.second }.take(100)}\n\n")

val scoreEdit: (Edit) -> Float = {
val tokens = it.second
val tokens = it.values
val tokenWeights = tokens.map { normedTokenWeights[it] ?: 0f }
// Tokens are t_1...t_n, we compute the score as log(p(t_1)*...*p(t_n))
// Edits are penalized by length, so we divide by the number of tokens
Expand Down Expand Up @@ -134,7 +134,7 @@ fun parallelRepairKotlinStatement(
filter = { isValidKotlin() },
scoreEdit = scoreEdit,
diagnostic = {
val levDiff = levenshtein(prompt, it) - 1
val levDiff = levenshtein(prompt, it)
if (levDiff < bestRepair) {
println("Δ=$levDiff repair: ${prettyDiffNoFrills(prompt, it)}")
// println("(LATEX) Δ=$levDiff repair: ${latexDiffSingleLOC(prompt, it)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fun String.uncoarsenAsPython(prompt: String): String {
token in pythonKeywords -> token
else -> throw Exception("Unknown token: $token")
}
} + words.joinToString(" ")
} + words.joinToString(" ", " ")

// println("After uncoarsening: $uncoarsed")
return uncoarsed
Expand Down

0 comments on commit b818e76

Please sign in to comment.