Skip to content

Commit

Permalink
Update README files (#117)
Browse files Browse the repository at this point in the history
* update README

* introduce features

* add demo

---------

Co-authored-by: wangzy <[email protected]>
  • Loading branch information
braisedpork1964 and wangzy authored Jan 31, 2024
1 parent 35331a5 commit f887b42
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 464 deletions.
126 changes: 21 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,10 @@ English | [简体中文](README_zh-CN.md) | [日本語](README_ja_JP.md) | [ह
👋 join us on <a href="https://twitter.com/intern_lm" target="_blank">𝕏 (Twitter)</a>, <a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a> and <a href="https://r.vansin.top/?r=internwx" target="_blank">WeChat</a>
</p>

## What's Lagent?

Lagent is a lightweight open-source framework that allows users to efficiently build large language model(LLM)-based agents. It also provides some typical tools to augment LLM. The overview of our framework is shown below:

![image](https://github.com/InternLM/lagent/assets/24351120/cefc4145-2ad8-4f80-b88b-97c05d1b9d3e)

## 💻Tech Stack

<p>
<a href="">
<img src="https://img.shields.io/badge/Python-007ACC?style=for-the-badge&logo=python&logoColor=yellow" alt="python" />
</a>

### Major Features

**0.1.2** was released in 24/10/2023:

- **Support an efficient inference engine.** Lagent now supports efficient inference engine [lmdeploy turbomind](https://github.com/InternLM/lmdeploy/tree/main).

- **Support multiple kinds of agents out of the box.** Lagent now supports [ReAct](https://arxiv.org/abs/2210.03629), [AutoGPT](https://github.com/Significant-Gravitas/Auto-GPT) and [ReWOO](https://arxiv.org/abs/2305.18323), which can drive the large language models(LLMs) for multiple trials of reasoning and function calling.

- **Extremely simple and easy to extend.** The framework is quite simple with a clear structure. With only 20 lines of code, you are able to construct your own agent. It also supports three typical tools: Python interpreter, API call, and google search.
<div align="center">

- **Support various large language models.** We support different LLMs, including API-based (GPT-3.5/4) and open-source (LLaMA 2, InternLM) models.
[![Alt text](https://img.youtube.com/vi/YAelRLi0Zak/0.jpg)](https://www.youtube.com/watch?v=YAelRLi0Zak)
</div>

## Getting Started

Expand All @@ -57,100 +37,36 @@ Install with pip (Recommended).
pip install lagent
```

Optionally, you could also build Lagent from source in case you want to modify the code:
### Run a Web Demo

```bash
git clone https://github.com/InternLM/lagent.git
cd lagent
pip install -e .
```

### Run ReAct Web Demo
You need to install Streamlit first.

```bash
# You need to install streamlit first
# pip install streamlit
streamlit run examples/react_web_demo.py
streamlit run examples/internlm2_agent_web_demo.py
```

Then you can chat through the UI shown as below
![image](https://github.com/InternLM/lagent/assets/24622904/3aebb8b4-07d1-42a2-9da3-46080c556f68)

### Run a ReWOO agent with GPT-3.5

Below is an example of running ReWOO with GPT-3.5

```python
# Import necessary modules and classes from the "lagent" library.
from lagent.agents import ReWOO
from lagent.actions import ActionExecutor, GoogleSearch
from lagent.llms import GPTAPI
## What's Lagent?

# Initialize the Language Model (llm) and provide your API key.
llm = GPTAPI(model_type='gpt-3.5-turbo', key=['Your OPENAI_API_KEY'])
Lagent is a lightweight open-source framework that allows users to efficiently build large language model(LLM)-based agents. It also provides some typical tools to augment LLM. The overview of our framework is shown below:

# Initialize the Google Search tool and provide your API key.
search_tool = GoogleSearch(api_key='Your SERPER_API_KEY')
![image](https://github.com/InternLM/lagent/assets/24351120/cefc4145-2ad8-4f80-b88b-97c05d1b9d3e)

# Create a chatbot by configuring the ReWOO agent.
chatbot = ReWOO(
llm=llm, # Provide the Language Model instance.
action_executor=ActionExecutor(
actions=[search_tool] # Specify the actions the chatbot can perform.
),
)
## Major Features

# Ask the chatbot a question and store the response.
response = chatbot.chat('What profession does Nicholas Ray and Elia Kazan have in common')
- Stream Output: Provides the `stream_chat` interface for streaming output, allowing cool streaming demos right at your local setup.
- Interfacing is unified, with a comprehensive design upgrade for enhanced extensibility, including:
- Model: Whether it's the OpenAI API, Transformers, or LMDeploy inference acceleration framework, you can seamlessly switch between models.
- Action: Simple inheritance and decoration allow you to create your own personal toolkit, adaptable to both InternLM and GPT.
- Agent: Consistent with the Model's input interface, the transformation from model to intelligent agent only takes one step, facilitating the exploration and implementation of various agents.
- Documentation has been thoroughly upgraded with full API documentation coverage.

# Print the chatbot's response.
print(response.response) # Output the response generated by the chatbot.
>>> Film director.
```
## 💻Tech Stack

### Run a ReAct agent with InternLM

NOTE: If you want to run a HuggingFace model, please run `pip install -e .[all]` first.

```python
# Import necessary modules and classes from the "lagent" library.
from lagent.agents import ReAct
from lagent.actions import ActionExecutor, GoogleSearch, PythonInterpreter
from lagent.llms import HFTransformer

from lagent.llms.meta_template import INTERNLM2_META as META

# Initialize the HFTransformer-based Language Model (llm) and
# provide the model name.
llm = HFTransformer(
path='internlm/internlm2-chat-7b',
meta_template=META
)

# Initialize the Google Search tool and provide your API key.
search_tool = GoogleSearch(
api_key='Your SERPER_API_KEY')

# Initialize the Python Interpreter tool.
python_interpreter = PythonInterpreter()

# Create a chatbot by configuring the ReAct agent.
# Specify the actions the chatbot can perform.
chatbot = ReAct(
llm=llm, # Provide the Language Model instance.
action_executor=ActionExecutor(
actions=[python_interpreter]
),
)
# Ask the chatbot a mathematical question in LaTeX format.
response = chatbot.chat(
'若$z=-1+\sqrt{3}i$,则$\frac{z}{{z\overline{z}-1}}=\left(\ \ \right)$'
)

# Print the chatbot's response.
print(response.response) # Output the response generated by the chatbot.
>>> $-\\frac{1}{3}+\\frac{{\\sqrt{3}}}{3}i$
```
<p>
<a href="">
<img src="https://img.shields.io/badge/Python-007ACC?style=for-the-badge&logo=python&logoColor=yellow" alt="python" />
</a>

### All Thanks To Our Contributors:
<a href="https://github.com/InternLM/lagent/graphs/contributors">
Expand Down
83 changes: 9 additions & 74 deletions README_KR_Kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,10 @@ English | [简体中文](README_zh-CN.md) | [日本語](README_ja_JP.md) | [ह
👋 join us on <a href="https://twitter.com/intern_lm" target="_blank">Twitter</a>, <a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a> and <a href="https://r.vansin.top/?r=internwx" target="_blank">WeChat</a>
</p>

## 소개

Lagent는 사용자가 효율적으로 대규모 언어 모델(LLM) 기반 에이전트를 구축할 수 있게 해주는 경량의 오픈 소스 프레임워크입니다. 또한 LLM을 보강하기 위한 몇 가지 일반적인 도구도 제공합니다. 우리 프레임워크의 개요는 아래와 같이 나와 있습니다:

![image](https://github.com/InternLM/lagent/assets/24351120/cefc4145-2ad8-4f80-b88b-97c05d1b9d3e)

### 주요 기능

**0.1.2** 은 2023년 10월 24일에 릴리스되었습니다:

- **효율적인 추론 엔진 지원.** Lagent는 이제 효율적인 추론 엔진 [lmdeploy turbomind](https://github.com/InternLM/lmdeploy/tree/main) 을 지원합니다.

- **다양한 종류의 에이전트를 기본으로 지원.** Lagent는 이제 [ReAct](https://arxiv.org/abs/2210.03629), [AutoGPT](https://github.com/Significant-Gravitas/Auto-GPT) and [ReWOO](https://arxiv.org/abs/2305.18323), 을 지원합니다. 이는 대규모 언어 모델(LLMs)을 이용하여 추론과 기능 호출의 여러 시행을 가능하게 합니다.

- **매우 간단하고 확장하기 쉽습니다.** 이 프레임워크는 구조가 명확한 간단한 구조를 가지고 있습니다. 20줄의 코드로 자체 에이전트를 구축할 수 있습니다. 또한 Python 인터프리터, API 호출, 구글 검색과 같은 세 가지 일반적인 도구를 지원합니다.
<div align="center">

- **다양한 대규모 언어 모델 지원.** 우리는 다른 LLMs를 지원하며, API 기반(GPT-3.5/4) 및 오픈 소스 (LLaMA 2, InternLM) 모델을 포함합니다.
[![Alt text](https://img.youtube.com/vi/YAelRLi0Zak/0.jpg)](https://www.youtube.com/watch?v=YAelRLi0Zak)
</div>

## 시작하기

Expand All @@ -46,72 +33,20 @@ pip를 사용하여 설치하십시오 (권장).
pip install lagent
```

원하는 경우 코드를 수정하려면 Lagent를 원본에서 빌드할 수도 있습니다:

```bash
git clone https://github.com/InternLM/lagent.git
cd lagent
pip install -e .
```
### 웹 데모 실행

### ReAct 웹 데모 실행
먼저 streamlit을 설치해야 합니다

```bash
# 먼저 streamlit을 설치해야 합니다
# pip install streamlit
streamlit run examples/react_web_demo.py
streamlit run examples/internlm2_agent_web_demo.py
```

그런 다음 아래와 같이 표시된 UI를 통해 채팅할 수 있습니다.
![image](https://github.com/InternLM/lagent/assets/24622904/3aebb8b4-07d1-42a2-9da3-46080c556f68)

### GPT-3.5로 ReWOO 에이전트 실행

아래는 GPT-3.5로 ReWOO를 실행하는 예입니다.

```python
from lagent.agents import ReWOO
from lagent.actions import ActionExecutor, GoogleSearch, LLMQA
from lagent.llms import GPTAPI

llm = GPTAPI(model_type='gpt-3.5-turbo', key=['Your OPENAI_API_KEY'])
search_tool = GoogleSearch(api_key='Your SERPER_API_KEY')
llmqa_tool = LLMQA(llm)

chatbot = ReWOO(
llm=llm,
action_executor=ActionExecutor(
actions=[search_tool, llmqa_tool]),
)

response = chatbot.chat('What profession does Nicholas Ray and Elia Kazan have in common')
print(response.response)
>>> Film director.
```

### InternLM과 함께 ReAct 에이전트 실행

참고: HuggingFace 모델을 실행하려면 먼저 pip install -e .[all]을 실행하십시오.

```python
from lagent.agents import ReAct
from lagent.actions import ActionExecutor, GoogleSearch, PythonInterpreter
from lagent.llms import HFTransformer

llm = HFTransformer('internlm/internlm-chat-7b-v1_1')
search_tool = GoogleSearch(api_key='Your SERPER_API_KEY')
python_interpreter = PythonInterpreter()
## 소개

chatbot = ReAct(
llm=llm,
action_executor=ActionExecutor(
actions=[search_tool, python_interpreter]),
)
Lagent는 사용자가 효율적으로 대규모 언어 모델(LLM) 기반 에이전트를 구축할 수 있게 해주는 경량의 오픈 소스 프레임워크입니다. 또한 LLM을 보강하기 위한 몇 가지 일반적인 도구도 제공합니다. 우리 프레임워크의 개요는 아래와 같이 나와 있습니다:

response = chatbot.chat('若$z=-1+\sqrt{3}i$,则$\frac{z}{{z\overline{z}-1}}=\left(\ \ \right)$')
print(response.response)
>>> $-\\frac{1}{3}+\\frac{{\\sqrt{3}}}{3}i$
```
![image](https://github.com/InternLM/lagent/assets/24351120/cefc4145-2ad8-4f80-b88b-97c05d1b9d3e)

## 인용

Expand Down
82 changes: 8 additions & 74 deletions README_in_HIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,10 @@ English | [简体中文](README_zh-CN.md) | [日本語](README_ja_JP.md) | [ह

</div>

<p align="center">
👋 <a href="https://twitter.com/intern_lm" target="_blank">Twitter</a>, <a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a> और <a href="https://r.vansin.top/?r=internwx" target="_blank">WeChat</a> पर हमसे जुड़ें
</p>

## परिचय

Lagent एक हल्का ओपन-सोर्स फ्रेमवर्क है जो उपयोगकर्ताओं को बड़े भाषा मॉडल (एलएलएम)-आधारित एजेंटों को कुशलतापूर्वक बनाने की अनुमति देता है। यह एलएलएम को बढ़ाने के लिए कुछ विशिष्ट उपकरण भी प्रदान करता है। हमारे ढांचे का अवलोकन नीचे दिखाया गया है:

![image](https://github.com/InternLM/lagent/assets/24351120/cefc4145-2ad8-4f80-b88b-97c05d1b9d3e)

### प्रमुख विशेषताएं

- **बॉक्स से बाहर कई प्रकार के एजेंटों का समर्थन करें।** लैजेंट अब समर्थन करता है [ReAct](https://arxiv.org/abs/2210.03629), [AutoGPT](https://github.com/Significant-Gravitas/Auto-GPT) और [ReWOO](https://arxiv.org/abs/2305.18323), जो तर्क और फ़ंक्शन कॉलिंग के कई परीक्षणों के लिए बड़े भाषा मॉडल (एलएलएम) को संचालित कर सकता है।

- **बेहद सरल और विस्तार करने में आसान।** स्पष्ट संरचना के साथ ढांचा काफी सरल है। कोड की केवल 20 पंक्तियों के साथ, आप अपना स्वयं का एजेंट बनाने में सक्षम हैं। यह तीन विशिष्ट टूल का भी समर्थन करता है: पायथन इंटरप्रेटर, एपीआई कॉल और गूगल सर्च।
<div align="center">

- **विभिन्न बड़े भाषा मॉडल का समर्थन करें।** हम एपीआई-आधारित (जीपीटी-3.5/4) और ओपन-सोर्स (एलएलएएमए 2, इंटर्नएलएम) मॉडल सहित विभिन्न एलएलएम का समर्थन करते हैं।
[![Alt text](https://img.youtube.com/vi/YAelRLi0Zak/0.jpg)](https://www.youtube.com/watch?v=YAelRLi0Zak)
</div>

## शुरू करना

Expand All @@ -42,72 +29,19 @@ pip के साथ स्थापित करें (अनुशंसि
pip install lagent
```

वैकल्पिक रूप से, यदि आप कोड को संशोधित करना चाहते हैं तो आप स्रोत से लैजेंट भी बना सकते हैं:

```bash
git clone https://github.com/InternLM/lagent.git
cd lagent
pip install -e .
```

### रिएक्ट वेब डेमो चलाएँ
### वेब डेमो चलाएँ

```bash
# You need to install streamlit first
# pip install streamlit
streamlit run examples/react_web_demo.py
streamlit run examples/internlm2_agent_web_demo.py
```

फिर आप नीचे दिखाए गए यूआई के माध्यम से चैट कर सकते हैं
![image](https://github.com/InternLM/lagent/assets/24622904/3aebb8b4-07d1-42a2-9da3-46080c556f68)

### GPT-3.5 के साथ ReWOO एजेंट चलाएँ

GPT-3.5 के साथ ReWOO चलाने का एक उदाहरण नीचे दिया गया है

```python
from lagent.agents import ReWOO
from lagent.actions import ActionExecutor, GoogleSearch, LLMQA
from lagent.llms import GPTAPI

llm = GPTAPI(model_type='gpt-3.5-turbo', key=['Your OPENAI_API_KEY'])
search_tool = GoogleSearch(api_key='Your SERPER_API_KEY')
llmqa_tool = LLMQA(llm)

chatbot = ReWOO(
llm=llm,
action_executor=ActionExecutor(
actions=[search_tool, llmqa_tool]),
)

response = chatbot.chat('What profession does Nicholas Ray and Elia Kazan have in common')
print(response.response)
>>> Film director.
```

### InternLM के साथ एक ReAct एजेंट चलाएँ

नोट: यदि आप हगिंगफेस मॉडल चलाना चाहते हैं, तो कृपया पहले `pip install -e .[all]` चलाएं।

```python
from lagent.agents import ReAct
from lagent.actions import ActionExecutor, GoogleSearch, PythonInterpreter
from lagent.llms import HFTransformer

llm = HFTransformer('internlm/internlm-chat-7b-v1_1')
search_tool = GoogleSearch(api_key='Your SERPER_API_KEY')
python_interpreter = PythonInterpreter()
## परिचय

chatbot = ReAct(
llm=llm,
action_executor=ActionExecutor(
actions=[search_tool, python_interpreter]),
)
Lagent एक हल्का ओपन-सोर्स फ्रेमवर्क है जो उपयोगकर्ताओं को बड़े भाषा मॉडल (एलएलएम)-आधारित एजेंटों को कुशलतापूर्वक बनाने की अनुमति देता है। यह एलएलएम को बढ़ाने के लिए कुछ विशिष्ट उपकरण भी प्रदान करता है। हमारे ढांचे का अवलोकन नीचे दिखाया गया है:

response = chatbot.chat('若$z=-1+\sqrt{3}i$,则$\frac{z}{{z\overline{z}-1}}=\left(\ \ \right)$')
print(response.response)
>>> $-\\frac{1}{3}+\\frac{{\\sqrt{3}}}{3}i$
```
![image](https://github.com/InternLM/lagent/assets/24351120/cefc4145-2ad8-4f80-b88b-97c05d1b9d3e)

## लाइसेंस

Expand Down
Loading

0 comments on commit f887b42

Please sign in to comment.