본문 바로가기
Projects/Agent Simulation

Autonomous Agents, Simulation with Agents

by 두우우우움 2023. 5. 16.
짧은 시간 동안 찾아보고 생각을 정리한 글이므로 틀린 정보가 있을 수 있습니다.

 

Autonomous Agents

 OpenAI의 ChatGPT 이전부터 현재까지 LLM(Large Language Models)은 빠르게 발전 중이며 이제는 하나의 역할을 수행하는 Agent를 정의하고 동작하는데 사용할 수 있게 되었다. 이를 통해 잘 질문해야만 잘 답변 받았던 이전과 달리 "대충"  질문해도 좋은 답변을 받을 수 있게 되었다. 

 

 

 어떻게 하나의 역할을 수행하는지 알아보자.

Baby AGI: how it works

 대표적인 LLM을 통한 Autonomous Agent 중 하나인 Baby AGI는 위와 같이 내재적으로 질문에 대한 과제를 만들고 우선 순위를 정하여 해결하는 방법을 도출한다. 반복적으로 과제를 만들고 해결하면서 만들어진 질문과 답변을 DB에 저장하여 다음 질문을 던질 때, 이를 사용하여 질문을 풍성하게 한다.

 

 다음으로 AutoGPT는 역할과 목표를 입력하면 해당 역할이 목표를 해결하기 위한 방안을 도출한다. 마찬가지로 내재적으로 목표를 달성하기 위한 과정을 메모리에 저장하고 사용하며 AutoGPT는 인터넷 접근이 가능하여 구글링을 통해 학습되지 않은 최근 정보도 답변 받을 수 있다.

 

 위와 같은 과정이 모두 ChatGPT 같은 LLM 모델에 질문을 통해 이루어진다. 예를 들어, 자산 운용사 역할을 부여받은 Agent에게  "돈을 많이 벌기 위해서는 어떻게 해야 할까?"에 대한 질문을 던지면 Agent는 내재적으로 "너는 자산 운용사인데, 돈을 많이 벌기 위해선 구체적으로 어떻게 해야 할까?"라는 질문을 ChatGPT한테 물어보는 것이다.

 이렇게 LLM에게 던지는 질문을 Prompt라고 하며 LLM에게 혹은 Agent가 LLM에게 좋은 질문을 하기 위해 질문 형식을 설정하는 직업인 프롬프트 엔지니어가 새롭게 나타나고 있다.

 

 

 

Simulation with Agents

 더 구체적인 답변이나 목적을 이루기 위해 하나의 역할을 수행하는 Agent만을 사용하는 것이 아닌 여러 Agent를 사용하여 Simulation을 진행할 수 있다.

 

CAMEL: role playing

  대표적인 Agent Simulation 중 하나인 CAMEL(Communicative Agents for "Mind" Exploration of Large Scale Language Model Society)은 위 이미지에서 확인할 수 있는 Task Specifier, AI User, AI Assistant 총 세 개의 Agent가 동작한다. 사용자는 질문을 Agent한테 던지는 것 뿐만 아니라 Agent의 역할까지 부여하면 각 Agent들이 질문을 역할에 맞게 구체화하고 질문에 대한 해결책을 대화를 통해 도출한다.

 

 여기서 흥미로운 점은 AI User와 AI Assistant가 대화를 하며 서로의 역할이 바뀌는 것을 방지하기 위해 Inception Prompt라는 것을 사용했는데, 이는 프롬프트 앞에 "Never forget you are a Python Programmer and I am a Stock Trader" 같이 서로의 역할을 명시하는 프롬프트를 추가하는 것이었다. 

 

 

Generative Agents: Interactive Simulacra of Human Behavior

 다음으론 질문에 대한 해답을 도출하는 것이 아닌 25명의 Agent들이 작은 마을에서 생활하는 시뮬레이션을 진행한 Generative Agents이다. 25명의 Agent들은 이름과 역할, 배경 지식이 있으며 부여 받은 정보에 맞게 서로 상호 작용도 하며 생활한다. Agent들은 제 시간이 되면 밥을 먹거나 씻으며, 발렌타인 데이 파티장을 열어 다른 Agent를 초대하며 놀기도 했다.

 

Genrative Agent Architecture

 Generative Agent의 구조는 위와 같으며 Agent가 위 샌드박스 마을에서 무엇을 인지하거나 메모리(기억)에서 어떤 기억이 중요한지 판단할 때, 모두 프롬프트를 입력하여 LLM에서 받은 정보를 활용한다. 

 중간에 있는 Plan은 하루 할 일에 대해 어느 정도 계획을 세우는 것이고 Reflect는 특정 시간마다 본인의 환경, 기억에 대해 회고를 하는 것이며 계획과 회고 모두 프롬프트를 입력하고 받은 정볼르 메모리에 저장함으로써 수행된다.

 

 

 

Practice

 위에서 소개된 모든 Agent와 Simulation들은 파이썬 라이브러리인 Langchain에서 진행해볼 수 있다. 실제로 CAMEL을 로컬 환경에서 진행해봤고 "What should I do next to earn a lot of money?"라는 같은 질문에 대해서 AI User가 "Investment Manager", AI Assistance가 "Business Man"일 때와 AI User가 "Power Blogger", AI Assistance가 "Youtuber"일 때의 답변을 비교해보았다.

 

 AI User가 "Investment Manager", AI Assistance가 "Business Man"일 때는 신흥 기술 부문에 대해 답변해주며 아래와 같은 기업을 추천해주었고

  1. Tesla (TSLA) - electric vehicles and renewable energy
  2. Square (SQ) - fintech and digital payments
  3. Zoom Video Communications (ZM) - video conferencing and remote work solutions
  4. DocuSign (DOCU) - e-signature and digital transaction management
  5. Shopify (SHOP) - e-commerce and online retail solutions
  6. CrowdStrike (CRWD) - cybersecurity and threat intelligence
  7. Twilio (TWLO) - cloud communications and customer engagement
  8. Moderna (MRNA) - biotech and mRNA-based vaccines and therapies

 

 신흥 기술 부문에 대한 투자와 분석, 권장 사항의 주요 내용을 요약해주었다.

  1. The emerging technology sector includes a wide range of industries that are focused on developing new and innovative technologies.
  2. The sector is currently experiencing rapid growth, with many new technologies and startups entering the market.
  3. Investing in the emerging technology sector can be risky due to the high level of uncertainty and volatility in the market.
  4. Some specific companies in the emerging technology sector that have the potential to yield high returns for the portfolio within the next five years include Tesla, Square, Zoom Video Communications, DocuSign, Shopify, CrowdStrike, Twilio, and Moderna.
  5. A recommended investment strategy for the emerging technology sector is to invest in a diversified portfolio of companies across different sub-sectors of the industry.
  6. To monitor and adjust the portfolio over the next five years, it is important to regularly review the performance of the companies in the portfolio and the overall market trends in the emerging technology sector, and to work with a professional investment advisor if necessary.

 

 반면, AI User가 "Power Blogger", AI Assistance가 "Youtuber"일 때는 다음과 같이 블로거가 시작할 수 있는 유투브 주제를 추천해주었고 유투브로 돈을 벌기 위한 방법이나 자세에 대해 이야기해주었다.

  1. 1E-commerce store: With the rise of online shopping, starting an e-commerce store can be a profitable business idea. Power Bloggers can leverage their audience to promote their products and earn a commission on sales.
  2. Online courses: With the increasing demand for online education, creating and selling online courses can be a lucrative business idea. Power Bloggers can use their expertise to create courses in their niche and promote them to their audience.
  3. Digital products: Creating and selling digital products such as e-books, templates, and printables can be a profitable business idea for Power Bloggers. They can use their blog to promote their products and earn a commission on sales.
  4. Coaching and consulting: Power Bloggers can leverage their expertise to offer coaching and consulting services to their audience. This can be a highly lucrative business idea, especially if they have a large and engaged following.
  5. Affiliate marketing: Power Bloggers can earn a commission by promoting other people's products through affiliate marketing. This can be a highly profitable business idea, especially if they have a large and engaged following.

 

 

 

마치며...

 LLM을 통한 Agent의 논문을 읽고 구현된 라이브러리를 사용해보며 기술의 발전이 Exponential하게 이루어지고 있다는 것을 새삼 느꼈다. 아직 직업을 대체하거나 구체적인 업무를 End-to-End로 처리할 성능은 안되지만, 충분히 여러 어플리케이션에 적용할 수 있을 것이고 업무 외 재밌는 것들을 만들 수 있을 것 같다. 

 

 논문을 읽다보니 다른 논문과 다르게 통계적인 방법론이나 EDA를 통해 문제를 발견하고 해결한 것이 아닌, Heuristic하게 문제를 발견하고 프롬프트를 통해 해결한 것이 많아 Prompt Engineer와 Agent의 발전이 어떻게 진행될지 궁금한다.

댓글