Skip to main content
Open on GitHub

DeepSparse

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

安装与设置

  • 使用 pip install deepsparse 安装 Python 包
  • 选择一个 SparseZoo 模型,或使用 Optimum 导出支持模型为 ONNX 格式

大型语言模型

存在一个 DeepSparse LLM 包装器,您可以通过以下方式访问:

from langchain_community.llms import DeepSparse
API 参考:DeepSparse

它为所有模型提供统一的接口:

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

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

Additional parameters can be passed using the config parameter:

config = {'max_generated_tokens': 256}

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