이번 포스트에서는 LLMTestCase 에 대해 간략한 설명을 기재한다.
A single-turn test case is a blueprint provided by deepeval to unit test LLM outputs, and represents a single, atomic unit of interaction with your LLM app.
https://deepeval.com/docs/evaluation-test-cases#llm-test-cases
DeepEval에서는 테스트케이스의 형태에 대해 크게 2가지로 나눈다.
기본적인 테스트케이스는 LLMTestCase 로 테스트케이스를 관리할 수 있다. multi-turn의 경우는 ConversationalTestCase 를 사용한다.
from deepeval.test_case import LLMTestCase, ToolCall
test_case = LLMTestCase(
input="What if these shoes don't fit?",
expected_output="You're eligible for a 30 day refund at no extra cost.",
actual_output="We offer a 30-day full refund at no extra cost.",
context=["All customers are eligible for a 30 day full refund at no extra cost."],
retrieval_context=["Only shoes can be refunded."],
tools_called=[ToolCall(name="WebSearch")]
)
위 LLMTestCase 클래스가, 하나의 테스트케이스 형태이다.
| 필드 | 쉬운 의미 | 언제 결정되는가? |
|---|---|---|
| input | 앱에 넣을 질문 | 평가 전에 준비 |
| expected_output | 좋은 답변의 예시 | 평가 전에 준비 |
| context | 정답으로 신뢰할 수 있는 공식 근거 | 평가 전에 준비 |
| expected_tools | 에이전트가 사용해야 하는 도구 | 평가 전에 준비 |
| actual_output | 앱이 실제 생성한 답변 | 앱 실행 후 관찰 |
| retrieval_context | 검색기가 실제 가져온 문서 | 앱 실행 후 관찰 |
| tools_called | 에이전트가 실제 호출한 도구 | 앱 실행 후 관찰 |
파라미터는 RAG가 제대로 된 근거로부터 답변을 가져오는지 확인할 수 있는 retrieval_context 나, 에이전트가 어떤 도구를 호출했는지를 확인할 수 있는 tools_called 파라미터도 있다.
이 LLMTestCase 자체로 무언가를 할 수 있는 것은 아니고, 다시 평가지표 와 함께 실제로 assertion을 실행시켜야한다.
당연할 수도 있겠지만, 테스트케이스나 기대결과, 컨텍스트의 체계적인 관리가 중요해진다. 몇천개 정도의 레벨로 가면 재사용하는 값들이 있을텐데 그것들을 어떻게 관리하는지가 관리부하를 줄일 수 있을 것이다.