You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+104-47
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,3 @@
1
-
**Important Notice**:
2
-
3
-
- This repository has been archived.
4
-
Please visit [akcio2023/akcio](https://github.com/akcio2023/akcio) for updates after June 14, 2023.
5
-
- To get invitation for the new repository, please send email to [jaelgu]([email protected]).
6
-
7
-
---
8
-
9
1
# Akcio: Enhancing LLM-Powered ChatBot with CVP Stack
10
2
11
3
[OSSChat](https://osschat.io) |
@@ -24,34 +16,77 @@ ChatGPT has constraints due to its limited knowledge base, sometimes resulting i
24
16
25
17
We have built [OSSChat](https://osschat.io) as a working demonstration of the CVP stack. Now we are presenting the technology behind OSSChat in this repository with a code name of Akcio.
With this project, you are able to build a knowledge-enhanced ChatBot using LLM service like ChatGPT.
28
22
By the end, you will learn how to start a backend service using FastAPI, which provides standby APIs to support further applications. Alternatively, we show how to use Gradio to build an online demo with user interface.
29
23
30
24
## Overview
31
25
32
-
The system is built on top of LangChain Agent using vector database for semantic search and memory storage for context support.
33
-
You can find more details and instructions at our [documentation](https://github.com/zilliztech/akcio/wiki).
Akcio allows you to create a ChatGPT-like system with added intelligence obtained through semantic search of customized knowledge base.
29
+
Instead of sending the user query directly to LLM service, our system firstly retrieves relevant information from stores by semantic search or keyword match. Then it feeds both user needs and helpful information into LLM. This allows LLM to better tailor its response to the user's needs and provide more accurate and helpful information.
30
+
31
+
You can find more details and instructions at our [documentation](https://github.com/zilliztech/akcio/wiki).
38
32
39
-
-[Agent](./src/agent)
40
-
- ChatAgent: agent ensembles all modules together to build up qa system.
33
+
Akcio offers two AI platforms to choose from: [Towhee](https://towhee.io) or [LangChain](https://langchain.com).
34
+
It also supports different integrations of LLM service and databases:
The option using Towhee simplifies the process of building a system by providing [pre-defined pipelines](https://towhee.io/tasks/pipeline). These built-in pipelines require less coding and make system building much easier. If you require customization, you can either simply modify configuration or create your own pipeline with rich options of [Towhee Operators](https://towhee.io/tasks/operator).
60
+
61
+
-[Pipelines](./towhee_src/pipelines)
62
+
-**Insert:**
63
+
The insert pipeline builds a knowledge base by saving documents and corresponding data in database(s).
64
+
-**Search:**
65
+
The search pipeline enables the question-answering capability powered by information retrieval (semantic search and optional keyword match) and LLM service.
66
+
-**Prompt:** a prompt operator prepares messages for LLM by assembling system message, chat history, and the user's query processed by template.
67
+
68
+
-[Memory](./towhee_src/memory):
69
+
The memory storage stores chat history to support context in conversation. (available: [most SQL](./towhee_src/memory/sql.py))
70
+
71
+
72
+
### Option 2: LangChain
73
+
74
+
The option using LangChain employs the use of [Agent](https://python.langchain.com/docs/modules/agents) in order to enable LLM to utilize specific tools, resulting in a greater demand for LLM's ability to comprehend tasks and make informed decisions.
75
+
76
+
-[Agent](./langchain_src/agent)
77
+
-**ChatAgent:** agent ensembles all modules together to build up qa system.
41
78
- Other agents (todo)
42
-
-[LLM](./src/llm)
43
-
- ChatLLM: large language model or service to generate answers (available: [OpenAI](src/llm/openai_chat.py), [Dolly](src/llm/dolly_chat.py))
44
-
-[Embedding](./src/embedding/)
45
-
- TextEncoder: encoder converts each text input to a vector (available: [OpenAI embedding](src/embedding/openai_embedding.py), [HuggingFace Hub](src/embedding/langchain_huggingface.py))
79
+
-[LLM](./langchain_src/llm)
80
+
-**ChatLLM:** large language model or service to generate answers.
81
+
-[Embedding](./langchain_src/embedding/)
82
+
-**TextEncoder:** encoder converts each text input to a vector.
46
83
- Other encoders (todo)
47
-
-[Store](./src/store)
48
-
- VectorStore: vector database stores document chunks in embeddings, and performs document retrieval via semantic search. (available: [Milvus/Zilliz Cloud](src/store/vector_store/milvus.py))
49
-
- ScalarStore: optional, database stores metadata for each document chunk, which supports additional information retrieval. (available: [Elastic](src/store/scalar_store/es.py))
50
-
- MemoryStore: memory storage stores chat history to support context in conversation. (available: [Postgresql](src/store/memory_store/pg.py))
51
-
- Other stores (todo)
52
-
-[DataLoader](./src/data_loader/)
53
-
- DataParser: tool loads data from given source and then splits documents into processed doc chunks.
54
-
- QuestionGenerator: tool generates a list of potential questions for each document chunk.
84
+
-[Store](./langchain_src/store)
85
+
-**VectorStore:** vector database stores document chunks in embeddings, and performs document retrieval via semantic search.
86
+
-**ScalarStore:** optional, database stores metadata for each document chunk, which supports additional information retrieval. (available: [Elastic](langchain_src/store/scalar_store/es.py))
87
+
-**MemoryStore:** memory storage stores chat history to support context in conversation.
88
+
-[DataLoader](./langchain_src/data_loader/)
89
+
-**DataParser:** tool loads data from given source and then splits documents into processed doc chunks.
55
90
56
91
## Deployment
57
92
@@ -63,56 +98,77 @@ You can find more details and instructions at our [documentation](https://github
63
98
64
99
2. Install dependencies
65
100
```shell
66
-
$ pip -r requirements.txt
101
+
$ pip install -r requirements.txt
67
102
```
68
103
69
104
3. Configure modules
70
-
- Agent
71
105
72
-
It will use default agents and prompts.
73
-
If you want to configure prompts or customize agent modules, refer to [agent](./src/agent) for guide.
106
+
You can configure all arguments by modifying [config.py](./config.py) to set up your system with default modules.
74
107
75
108
- LLM
76
109
77
-
The default ChatAI module uses OpenAI service, which requires an [OpenAI API key](https://platform.openai.com/account/api-keys).
110
+
By default, the system will use OpenAI service as the LLM option.
111
+
To set your OpenAI API key without modifying the configuration file, you can pass it as environment variable.
78
112
79
113
```shell
80
114
$ export OPENAI_API_KEY=your_keys_here
81
115
```
82
116
83
-
If you want to customize llm modules, you can refer to [llm](./src/llm) for guide.
117
+
<details>
118
+
119
+
<summary> Check how to <strong>SWITCH LLM</strong>. </summary>
120
+
If you want to use another supported LLM service, you can change the LLM option and set up for it.
121
+
Besides directly modifying the configuration file, you can also set up via environment variables.
122
+
For example, to use Ernie instead of OpenAI, you need to change the option and set up Ernie API key & secret key:
123
+
124
+
```shell
125
+
$ export LLM_OPTION=ernie
126
+
$ export ERNIE_API_KEY=your_ernie_api_key
127
+
$ export ERNIE_SECRET_KEY=your_ernie_secret_key
128
+
```
129
+
</details>
84
130
85
131
- Embedding
86
132
87
-
By default, the embedding module uses LangChain HuggingFaceEmbeddings to convert text inputs to vectors. Here are some information about the default embedding method:
133
+
By default, the embedding module uses methods from [Sentence Transformers](https://www.sbert.net/) to convert text inputs to vectors. Here are some information about the default embedding method:
If you want to customize embedding method, you can refer to [embedding](./src/embedding) for guide.
93
-
94
138
- Store
95
139
140
+
Before getting started, all database services used for store must be running and be configured with write and create access.
141
+
96
142
- Vector Store: You need to prepare the service of vector database in advance. For example, you can refer to [Milvus Documents](https://milvus.io/docs) or [Zilliz Cloud](https://zilliz.com/doc/quick_start) to learn about how to start a Milvus service.
97
-
- Scalar Store (Optional): This is optional, only work when `USE_SCALAR` is truein [configuration](./src/store/config.py). If this is enabled (i.e. USE_SCALAR=True), the default scalar store will use [Elastic](https://www.elastic.co/). In this case, you need to prepare the Elasticsearch service in advance.
98
-
- Memory Store: You need to prepare the database for memory storage as well. By default, the memory store uses [Postgresql](https://www.postgresqltutorial.com) which requires installation.
143
+
- Scalar Store (Optional): This is optional, only work when `USE_SCALAR` is truein [configuration](config.py). If this is enabled (i.e. USE_SCALAR=True), the default scalar store will use [Elastic](https://www.elastic.co/). In this case, you need to prepare the Elasticsearch service in advance.
144
+
- Memory Store: You need to prepare the database for memory storage as well. By default, LangChain mode supports [Postgresql](https://www.postgresql.org/) and Towhee mode allows interaction with any database supported by [SQLAlchemy 2.0](https://docs.sqlalchemy.org/en/20/dialects/).
99
145
100
-
The store will use [default store configs](./src/store/config.py).
101
-
You can modify the the [config file](./src/store/config.py).
102
-
To set up your special connections for each database, you can also export environment variables instead of modifying:
146
+
The system will use default store configs.
147
+
To set up your special connections for each database, you can also export environment variables instead of modifying the configuration file.
0 commit comments