C.W.K.
Stream
Lesson 02 of 05 · published

Lost in the Middle

~26 min · position-bias, lost-in-the-middle, retrieval

Level 0Window Watcher
0 XP0/50 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

총 길이보다 position이 더 중요

2023년 Liu et al. Lost in the Middle: How Language Models Use Long Contexts 논문이 disturbing한 걸 보여줬어 — 관련 정보가 long context 가운데 있으면 모형 정확도가 sharp하게 떨어진다. 성능은 U자 모양 — 시작 best, 끝 second-best, 가운데 worst. 모형 family 전반과 수년간의 capability 발전에 걸쳐 effect 지속.

강의 비유

90분 강의 상상해. 시작 기억나, 마무리 기억나, 47분쯤? 거의 안개. 모형도 똑같이 한다. naive stuffing 위험: 맞는 사실 포함하고도 모형이 가장 못 쓸 위치에 둘 수 있어.

실전 함의

중요한 instruction은 prompt 시작 *또는* 끝에. task를 context에 sandwich, 중간에 묻지 마. RAG retrieval order가 중요 — 가장 관련 chunk를 1, 2 위치와 N-1, N 위치에 — 가운데 X. 100K-token blob 가운데 데이터 박아놓고 '데이터 줬으니 알겠지' 믿지 마.

사실이 task 결정한다면, 거대한 prompt 가운데 묻지 마. 모형이 거기서 그걸 쓸 통계적 가능성이 가장 낮다.

Code

position-aware ordering·yaml
context_order:
  front:
    - live rules
    - source of truth
    - task objective
  middle:
    - supporting references
    - optional detail
  tail:
    - latest human decision
    - latest tool result
    - next action
빠른 A/B 테스트·python
def test_lim(model, fact, distractor_blob):
    # A: fact at start
    a = model.ask(f"FACT: {fact}\n\n{distractor_blob}\n\nWhat was the fact?")
    # B: fact in middle
    mid = len(distractor_blob) // 2
    b = model.ask(f"{distractor_blob[:mid]}\nFACT: {fact}\n{distractor_blob[mid:]}\n\nWhat was the fact?")
    return {"start": a, "middle": b}
# 차이가 놀랄 거야.

External links

Exercise

지저분한 prompt 골라 front, middle, tail 영역으로 재정렬. authority bearing 사실은 edge에. 같은 prompt를 critical 사실 가운데 vs 앞에 두고 A/B.
Hint
Rule과 current state는 edge 자격. background는 가운데도 OK.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.