Skip to content

Commit

Permalink
Support the chinese towhee model
Browse files Browse the repository at this point in the history
Signed-off-by: SimFG <[email protected]>
  • Loading branch information
SimFG committed Mar 31, 2023
1 parent 8247852 commit af09add
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
16 changes: 4 additions & 12 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

为了解决这个问题,我们开发了GPT Cache,这是一个专注于缓存语言模型响应的项目,也称为语义缓存。该系统提供了两个主要的好处:

快速响应用户请求:缓存系统提供比大型模型推理更快的响应时间,从而降低延迟并更快地响应用户请求。
降低服务成本:目前大多数ChatGPT服务是基于请求数量收费的。如果用户请求命中缓存,它可以减少请求数量并降低服务成本。
1. 快速响应用户请求:缓存系统提供比大型模型推理更快的响应时间,从而降低延迟并更快地响应用户请求。
2. 降低服务成本:目前大多数ChatGPT服务是基于请求数量收费的。如果用户请求命中缓存,它可以减少请求数量并降低服务成本。

如果这个想法💡对你很有帮助,帮忙给个star 🌟,甚是感谢!

## 🤔 GPT缓存为什么会有帮助?

我认为以下原因是必要的
我认为是有必要,原因是

- 局部性无处不在。像传统的应用系统一样,AIGC应用程序也面临类似的热点问题。例如,ChatGPT本身可能是程序员们热议的话题。
- 面向特定领域的SaaS服务,用户往往在特定的领域内提出问题,具有时间和空间上的局部性。
Expand All @@ -26,7 +26,7 @@
## 😊 快速接入

注:
- 可以通过下面指令快速体验这个缓存,值得注意的是或许这不是很稳定。
- 可以通过下面指令快速体验这个缓存,值得注意的是目前项目正在开发,API可能存在变更
- 默认情况下,基本上不需要安装什么第三方库。当需要使用一些特性的时候,相关的第三方库会自动下载。
- 如果因为pip版本低安装第三方库失败,使用:`python -m pip install --upgrade pip`

Expand Down Expand Up @@ -82,14 +82,6 @@ answer = openai.ChatCompletion.create(
- [功能,当前支持的所有特性](doc/feature_cn.md)
- [案例,更加了解如何定制化缓存](example/example.md)

## 🤔 是否有必要使用缓存?

我认为有必要,理由如下:

- 基于ChatGPT开发的某些领域服务,许多问答具有一定的相似性。
- 对于一个用户,使用ChatGPT提出的一系列问题具有一定规律性,与其职业、生活习惯、性格等有一定关联。例如,程序员使用ChatGPT服务的可能性很大程度上与其工作有关。
- 如果您提供的ChatGPT服务面向大量用户群体,将其分为不同的类别,那么相同类别中的用户问的相关问题也有很大概率命中缓存,从而降低服务成本。

## 🤗 所有模块

![GPTCache Struct](doc/GPTCacheStructure.png)
Expand Down
3 changes: 3 additions & 0 deletions example/sqlite_faiss_towhee/sqlite_faiss_towhee.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

def run():
towhee = Towhee()
# chinese model
# towhee = Towhee(model="uer/albert-base-chinese-cluecorpussmall")

sqlite_file = "sqlite.db"
faiss_file = "faiss.index"
has_data = os.path.isfile(sqlite_file) and os.path.isfile(faiss_file)
Expand Down
4 changes: 2 additions & 2 deletions gpt_cache/embedding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
towhee = LazyImport('towhee', globals(), 'gpt_cache.embedding.towhee')


def Towhee():
return towhee.Towhee()
def Towhee(model="paraphrase-albert-small-v2"):
return towhee.Towhee(model)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def parse_requirements(file_name: str) -> List[str]:
setuptools.setup(
name="gpt_cache",
packages=find_packages(),
version="0.1.0",
version="0.1.1",
author="SimFG",
author_email="[email protected]",
description="GPT Cache, make your chatgpt services lower cost and faster",
Expand Down

0 comments on commit af09add

Please sign in to comment.