다시 시도하되 뒤돌아보지 마라: 작은 코드 모델에서는 Blind Resampling이 Self-Repair보다 낫다
Try Again, Don't Look Back: Blind Resampling Outperforms Self-Repair in Small Code Models
TL;DR Highlight
실패 코드를 보여주지 않고 다시 뽑았더니 작은 모델에서 self-repair보다 정확하고 쌌다
Who Should Read
작은 오픈 코드 모델(1.5B~7B)로 테스트 실패 시 자동 재시도하는 코드 에이전트를 만드는 백엔드 개발자
Core Mechanics
- 실패 코드를 보여주면 오히려 손해
- 1.5B·3B에서는 자기 실패 코드를 다시 보여준 쪽이 그냥 처음 프롬프트로 다시 뽑은 쪽보다 정답률이 낮았다.
- 7B에서는 차이가 통계적으로 동률이 됐다.
- 테스트 출력은 아무 정보도 못 보탰다
- 실제 실행 피드백과 "틀렸다"는 내용 없는 안내문(placebo)을 비교하면 차이가 없었다.
- 차이는 +0.000, +0.026, +0.008이고 모두 유의하지 않았다.
- 원인은 앵커링(anchoring)이다
- 자기 코드를 보면 모델이 그 코드를 조금 고치는 쪽으로 쏠린다.
- 거의 같은 코드를 다시 내놓는 비율이 blind resampling은 2~14%, 자기 코드를 보여준 조건은 33~68%였다.
- 컨텍스트가 길어서가 아니다
- 다른 태스크의 성공 풀이를 앞에 붙여도 효과가 없었다(±3.5%p 이내).
- 해로운 건 길이가 아니라 자기 실패작을 보는 것이다.
- reflection은 비싸기만 하다
- 실패 원인을 글로 먼저 분석시키면 앵커링이 줄지만 비용을 못 메운다.
- 7B에서는 blind resampling과 같은 수준인데 출력 토큰은 2.5배였다.
Evidence
- MBPP+ k=8 정답률(pass@1)
- 1.5B: resample 0.749, placebo 0.688, feedback 0.688, reflect 0.688.
- 3B: resample 0.778, placebo 0.709, feedback 0.735, reflect 0.743.
- 7B: resample 0.820, placebo 0.802, feedback 0.810, reflect 0.828.
- 토큰 비용은 resample이 가장 적었다
- 1.5B 출력 토큰: resample 63k, placebo 90k, feedback 129k, reflect 345k.
- 3B: resample 76k, reflect 284k. 7B: resample 49k, reflect 122k.
- 자기 출력 노출의 손실(resample 대비)
- placebo−resample: 1.5B −0.061(p=0.006), 3B −0.069(p<0.001).
- 무재시도 baseline 대비로는 feedback이 1.5B에서 12.2점 이득처럼 보이지만, blind resampling과 비교하면 손해다.
- 재현 실험(DeepSeek-Coder, FP16)
- DeepSeek 1.3B: placebo−resample −0.138, feedback−resample −0.114(둘 다 p<10^-4).
- FP16 1.5B에서도 feedback−resample −0.063(p=0.0008)로 Q4의 −0.061과 같았다.
- 6개 설정에서 baseline 품질과 손실 크기의 상관은 r=0.96이었다.
How to Apply
- 재시도 루프에 blind resample 대조군 추가하기
- 지금 쓰는 self-repair 루프 옆에 원래 프롬프트만 temperature 0.8로 다시 뽑는 분기를 만들어라.
- 같은 태스크 세트에서 정답률과 토큰 수를 비교해라.
- 작은 모델은 재시도 프롬프트에서 실패 코드 빼기
- 7B 미만 모델이면 재시도 때 이전 시도를 넣지 말고 원래 지시만 다시 보내라.
- temperature는 0보다 크게 설정해라. greedy면 똑같은 코드가 반복된다.
- 재시도 횟수를 2회 안팎으로 제한하기
- 최대 반복 수를 2 근처로 낮춰라.
- 개선이 앞 두 번에 몰려 있으니 그 뒤는 토큰만 쓴다.
- 실행 피드백과 reflection은 비용으로 따지기
- 실행 결과를 프롬프트에 넣는 조건과 "틀렸습니다"만 넣는 조건을 같은 예산으로 A/B 해라.
- 차이가 없으면 피드백 단계를 빼라.
Try It
# Claude나 ChatGPT에 붙여넣는 프롬프트 — 논문 방법의 간이 버전 (blind resampling 체험)
# 1단계: 아래를 새 대화에서 실행하고 결과를 저장해 둔다. 같은 대화에서 이어 하지 말고 새 대화를 열어 다시 실행한다.
다음 함수를 파이썬으로 작성해줘. 코드만 출력해.
{{함수 명세}}
# 2단계: 테스트가 실패하면 실패한 코드를 붙이지 말고, 위 1단계 프롬프트를 새 대화에서 그대로 다시 보낸다.
# 비교용 대조군: 같은 대화에서 아래처럼 실패 코드를 보여주고 고치게 한다.
아래 코드는 틀렸어.
{{실패한 코드}}
수정해줘.
# 이어서 해 볼 것: 10~20개 문제로 두 방식의 통과율과 두 코드의 유사도를 비교해 본다.Terminology
관련 논문
같은 시뮬레이션, 다른 근거: 도구 출력을 파일로 넘기면 LLM 에이전트 정확도가 어디서 깎이나
긴 툴 출력을 파일로 넘기자 GPT-5.1은 정확도 11.3%p 하락, 정식 출력 지정하니 회복
가짜 뉴스가 진짜 폭락을: LLM 트레이딩 에이전트 대상 정보 주입 공격
가짜 헤드라인 한 줄로 LLM 트레이딩 에이전트 62%를 조종했다(프롬프트 주입은 14%)
Harness Engineering 101: LLM은 뇌, harness는 몸
에이전트는 JSON 배열을 관리하는 루프이고, 16개 챕터로 직접 만들어 본다
Harness²: 에이전트 harness를 스스로 고쳐 쓰는 재귀 최적화 프레임워크
모델은 고정하고 harness를 재귀로 고쳤더니 벤치마크 점수가 최대 11.8%p 올랐다
해고된 Savannah 경찰관, ICE 요원 남편에게 Flock 계정 공유
경찰관이 Flock 계정을 남편(ICE 요원)에게 공유했고, 감사에서 983건 검색이 드러나 해고됐다
tmux와 Claude Code: 세션, send-keys, 그리고 한계선
tmux로 Claude Code 여러 개를 돌리면 편하지만 에이전트 4개쯤에서 한계가 온다
Hybrid Reasoning Agents: 잠재 공간에서 생각하고 텍스트로 행동하는 LLM 에이전트
잠재 공간 추론과 텍스트 도구 호출을 섞었더니 성능 10.4%↑, 토큰 최대 54.7%↓
Related Resources
Original Abstract (Expand)
Self-repair - returning a failed program to the model together with its test output and asking for a correction - is a standard component of code agents, and is almost always evaluated against a baseline that does not retry at all. We argue that this comparison confounds the value of the feedback with the value of the extra attempt. Using a placebo-controlled design on MBPP+ at three model scales (1.5B, 3B, 7B), we compare four matched-budget retry conditions: blind resampling, a content-free failure notice, genuine execution feedback, and feedback augmented with verbal self-reflection. Blind resampling is the strongest condition below 7B, and remains statistically tied with the best condition at 7B, while consuming 2.5-5.5x fewer tokens; conditioning on the model's own failed attempt costs 6.1 points at 1.5B (p=0.006), and the informational content of execution feedback adds nothing measurable over the placebo. We attribute this to anchoring: when shown its previous attempt, a model reproduces a near-identical program in 33-68% of retries, against 2-14% under blind resampling. Two further experiments delimit the effect. Retrieved solutions to other tasks change nothing (bounded to +/-3.5 points), which localizes the harm to self-conditioning rather than context length; and reflection, the only condition that measurably weakens the anchor, remains dominated on cost. Replication rules out two competing explanations: the penalty is unchanged at full precision, and it reproduces on an independent model family. Across six configurations spanning two families and two precisions, its magnitude is predicted by baseline quality alone (r=0.96) - the cost of anchoring is the cost of committing to a bad first attempt.