빅데이타 & 머신러닝/생성형 AI (ChatGPT etc)

주제와 관계 없는 질문을 막기 위한 DARE 프롬프팅 기법

Terry Cho 2023. 11. 1. 14:34

주제와 관계 없는 질문을 막기 위한 DARE 프롬프팅 기법

조대협 (http://bcho.tistory.com)

 

LLM모델을 기반으로 채팅 서비스등을 개발할때, 마주하는 문제중 하나가 사용자가 주제와 관련 없는 질문을 하는 경우 이를 어떻게 판별하고 필터링할 것인가이다. 예를 들어 LLM(ChatGPT등) API를 바로 연결해서 여행 사이트용 챗봇을 만들었다고 가정하자. 이때 사용자가 악의적으로 여행과 관련 없는 질문을 하더라도 LLM API로 전달된 질문은 답변이 되기 때문에 악용 될 수 있다.

 

예를 들어 아래 프롬프트는 챗봇에게 여행사이트 챗봇의 역할을 부여하고 컨택스트를 강제하여 주었지만 사용자가 미국 자동차 모델중 최고 모델을 질의하는 프롬프트인데, 여행 챗봇임에도 불구하고 이 질문에 대해서 답변을 한다. 

You are a chatbot for a travel web site.

Context: I'm going to travel to Seoul this winter with my family. I have 2 daughters and a wife.

Question : What is the best car model in the US?

이렇게 악의적으로 서비스 주제와 관련 없는 질문을 하는 것을 방지 하는 프롬프팅 작성 방식을 DARE (Determine Appropriate REsponse)기법이라고 하는데 다음과 같은 구조를 따르면 된다.

{your role}{your mission}
{
  Add context
}
Remember that you answer a question, you must check to see if it complies with your mission above. If not, you must respond, "I am not able to answer this question"
Question : {user prompt}

 

role과 mission을 정의해준 후에, 질문전에 mission과 관련 없는 질문의 경우에는 “답변을 할 수 없다”는 메세지를 출력하도록 가이드 하는 방식이다. 이 DARE 프롬프트를 적용해서 위의 프롬프트를 다시 개선해보면 다음과 같다. 

 

You are a chatbot for a travel web site.
Your mission is to provide helpful queries for travelers.
Context: I'm going to travel to Seoul this winter with my family. I have 2 daughters and a wife.

Remember that you answer a question, you must check to see if it complies with your mission above. If not, you must respond, "I am not able to answer this question"

Question : What is the best car model in the US?

 

결과는 “I am not able to answer this question” 이 출력된다. 다시 말해서 챗봇의 역할과 관련 없는 질문에 대해서 필터링이 되는 것이다.

 

그리드형