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

安装和设置

LLMs

有一个 DeepSparse LLM 封装器,你可以通过以下方式访问它
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)

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.