실험 설정: 요약 작업 및 LLM 심사위원
본 실험은 세 가지 핵심 요소로 구성됩니다: 비교 대상인 요약 작업, 품질을 평가할 LLM 심사위원, 그리고 이들을 실행할 평가 하네스입니다.
1. 요약 시그니처 정의
Summarize라는 DSPy::Signature를 정의하여 텍스트를 입력받아 핵심 개념을 보존하는 간결한 요약을 출력하도록 했습니다. 이 시그니처는 DSPy::Predict와 DSPy::ChainOfThought 두 가지 예측기 모두에 동일하게 적용됩니다.
ruby
class Summarize < DSPy::Signature
description "Summarize the given text concisely while preserving key concepts"
input { const :text, String, description: "Text to summarize" }
output { const :summary, String, description: "Concise summary preserving key concepts (2-3 sentences)" }
end
gpt-4o-mini 모델을 사용하여 Predict와 ChainOfThought 예측기를 각각 생성하고, ChainOfThought는 reasoning 단계를 추가로 출력합니다.
2. 다차원 품질 평가를 위한 LLM 심사위원
수동 검토 대신 LLM을 사용하여 요약 품질을 평가하는 G-Eval 방식이 도입되었습니다. 이를 위해 EvaluatorMindset (Critical, Balanced, Generous)과 GroundedSummary (source_text, summary) 타입을 정의했습니다. EvaluateSummary 시그니처는 GroundedSummary와 EvaluatorMindset을 입력받아 faithfulness, relevance, coherence, fluency를 1-5점 척도로 평가하고 overall_score를 산출합니다. 심사위원 자체도 DSPy::ChainOfThought를 사용하여 평가 과정에서 추론하도록 설정되었습니다.
ruby
class EvaluateSummary < DSPy::Signature
description "Evaluate summary quality using G-Eval criteria according to the specified mindset."
input { const :grounded_summary, GroundedSummary; const :mindset, EvaluatorMindset }
output do
const :faithfulness, Integer, description: "Score 1-5: Is the summary factually accurate?"
const :relevance, Integer, description: "Score 1-5: Does it capture the most important information?"
const :coherence, Integer, description: "Score 1-5: Is it well-structured with logical flow?"
const :fluency, Integer, description: "Score 1-5: Is it grammatically correct and readable?"
const :overall_score, Float, description: "Overall quality score from 1.0 to 5.0"
end
end
3. LLM 심사위원 패키징 및 평가 실행
create_llm_judge_metric 함수는 LLM 심사위원을 캡슐화한 람다 함수로, 예시와 예측을 받아 평가 결과를 반환합니다. 이 지표는 DSPy::Evals와 함께 사용되어 예측기와 CoT 예측기의 성능을 5개의 위키피디아 문서(광합성, 비잔틴 제국 등)에 대해 평가했습니다. gpt-4o-mini가 요약기로, gpt-4.1이 심사위원으로 사용되었습니다.
실험 결과
실험 결과, 일반 예측 방식은 평균 93.0%의 점수를, ChainOfThought 방식은 평균 96.0%의 점수를 기록하여 CoT 방식이 3.0%p 더 높은 성능을 보였습니다. 세부 차원별 분석에서는 특히 Faithfulness(사실성)에서 0.4점, Coherence(일관성)에서 0.2점의 개선이 나타났습니다. Relevance(관련성)와 Fluency(유창성)는 두 방식 모두 높은 점수를 기록했습니다. 이 결과는 CoT의 추론 단계가 모델이 환각을 피하고 더 잘 구조화된 출력을 생성하는 데 도움이 됨을 시사합니다.