수정된 출력

수정된 출력 (Corrected Outputs)

Corrections를 사용하면 trace와 observation 뷰에서 직접 LLM 출력의 개선된 버전을 캡처할 수 있어요. 도메인 전문가가 모델이 생성했어야 하는 내용을 문서화해, 파인튜닝 데이터셋과 지속적인 개선을 위한 기반을 만들 수 있어요.

출처: 문서

본문

Corrections를 사용하면 trace와 observation 뷰에서 직접 LLM 출력의 개선된 버전을 캡처할 수 있어요. 도메인 전문가가 모델이 생성했어야 하는 내용을 문서화해 파인튜닝 데이터셋과 지속적 개선의 기반을 만들어요.

Corrected output with diff view

왜 Corrections를 쓰나요? (Why Use Corrections?)

  • 도메인 전문가 피드백: 주제 전문가가 자신의 전문성에 기반해 모델이 출력했어야 하는 내용을 제공.
  • 파인튜닝 데이터셋: 수정된 출력을 원래 입력과 함께 내보내 프로덕션 trace에서 고품질 훈련 데이터를 만들기.
  • 품질 벤치마킹: 프로덕션 trace 전반에서 실제 vs 기대 출력을 비교해 체계적인 문제를 식별.
  • Human-in-the-loop 워크플로: 리뷰 과정에서 수정을 캡처, 특히 annotation queues에서 유용.

작동 방식 (How It Works)

UI나 API를 통해 아무 trace·observation에 수정된 출력을 추가하세요. Corrections는 원래 출력 옆에 무엇이 바뀌었는지 보여주는 diff 뷰와 함께 나타나요. 각 trace·observation은 하나의 수정된 출력을 가질 수 있어요.

Corrections 추가 (Adding Corrections)

UI를 통해 (Via the UI)

아무 trace·observation 상세 페이지로 이동하세요:

  1. 원래 출력 아래의 "Corrected Output" 필드를 찾으세요.
  2. 클릭해 수정을 추가하거나 편집하세요.
  3. 출력의 개선된 버전을 입력하세요.
  4. 데이터 형식에 맞게 JSON 검증 모드와 일반 텍스트 모드 사이를 토글하세요.
  5. 원본 vs 수정 출력을 비교하는 diff를 보세요.

Adding a correction in the UI

편집기는 입력하는 대로 자동 저장하고 JSON 모드에서 실시간 검증 피드백을 제공해요.

API/SDK를 통해 (Via API/SDK)

Corrections는 dataType: "CORRECTION"name: "output"을 가진 score로 생성돼요.

Python

from langfuse import Langfuse

langfuse = Langfuse()

# Add correction to a trace
langfuse.create_score(
    trace_id="trace-123",
    name="output",
    value="The corrected output text here",
    data_type="CORRECTION"
)

# Add correction to an observation
langfuse.create_score(
    trace_id="trace-123",
    observation_id="obs-456",
    name="output",
    value="The corrected output text here",
    data_type="CORRECTION"
)

TypeScript

import { LangfuseClient } from "@langfuse/client";

const langfuse = new LangfuseClient();

// Add correction to a trace
langfuse.score.create({
  traceId: "trace-123",
  name: "output",
  value: "The corrected output text here",
  dataType: "CORRECTION"
});

// Add correction to an observation
langfuse.score.create({
  traceId: "trace-123",
  observationId: "obs-456",
  name: "output",
  value: "The corrected output text here",
  dataType: "CORRECTION"
});

HTTP

curl -X POST https://cloud.langfuse.com/api/public/scores \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic <base6...als>" \
  -d '{
    "traceId": "trace-123",
    "observationId": "obs-456",
    "name": "output",
    "value": "The corrected output text here",
    "dataType": "CORRECTION"
  }'

Corrections 가져오기 (Fetching Corrections)

Corrections는 score로 저장되며 데이터셋을 만들거나 모델 성능을 분석하기 위해 프로그래밍 방식으로 가져올 수 있어요. dataType=CORRECTION으로 Scores API를 필터링하세요. 수정된 출력은 value 필드에 있어요.

Python

from langfuse import get_client

langfuse = get_client()

corrections = langfuse.api.scores_v3.get_many_v3(
    data_type="CORRECTION",
    fields="subject,details",
)

TypeScript

import { LangfuseClient } from "@langfuse/client";

const langfuse = new LangfuseClient();

const corrections = await langfuse.api.scoresV3.getManyV3({
  dataType: "CORRECTION",
  fields: "subject,details",
});

HTTP

curl -X GET "https://cloud.langfuse.com/api/public/v3/scores?dataType=CORRECTION&fields=subject,details" \
  -H "Authorization: Basic <base6...als>"

더 알아보기 (Learn more)