dspy.evaluate.CompleteAndGrounded
dspy.evaluate.CompleteAndGrounded
dspy.evaluate.CompleteAndGrounded(threshold=0.66)
상위 클래스: Module
답의 **완전성(completeness)**과 **근거성(groundedness)**을 하나의 점수로 결합하는 LLM-as-judge 메트릭이에요. 검색 보강(retrieval-augmented) 프로그램용으로 설계됐어요.
| 이름 | 타입 | 설명 | 기본값 |
|---|---|---|---|
threshold |
최적화 중 수용할 최소 점수 | 0.66 |
소스: dspy/evaluate/auto_evaluation.py
생성자는 두 개의 ChainOfThought 서브모듈을 만들어요:
def __init__(self, threshold=0.66):
self.threshold = threshold
self.completeness_module = ChainOfThought(AnswerCompleteness)
self.groundedness_module = ChainOfThought(AnswerGroundedness)
Module이라 검사·트레이스·최적화가 가능하고, batch·deepcopy·get_lm 등 일반 Module 메서드를 상속해요.
핵심: forward(example, pred, trace=None)
def forward(self, example, pred, trace=None):
completeness = self.completeness_module(
question=example.question, ground_truth=example.response, system_response=pred.response
)
groundedness = self.groundedness_module(
question=example.question, retrieved_context=pred.context, system_response=pred.response
)
score = f1_score(groundedness.groundedness, completeness.completeness)
return Prediction(score=score if trace is None else score >= self.threshold)
두 번의 ChainOfThought 호출을 돌려요 — 하나는 완전성(pred.response가 example.response를 커버하는가), 하나는 근거성(pred.response가 pred.context에 의해 뒷받침되는가). 둘의 조화 평균을 score로 쓰지요. 반환은 모드에 따라 달라져요 — trace is None(평가 시점)이면 연속 점수를, trace is not None(최적화 시점)이면 score >= threshold의 이진화된 통과/실패를 돌려줘요. 같은 인스턴스가 두 모드를 모두 처리해요.
출처: 공식문서
더 알아보기 (Learn more)
- 메트릭과 평가 — LLM 판정자 메트릭 계약과
trace기반 이진화. - 통합 평가 도구 dspy.Evaluate
- dspy.evaluate.SemanticF1 — 같은 패턴의 의미론적 F1 판정자.