[부스트캠프] Day 107 회고

Gamchan Kang·2025년 1월 20일
0

주말 동안 self-refine 논문을 간단하게 훑고, CheckEval의 Aspect 및 평가 루브릭 설정을 위한 요약의 필수 조건 5가지를 고민했다. 특히 LLM이 평가하는 요소인 만큼, 사람과 유사하면서도 다른 점을 고려해야 한다. 정말 운이 좋게도 우리 팀의 담당 멘토님이 CheckEval 논문 저자셔서 Aspects 설정에 대한 자세한 예시를 들을 수 있었다. Aspects 간 서로 겹치는 부분이 없어야 하며, 각 요소들은 아주 상세해야 한다는 점이 키 포인트였다. 요약하자면 다음과 같다.

CheckEval의 Aspects는 각가 명확하게 정의되어야 하며, 상호 배타적(mutually exclusive)이어야 한다.

실제 평가를 하지 않아 LLM이 어떻게 동작하는지 감이 잡히지 않는다. 다만, Aspects를 깔끔하게 정의하면 Agent 실행 시, 더욱 세밀한 reflection으로 개별 요약문 혹은 최종 리포트의 품질을 끌어올릴 수 있을 것으로 보인다.

오늘은 self-refine 코드를 아주 간단하게 구현했다. reflexion 리뷰를 담당한 팀원과 이야기를 나누고, reflexion 공식 깃허브 레포를 살펴보니 프롬프트가 잘 이해가 안 됐다. reflexion 동작은 어렴풋이 이해했는데, 각 프롬프트가 어떤 동작을 의미하는지 연결이 안 됐다.

from langchain.prompts import PromptTemplate

COT_INSTRUCTION = """Solve a question answering task by having a Thought, then Finish with your answer. Thought can reason about the current situation. Finish[answer] returns the answer and finishes the task. You will be given context that you should use to help you answer the question.
Here are some examples:
{examples}
(END OF EXAMPLES)
{reflections}
Relevant Context: {context} 
Question: {question}{scratchpad}"""

COT_AGENT_REFLECT_INSTRUCTION = """Solve a question answering task by having a Thought, then Finish with your answer. Thought can reason about the current situation. Finish[answer] returns the answer and finishes the task. You will be given context that you should use to help you answer the question.
Here are some examples:
{examples}
(END OF EXAMPLES)

{reflections}

Relevant Context: {context}
Question: {question}{scratchpad}"""

COT_REFLECT_INSTRUCTION = """You are an advanced reasoning agent that can improve based on self refection. You will be given a previous reasoning trial in which you were given access to relevant context and a question to answer. You were unsuccessful in answering the question either because you guessed the wrong answer with Finish[<answer>] or there is a phrasing discrepancy with your provided answer and the answer key. In a few sentences, Diagnose a possible reason for failure or phrasing discrepancy and devise a new, concise, high level plan that aims to mitigate the same failure. Use complete sentences.  
Here are some examples:
{examples}
(END OF EXAMPLES)

Previous trial:
Relevant Context: {context}
Question: {question}{scratchpad}

Reflection:"""

cot_agent_prompt = PromptTemplate(
                        input_variables=["examples", "reflections", "context", "question", "scratchpad"],
                        template = COT_INSTRUCTION,
                        )

cot_reflect_agent_prompt = PromptTemplate(
                        input_variables=["examples", "reflections", "context", "question", "scratchpad"],
                        template = COT_AGENT_REFLECT_INSTRUCTION,
                        )

cot_reflect_prompt = PromptTemplate(
                        input_variables=["examples", "context", "question", "scratchpad"],
                        template = COT_REFLECT_INSTRUCTION,
                        )

COT_INSTRUCTIONCOT_AGENT_REFLECT_INSTRUCTION, COT_REFLECT_INSTRUCTION이 논문 다이어그램의 어느 부분에 해당되는지 잘 감이 안 잡혔다.

우선, self-refine이 reflexion보다 먼저 나온 기술이니 처음에는 self-refine을 적용하고 정량적인 평가로 reflexion을 적용하자고 이야기를 했다. reflexion 담당 팀원은 멘토링에 처음 reflexion을 소개받았으니, 멘토님께 커피챗을 요청하여 reflexion을 더 면밀하게 이해한다고 했다. 이런 적극성은 정말 본 받아야 한다고 생각했다.

self-refine을 max_iteration=3으로 두어 얼추 구현했다. 다만, reasoning 정보가 최종 요약문에 같이 출력된다는 점, 분류 카테고리에 정적으로 적용된다는 점이 수정해야 할 사항이다.

profile
Someday, the dream will come true

0개의 댓글