ReAct: Synergizing Reasoning and Acting in Language Models

Taewoo Kim·2025년 1월 6일
0

[Prompt Engineering]

목록 보기
3/7

1. Introduction

기존 CoT와 같은 방식은 학습된 정보만을 가지고 작동하여 정보가 업데이트 되지 않는 static black box임. 그로인해 Hallucination과 error propagation이 발생.

ReAct : reasoning과 acting을 상호보완적으로 결합한 모델로, reasoning은 모델이 행동 계획을 세우고, 이를 추적하며 조정하는 데 도움을 주고, acting은 모델이 외부 정보(ex: Wikipedia API)를 활용해 reasoning을 개선.

2. ReAct : Synergizing Reasoning + Acting

특정 시점 t에서 Agent는 Environment으로부터 관측 oto_t를 통해, 정책 π(atct)\pi(a_t|c_t)에 따라 ata_t을 취함. ctc_t는 에이전트에 대한 context로 과거의 모든 관찰과 행동의 집함을 의미.

ctc_t = ( o1,a1,,ot1,at1,ot)o_1,a_1, \cdot \cdot \cdot , o_{t-1},a_{t-1},o_t)

문제점

ctc_tata_t로 mapping 하는 policy를 학습하는 것은 복잡한 추론이 필요하거나, 에이전트가 적절한 행동을 생성하지 못하는 상황이 발생.

ReAct 아이디어

에이전트의 action space를 A^=AL\hat{A} = A \cup L로 확장. LL은 space of language를 의미.

thought나 reasoning trace라고 부르는 action을 a^tL\hat{a}_t \in L 은 외부 환경 (extenal environment)로부터 영향을 받지 않아 observation feedback이 생기지 않음.

a^t\hat{a}_t는 현재 context ctc_t을 바탕으로 유용한 정보를 구성하고, 이를 통해 미래의 행동에 도움이 되도록 context ct+1=(ct,a^t)c_{t+1} = (c_t,\hat{a}_t)을 업데이트하는 역할을 함.

ReAct의 특징

  1. Intuitive and easy to design : 프롬프트 디자인하는 것이 직관적이고 자연어를 사용하기 때문에 Human annotators가 생각하는 정보를 직접 입력을 통해 쉽게 생성 가능.
  2. General and flexible: ReAct는 다양한 작업에 적용 가능.
  3. Performant and robust: ReAct는 1~6개의 in-context examples 정도만 있어도 좋은 성능을 보임.
  4. Human aligned and controllable: 인간이 에이전트의 사고 과정을 쉽게 이해하고, thought나 action을 수정할 수 있도록 해줌.

3. Method

ReAct Prompting : Hotpot QA와 Fever에서 각각 6개와 3개의 case를 무작위로 선택해 ReAct 형식의 trajectories를 구성하여 few-shot 예시로 사용, 각 trajectory consists는 thought-action-observation 단계로 구성

※ Trajectory : Reasoning/Thoughts, Actions, Observation 등 기본 프롬프트 질문에서 이어지는 과정을 나열한 것으로, ReAct Prompting에서 few shot example로 제공하거나,

fine-tuning 진행 후 최종 질문을 하였을 때, 학습했던 Trajectory에 따라 추론-act-obs를 실행하도록 지시한다.

Thought의 종류 : ****

  • decompose questions: (“I need to search x, find y, then find z”)
  • extract information from Wikipedia observations: (“x was started in 1844”, “The paragraph does not tell x”)
  • perform commonsense: (“x is not y, so z must instead be...”)
  • arithmetic reasoning: (“1844 < 1989”)
  • guide search reformulation: (“maybe I can search/look up x instead”)
  • synthesize the final answer: (“...so the answer is x”)

Baselines

ReAct 경로에서 요소들을 제거하여 여러 기준을 설정했습니다:

  • Standard Prompting: 모든 생각, 행동, 관찰을 제거한 프롬프팅.
  • Chain-of-Thought Prompting(CoT): 행동과 관찰을 제거하여 추론만 수행하는 방식. + CoT-SC(Self consistency)
  • Acting-only Prompting(Act): 생각을 제거한 행동만 수행하는 방식.

Combining Internal and External Knowledge

Results

Finetuning

4. Decision Making Tasks

  • ALFWorld : 텍스트 기반의 가상 가정 환경 시뮬레이션 게임, ALFRED 벤치마크를 따름.

  • ALFWorld

  • WebShop

Reference

kyopark2014-Github

LangSmith

0개의 댓글