跳到主要内容

用 Langchain 起服务

vLLM 也支持 Langchain 。

安装 langchain, 运行

pip install langchain langchain_community -q

在单个或多个GPU上运行推理, 使用langchain中的VLLM

from langchain_community.llms import VLLM

llm = VLLM(model="mosaicml/mpt-7b",
trust_remote_code=True, # mandatory for hf models
max_new_tokens=128,
top_k=10,
top_p=0.95,
temperature=0.8,
# tensor_parallel_size=... # for distributed inference
)

print(llm("What is the capital of France ?"))

更多资料请参考 https://python.langchain.com/docs/integrations/llms/vllm