Skip to main content

DeepSparse

本页面介绍如何在LangChain中使用DeepSparse推理运行时。 内容分为两部分:安装和设置,以及DeepSparse使用示例。

安装和设置

存在一个DeepSparse LLM包装器,提供所有模型的统一接口:

<!--IMPORTS:[{"imported": "DeepSparse", "source": "langchain_community.llms", "docs": "https://python.langchain.com/api_reference/community/llms/langchain_community.llms.deepsparse.DeepSparse.html", "title": "DeepSparse"}]-->
from langchain_community.llms import DeepSparse

llm = DeepSparse(
model="zoo:nlg/text_generation/codegen_mono-350m/pytorch/huggingface/bigpython_bigquery_thepile/base-none"
)

print(llm.invoke("def fib():"))

可以使用 config 参数传递附加参数:

config = {"max_generated_tokens": 256}

llm = DeepSparse(
model="zoo:nlg/text_generation/codegen_mono-350m/pytorch/huggingface/bigpython_bigquery_thepile/base-none",
config=config,
)

相关


Was this page helpful?


You can also leave detailed feedback on GitHub.

扫我,入群扫我,找书