> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# HuggingFace 中心集成

> 使用 LangChain Python 与 HuggingFace 中心工具集成。

> [Huggingface 工具](https://huggingface.co/docs/transformers/v4.29.0/en/custom_tools)（支持文本 I/O）可以直接使用 `load_huggingface_tool` 函数加载。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
# 需要 transformers>=4.29.0 和 huggingface_hub>=0.14.1
pip install -qU  transformers huggingface_hub > /dev/null
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
pip install -qU  langchain-community
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_community.agent_toolkits.load_tools import load_huggingface_tool

tool = load_huggingface_tool("lysandre/hf-model-downloads")

print(f"{tool.name}: {tool.description}")
```

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
model_download_counter: 这是一个返回 Hugging Face 中心上给定任务下载量最多模型的工具。它接受类别名称（例如 text-classification、depth-estimation 等），并返回检查点的名称
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
tool.run("text-classification")
```

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
'facebook/bart-large-mnli'
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/tools/huggingface_tools.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
