평가 모델 구성

모델 기반 측정항목은 기준과 사용 사례에 따라 평가 측정항목을 맞춤설정하고 생성하는 데 도움이 되는 다양한 접근 방식을 제공합니다. 이 페이지에서는 이상적인 사용 사례에 맞게 평가 모델을 구성하는 방법을 설명합니다.

기본 평가 워크플로는 Gen AI Evaluation Service 빠른 시작을 참조하세요. 고급 평가 모델 맞춤설정 시리즈에는 다음 페이지가 포함됩니다.

  1. 평가 모델 평가
  2. 평가 모델 맞춤설정 프롬프트
  3. 평가 모델 구성(현재 페이지)

개요

품질을 개선하기 위해 다음과 같은 옵션으로 평가 모델을 구성할 수 있습니다.

  • 시스템 안내: 평가 프롬프트를 처리하기 전에 평가 모델에서 안내 집합을 처리할 수 있습니다.
  • 평가 모델 구성:
    • 응답 전환: 평가 중에 평가 모델의 편향을 줄이기 위해 기준 모델과 후보 모델의 응답을 전환합니다.
    • 멀티 샘플링: 일관성을 개선하기 위해 평가 점수에 대해 평가 모델을 호출하는 횟수를 조정합니다.
    • 조정된 평가 모델: 조정된 LLM을 평가 모델로 사용합니다.

시스템 안내

Gemini 모델은 모델이 프롬프트를 처리하는 방식에 영향을 미치는 안내 집합인 시스템 안내를 가져올 수 있습니다. 모델에서 콘텐츠를 초기화하거나 생성할 때 시스템 안내를 사용하여 역할 또는 페르소나, 문맥 정보, 설명 스타일 및 어조와 같은 제품 수준의 동작을 지정할 수 있습니다. 평가 모델은 일반적으로 입력 프롬프트보다 시스템 안내의 중요성을 더 높게 평가합니다.

시스템 안내를 지원하는 모델 목록은 지원되는 모델을 참조하세요.

다음 Vertex AI SDK 예시에서는 PointwiseMetric의 측정항목 수준에 system_instruction을 추가합니다.

system_instruction = "You are an expert evaluator."
linguistic_acceptability = PointwiseMetric(
    metric="linguistic_acceptability",
    metric_prompt_template=linguistic_acceptability_metric_prompt_template,
    system_instruction=system_instruction,
)

eval_result = EvalTask(
    dataset=EVAL_DATASET,
    metrics=[linguistic_acceptability]
).evaluate()

PairwiseMetric에도 동일한 접근 방식을 사용할 수 있습니다.

평가 모델 구성

autorater_config를 통해 평가 모델을 추가로 맞춤설정할 수 있습니다.

  • 응답 전환: 평가 중에 평가 모델의 편향을 줄이기 위해 기준 모델과 후보 모델의 응답을 전환합니다.

  • 멀티 샘플링: 일관성을 개선하기 위해 평가 점수에 대해 평가 모델을 호출하는 횟수를 조정합니다.

  • 조정된 평가 모델: 조정된 LLM을 평가 모델로 사용합니다.

응답 전환

PairwiseMetrics의 경우 Gen AI Evaluation Service는 기준 모델과 후보 모델의 응답을 가져옵니다. 평가 모델은 metric_prompt_template의 기준에 더 잘 부합하는 응답을 평가합니다. 그러나 특정 설정에서 평가 모델이 기준 모델 또는 후보 모델에 편향될 수 있습니다.

평가 결과의 편향을 줄이려면 평가 모델 호출의 절반이 Vertex AI SDK를 사용하여 기준 모델과 후보 모델 응답을 전환하는 응답 전환을 사용 설정할 수 있습니다.

from vertexai.preview.evaluation import AutoraterConfig

pairwise_relevance_prompt_template = """
    # Instruction


    ### Response A
    {baseline_model_response}

    ### Response B
    {candidate_model_response}
"""

my_pairwise_metric = PairwiseMetric(
    metric="my_pairwise_metric",
    metric_prompt_template=pairwise_relevance_prompt_template,
    candidate_response_field_name = "candidate_model_response",
    baseline_response_field_name = "baseline_model_response"
)


# Define an AutoraterConfig with flip_enabled
my_autorater_config = AutoraterConfig(flip_enabled=True)

# Define an EvalTask with autorater_config
flip_enabled_eval_result = EvalTask(
    dataset=EVAL_DATASET,
    metrics=[my_pairwise_metric],
    autorater_config=my_autorater_config,
).evaluate()

멀티 샘플링

평가를 실행할 때 평가 모델의 응답에 약간의 무작위성이 나타날 수 있습니다. 샘플링을 추가하면 평가 모델의 고���한 무작위성을 제거하고 더 일관된 결과를 얻을 수 있습니다.

하지만 샘플링을 늘리면 요청을 완료하는 데 걸리는 지연 시간도 늘어납니다. AutoraterConfig를 사용하여 샘플링 횟수 값을 1과 32 사이의 정수로 업데이트할 수 있습니다. 무작위성과 지연 시간이라는 두 가지 요소의 균형을 맞추려면 기본 sampling_count 값으로 4를 사용하는 것이 좋습니다.

Vertex AI SDK를 사용하여 각 요청에 대해 실행되는 샘플 수를 지정할 수 있습니다.

from vertexai.preview.evaluation import AutoraterConfig

# Define customized sampling count in AutoraterConfig
autorater_config = AutoraterConfig(sampling_count=6)

# Run evaluation with the sampling count.
eval_result = EvalTask(
    dataset=EVAL_DATASET,
    metrics=[METRICS],
    autorater_config=autorater_config
).evaluate()

조정된 평가 모델

평가 사용 사례에 적합한 조정 데이터가 있는 경우 Vertex AI SDK를 사용하여 Gemini 모델을 평가 모델로 조정하고 조정된 모델을 평가에 사용할 수 있습니다. AutoraterConfig를 통해 조정된 모델을 평가 모델로 지정할 수 있습니다.

from vertexai.preview.evaluation import {
   AutoraterConfig,
   PairwiseMetric,
   tune_autorater,
   evaluate_autorater,
}

# Tune a model to be the judge model. The tune_autorater helper function returns an AutoraterConfig with the judge model set as the tuned model.
autorater_config: AutoRaterConfig = tune_autorater(
    base_model="gemini-2.0-flash",
    train_dataset=f"{BUCKET_URI}/train/sft_train_samples.jsonl",
    validation_dataset=f"{BUCKET_URI}/val/sft_val_samples.jsonl",
    tuned_model_display_name=tuned_model_display_name,
)

# Alternatively, you can set up the judge model with an existing tuned model endpoint
autorater_config = AutoraterConfig(autorater_model=TUNED_MODEL)

# Use the tuned judge model
eval_result = EvalTask(
    dataset=EVAL_DATASET,
    metrics=[METRICS],
    autorater_config=autorater_config,
).evaluate()

다음 단계