-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95056c0
commit 535e847
Showing
2 changed files
with
135 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# LLMs | ||
## Inference | ||
|
||
`superduperdb` allows users to work with LLM services and models | ||
|
||
以下是支持的LLM服务/模型列表 | ||
|
||
- vLLM | ||
- OpenAI格式的API服务 | ||
|
||
|
||
|
||
### vLLM | ||
|
||
[vLLM](https://docs.vllm.ai/en/latest/) is a fast and easy-to-use library for LLM inference and serving. | ||
|
||
目前`superduperdb`支持以下方式来使用vLLM | ||
|
||
- **VllmModel**: 使用vLLM加载模型 | ||
|
||
- **VllmOpenAI**: 请求已部署[OpenAI格式的vLLM服务](https://docs.vllm.ai/en/latest/getting_started/quickstart.html#openai-compatible-server) | ||
- **VllmAPI**: 请求已部署[API server格式的服务](https://docs.vllm.ai/en/latest/getting_started/quickstart.html#api-server) | ||
|
||
#### VllmModel | ||
|
||
`VllmModel` 支持将模型加载到本地或者Ray集群。 | ||
|
||
使用 `model = VllmModel(....) ` 实例化后,模型会延迟加载,直到调用`model.predict`方法,模型才开始加载 | ||
|
||
**加载到本地** | ||
|
||
使用该模型先安装`vllm` | ||
|
||
```bash | ||
pip install vllm | ||
``` | ||
|
||
```python | ||
from superduperdb.ext.llm import VllmModel | ||
model = VllmModel(model_name="mistralai/Mistral-7B-Instruct-v0.2") | ||
``` | ||
|
||
**加载到Ray集群** | ||
|
||
需要先安装`ray`,如果加载到Ray集群是无需安装`vllm`依赖的。 | ||
|
||
> 安装`vllm`需要Cuda 环境,对于无GPU的客户端,这将导致无法安装vllm。因此,superduper做了适配,如果加载到ray集群,则本地无需安装`vllm` | ||
```bash | ||
pip install 'ray[default]' | ||
``` | ||
|
||
```python | ||
from superduperdb.ext.llm import VllmModel | ||
model = VllmModel(model_name="mistralai/Mistral-7B-Instruct-v0.2", ray_address="ray://172.31.29.75:10001") | ||
``` | ||
|
||
如果你是第一次在该ray集群上运行,等待时间会稍长,因为会在ray集群的服务器上安装`vllm` 和下载对应的模型。 | ||
|
||
|
||
|
||
#### VllmOpenAI | ||
|
||
```python | ||
from superduperdb.ext.llm import VllmOpenAI | ||
model = VllmOpenAI(openai_api_base="http://localhost:8000/v1", model_name="mistralai/Mistral-7B-Instruct-v0.2") | ||
``` | ||
|
||
|
||
|
||
#### VllmAPI | ||
|
||
初始化模型 | ||
|
||
```python | ||
from superduperdb.ext.llm import VllmAPI | ||
model = VllmAPI(identifier='llm', api_url='http://localhost:8000/v1') | ||
``` | ||
|
||
|
||
|
||
### OpenAI | ||
|
||
`superduperdb` 支持OpenAI格式的API服务,若不提供`openai_api_base` 等参数,默认调用OpenAI的服务。 | ||
|
||
初始化模型 | ||
|
||
```python | ||
from superduperdb.ext.llm import OpenAI | ||
model = OpenAI(openai_api_base="http://localhost:8000/v1", model_name="mistralai/Mistral-7B-Instruct-v0.2") | ||
``` | ||
|
||
|
||
|
||
## Training | ||
|
||
Coming soon... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters