Skip to content

Commit

Permalink
Merge pull request #158 from LuShanYanYu7/main
Browse files Browse the repository at this point in the history
add hf
  • Loading branch information
yangj1211 authored Nov 14, 2024
2 parents 3d92051 + 24288c2 commit 5abed2f
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/AcademicResource/huggingface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 2
title: HuggingFace Mirror
sidebar_label: HuggingFace Mirror
---

**NOTE:** This proxy acceleration service aims to alleviate network speed issues encountered in academic usage scenarios when accessing Hugging Face, making it easier for users to obtain related resources. Please be aware that this service does not offer stability guarantees and may be terminated at any time in case of malicious attacks or other disruptions.

**Service URL:** [https://hf-mirror.com/](https://hf-mirror.com/)

Below is an example of how to download the `bert-base-uncased` model on Hugging Face:

- Set up environment variables

```bash
export HF_ENDPOINT=https://hf-mirror.com
```

- Install the transformers library

```bash
pip install transformers
```

- Download the Hugging Face model

Write and run the following Python code:

```python
from transformers import AutoModel, AutoTokenizer

# Download BERT model and tokenizer
model_name = "bert-base-uncased"
model = AutoModel.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

print("BERT model downloaded successfully!")
```

<img src={require('../../static/img/accerate/acc-1.png').default} alt="创建集群" style={{width: '700px', height: 'auto'}} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 2
title: HuggingFace 镜像站
sidebar_label: HuggingFace 镜像站
---

**NOTE:** 本加速代理服务旨在缓解学术用途中访问 Hugging Face 时遇到的网络速度问题,方便用户获取相关资源。请注意,本服务不提供稳定性保障,且在遭遇恶意攻击等情况下,可能会随时中止服务。

**服务地址**[https://hf-mirror.com/](https://hf-mirror.com/)

以下是如何在 Hugging Face 上下载 `bert-base-uncased` 模型的示例:

- 配置环境变量

```bash
export HF_ENDPOINT=https://hf-mirror.com
```

- 安装 transformers 库

```bash
pip install transformers
```

- 下载 Hugging Face 模型

编写 python 代码并运行:

```python
from transformers import AutoModel, AutoTokenizer

# 下载 BERT 模型和分词器
model_name = "bert-base-uncased"
model = AutoModel.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

print("BERT 模型下载完成!")
```

<img src={require('../../../../../static/img/accerate/acc-1.png').default} alt="创建集群" style={{width: '700px', height: 'auto'}} />

0 comments on commit 5abed2f

Please sign in to comment.