-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reformat and improve RAG module and agents #184
base: main
Are you sure you want to change the base?
Conversation
Persist function added.
persist function added.
…dd a guide agent.
Enhance RAG example
copilot dialog agents update
as_copilot updates
move emb_model_config_name to knowledge_config
…dge bank and add tutorials
improve rag module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to follow the tutorial to use the RAG module. Some important guidances are missing as follows. More details please refer to inline comments.
- how to use the knowledge objects here, what methods does it provide?
- how to set the configuration, and what's the meaning and candidate values of each parameter?
update as comments suggest
update as comments suggest (for docs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the inline comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the inline comments.
The current version of rag is not compatible with distributed mode. We can add support in future PRs
update as comments
…s used in previous versions, but no longer needed.
# Conflicts: # examples/conversation_with_RAG_agents/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see inline comments
### Knowledge Bank | ||
知识库将一组Knowledge模块(例如,来自不同数据集的知识)作为知识的集合进行维护。因此,不同的智能体可以在没有不必要的重新初始化的情况下重复使用知识模块。考虑到配置Knowledge模块可能对大多数用户来说过于复杂,知识库还提供了一个简单的函数调用来创建Knowledge模块。 | ||
|
||
* `KnowledgeBank.add_data_as_knowledge`: 创建Knowledge模块。一种简单的方式只需要提供knowledge_id、emb_model_name和data_dirs_and_types。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What types do we support here? And for unsupported file types, what should the users do?
* `KnowledgeBank.add_data_as_knowledge`: 创建Knowledge模块。一种简单的方式只需要提供knowledge_id、emb_model_name和data_dirs_and_types。 | ||
```python | ||
knowledge_bank.add_data_as_knowledge( | ||
knowledge_id="agentscope_tutorial_rag", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more like a knowledge name rather than ID here
@@ -23,35 +22,28 @@ capability can be used to build easily. | |||
**Note:** This example has been tested with `dashscope_chat` and `dashscope_text_embedding` model wrapper, with `qwen-max` and `text-embedding-v2` models. | |||
However, you are welcome to replace the Dashscope language and embedding model wrappers or models with other models you like to test. | |||
|
|||
## Start AgentScope Consultants | |||
## Start AgentScope Copilots | |||
* **Terminal:** The most simple way to execute the AgentScope Consultants is running in terminal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copilot or copilots
@@ -23,35 +22,28 @@ capability can be used to build easily. | |||
**Note:** This example has been tested with `dashscope_chat` and `dashscope_text_embedding` model wrapper, with `qwen-max` and `text-embedding-v2` models. | |||
However, you are welcome to replace the Dashscope language and embedding model wrappers or models with other models you like to test. | |||
|
|||
## Start AgentScope Consultants | |||
## Start AgentScope Copilots | |||
* **Terminal:** The most simple way to execute the AgentScope Consultants is running in terminal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consultants or copilot
|
||
### RAG 智能体 | ||
RAG 智能体是可以基于检索到的知识生成答案的智能体。 | ||
* 让智能体使用RAG: RAG agent在其配置中需要`rag_config`,其中有一个`knowledge_id`的列表 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What parameters should be contained in this rag_config? It remains unknown for users in this tutorial.
```json | ||
[ | ||
{ | ||
"knowledge_id": "{your_knowledge_id}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use a config to setup the rag module, do we consider to add a config file to explain what's the usage of each parameters? Just like this file in FederatedScope
https://github.com/alibaba/FederatedScope/blob/master/federatedscope/core/configs/config.py#L258
"description": "Code-Search-Assistant is an agent that can provide answer based on AgentScope code base. It can answer questions about specific modules in AgentScope.", | ||
"sys_prompt": "You're a coding assistant of AgentScope. The answer starts with appreciation for the question, then provide details regarding the functionality and features of the modules mentioned in the question. The language should be in a professional and simple style. The answer is limited to be less than 100 words.", | ||
"model_config_name": "qwen_config", | ||
"rag_config": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this pre-processing outside the agent? For example (taking get
as example):
knowledge_bank = KnowledgeBank(...)
knowledges = knowledge_bank.get(knowledge_ids=["kb1", "kb2"], similarity_top_k=5, log_retrieval=5, recent_n_mem=1)
AgentClass(name="assistant", knowledges=knowledges, ...)
or user can setup their own knowledge within the agent object's constructor by themselves.
There are two advantages:
- No need to know what parameters should be written in a rag config. All parameters are in the declaration of this
get()
function, which can be accessed easily. - The agent is not required to have a rag config attribute.
Description
Updates
Changes on code structure
llama-index
asrag_requires
insetup.py
Changes on the RAG agent module
KnowledgeBank
featureKnowledgeBank
membersChanges on the RAG/knowledge module
Improving utility of knowledge module
KnowledgeBank
KnowledgeBank
:KnowledgeBank
provides an easier way to initialize a knowledge object, just calladd_data_as_knowledge
withknowledge_id
(a string as the identifier for this knowledge object),emb_model_name
(the name of the embedding model config) anddata_dirs_and_types
(a dictionary of data directories and the wanted file extensions). As shown in therag_example.py
KnowledgeBank
can be shared and duplicated by multiple agents, which can avoid embedding duplicated documents."knowledge_id"
inknowledge_config.json
) with associated retrievers to perform multi-source information retrieval. Just need to pass the agent intoKnowledgeBank.equip
function.Toturial
Both English and Chinese tutorial are added as 209-rag.md .
Checklist
Please check the following items before code is ready to be reviewed.