본문 바로가기
C.W.K.
Stream
Lesson 01 of 06 · published

완전 일치와 포함 여부

~18 min · metrics, deterministic, fundamentals

Level 0추측자
0 XP0/55 lessons0/10 achievements
0/150 XP to next level150 XP to go0% complete

단순하지만 충분히 활용되지 않는 채점기

LLM 판정 모델을 호출하기 전에 먼저 물어봐. '특정 문자열만 확인해도 이 평가를 끝낼 수 있을까?' 많은 팀이 완전 일치와 포함 여부 검사를 지나치게 단순하다는 이유로 건너뛰지만, 그건 실수야. 이 채점기들은 무료이고 결정론적이며 즉시 실행돼. 게다가 생각보다 훨씬 많은 실제 회귀를 잡아내지.

완전 일치가 잘 맞는 곳

  • 예/아니요, 참/거짓, A/B/C/D 분류처럼 답이 하나의 토큰으로 정해지는 과제.
  • 형식이 고정된 수치형 답.
  • 특정 함수 이름을 요구하는 코드 생성.
  • JSON 출력의 구조화된 필드.

포함 여부 검사가 주력인 이유

자연어 과제에서는 완전 일치가 대개 너무 엄격해. "Paris"와 "Paris is the capital of France"는 표현이 달라도 같은 정답을 담고 있지. 포함 여부 채점기는 참조 답안이 출력 어딘가에 나타나는지 확인하고, 필요하면 대소문자 차이도 무시해. 내용에는 엄격하면서 장황하거나 간결한 표현의 차이는 허용할 수 있어.

원칙: LLM 판정 모델에 비용을 쓰기 전에 결정론적 채점기를 최대한 활용해. 비용은 약 1,000분의 1이고, 생각보다 훨씬 많은 회귀를 잡아내.

여러 참조 답안으로 포함 여부 검사하기

실제 질문에는 허용할 수 있는 표현이 여러 개일 때가 많아. '남수단의 수도는?'이라는 질문에는 "Juba", "Juba is the capital", "South Sudan's capital is Juba"를 모두 정답으로 인정할 수 있어. 허용할 참조 답안 목록을 저장하고 그중 하나라도 일치하는지 확인하면, 내용에는 엄격하고 문체에는 너그러운 채점기가 돼.

Code

완전 일치와 포함 여부 검사·python
import re

def exact(output, reference):
    return output.strip() == reference.strip()

def contains(output, reference, case_insensitive=True):
    if case_insensitive:
        output, reference = output.lower(), reference.lower()
    return reference in output

def contains_any(output, references, case_insensitive=True):
    return any(contains(output, r, case_insensitive) for r in references)

def contains_all(output, references, case_insensitive=True):
    return all(contains(output, r, case_insensitive) for r in references)

# Usage
assert contains("The capital is Paris", "paris")            # True
assert contains_any("The capital is Juba", ["juba", "jouba"])
assert contains_all("Citizens of Tokyo and Osaka", ["Tokyo", "Osaka"])
단어 경계를 고려한 포함 여부 — 부분 문자열을 조심해·python
# 'cat' is in 'concatenate'. Naive contains says cats appear in your output.
# Use word boundaries when the reference is a short word.
import re

def contains_word(output, word, case_insensitive=True):
    flags = re.IGNORECASE if case_insensitive else 0
    pattern = rf"\b{re.escape(word)}\b"
    return re.search(pattern, output, flags) is not None

assert not contains_word("concatenate things", "cat")  # True — substring trap avoided
assert contains_word("the cat sat", "cat")              # True

External links

Exercise

가장 중요한 과제에서 나올 수 있는 참조 출력 20개를 목록으로 만들어. 최근 평가 실행의 각 출력에 목록의 참조 표현 중 하나라도 포함되면 통과하는 채점기를 적용해 봐. LLM 판정 모델은 실패로 봤지만 이 채점기는 통과시킨 사례나 그 반대 사례는 어디에 있을까? 불일치마다 데이터셋이나 채점기에 관해 무엇을 배울 수 있는지 정리해.

Progress

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

댓글 0

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

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