시작하기무료로 시작하기

자기일관성으로 신뢰도 평가하기

아래의 prompt는 ChatGPT에게 리뷰의 감성을 분류하도록 요청합니다. 자기일관성(self-consistency)을 사용해 각 클래스에 대한 ChatGPT의 신뢰도를 추정해 보세요.

ChatGPT와 통신하기 위한 get_response() 함수가 미리 로드되어 있습니다.

이 연습은 강의의 일부입니다

Python으로 배우는 Explainable AI

강의 보기

연습 안내

  • 각 리뷰에 대해 responses 리스트에 sentiment를 추가하세요.
  • 각 감성에 대한 신뢰도를 계산하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

prompt = """Classify the following review as positive or negative. 
You should reply with either "positive" or "negative", nothing else.
Review: 'The coffee was excellent, but the service left much to be desired.'"""

responses = []
for i in range(5):
    sentiment = get_response(prompt)
    # Append the response to the responses list
    ____

# Compute the confidence for each sentiment
confidence = {
    'positive': ____,
    'negative': ____
}

print(confidence)
코드 편집 및 실행