Skip to content

Commit c9fd8e7

Browse files
authored
update readme (#2307)
1 parent 4779164 commit c9fd8e7

File tree

1 file changed

+96
-82
lines changed

1 file changed

+96
-82
lines changed

README.md

Lines changed: 96 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# <center> MindNLP
1+
# <center> MindHF
22

33
<p align="center">
4-
<a href="https://mindnlp.cqu.ai/en/latest/">
4+
<a href="https://mindhf.cqu.ai/en/latest/">
55
<img alt="docs" src="https://img.shields.io/badge/docs-latest-blue">
66
</a>
77
<a href="https://github.com/mindspore-lab/mindnlp/blob/master/LICENSE">
@@ -18,11 +18,15 @@
1818
</a>
1919
</p>
2020

21+
**MindHF** stands for **MindSpore + HuggingFace**, representing seamless compatibility with the HuggingFace ecosystem. The name also embodies **Harmonious & Fluid**, symbolizing our commitment to balancing compatibility with high performance. MindHF enables you to leverage the best of both worlds: the rich HuggingFace model ecosystem and MindSpore's powerful acceleration capabilities.
22+
23+
> **Note**: MindHF (formerly MindNLP) is the new name for this project. The `mindnlp` package name is still available for backward compatibility, but we recommend using `mindhf` going forward.
24+
2125
## Table of Contents
2226

23-
- [ MindNLP](#-mindnlp)
27+
- [ MindHF](#-mindhf)
2428
- [Table of Contents](#table-of-contents)
25-
- [News 📢](#news-)
29+
- [Features ✨](#features-)
2630
- [Installation](#installation)
2731
- [Install from Pypi](#install-from-pypi)
2832
- [Daily build](#daily-build)
@@ -37,98 +41,116 @@
3741
- [Acknowledgement](#acknowledgement)
3842
- [Citation](#citation)
3943

40-
## News 📢
44+
## Features ✨
45+
46+
### 1. 🤗 Full HuggingFace Compatibility
47+
48+
MindHF provides seamless compatibility with the HuggingFace ecosystem, enabling you to run any Transformers/Diffusers models on MindSpore across all hardware platforms (GPU/Ascend/CPU) without code modifications.
49+
50+
#### Direct HuggingFace Library Usage
51+
52+
You can directly use native HuggingFace libraries (transformers, diffusers, etc.) with MindSpore acceleration:
53+
54+
**For HuggingFace Transformers:**
55+
56+
```python
57+
import mindspore
58+
import mindhf
59+
from transformers import pipeline
60+
61+
chat = [
62+
{"role": "system", "content": "You are a sassy, wise-cracking robot as imagined by Hollywood circa 1986."},
63+
{"role": "user", "content": "Hey, can you tell me any fun things to do in New York?"}
64+
]
65+
66+
pipeline = pipeline(task="text-generation", model="Qwen/Qwen3-8B", ms_dtype=mindspore.bfloat16, device_map="auto")
67+
response = pipeline(chat, max_new_tokens=512)
68+
print(response[0]["generated_text"][-1]["content"])
69+
```
70+
71+
**For HuggingFace Diffusers:**
4172

42-
***MindNLP Core support Pytorch compatible:** To meet ecosystem compatibility requirements, we provide the `mindnlp.core` module to support compatibility with PyTorch interfaces. This module is built upon MindSpore's foundational APIs and operators, enabling model development using syntax similar to PyTorch. It also supports taking over torch interfaces through a Proxy, allowing the use of MindSpore for acceleration on Ascend hardware without the need for code modifications. The specific usage is as follows:
73+
```python
74+
import mindspore
75+
import mindhf
76+
from diffusers import DiffusionPipeline
4377

44-
```python
45-
import mindnlp # import mindnlp lib will enable proxy automaticlly
46-
import torch
47-
from torch import nn
78+
pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", ms_dtype=mindspore.float16, device_map='cuda')
79+
pipeline("An image of a squirrel in Picasso style").images[0]
80+
```
81+
82+
#### MindHF Native Interface
4883

49-
# all torch.xx apis will be mapped to mindnlp.core.xx
50-
net = nn.Linear(10, 5)
51-
x = torch.randn(3, 10)
52-
out = net(x)
53-
print(out.shape)
54-
# core.Size([3, 5])
55-
```
84+
You can also use MindHF's native interface for better integration:
5685

57-
It is particularly noteworthy that MindNLP supports several features not yet available in MindSpore, which enables better support for model serialization, heterogeneous computing, and other scenarios:
58-
1. ​Dispatch Mechanism Support: Operators are dispatched to the appropriate backend based on Tensor.device.
59-
2. ​Meta Device Support: Allows for shape inference without performing actual computations.
60-
3. ​Numpy as CPU Backend: Supports using NumPy as a CPU backend for acceleration.
61-
4. ​Tensor.to for Heterogeneous Data Movement: Facilitates the movement of data across different devices using `Tensor.to`.
86+
```python
87+
from mindhf.transformers import AutoTokenizer, AutoModel
6288

63-
* 🔥 **Fully compatible with 🤗HuggingFace:** It enables seamless execution of any Transformers/Diffusers models on MindSpore across all hardware platforms (GPU/Ascend/CPU).
64-
65-
You may still invoke models through MindNLP as shown in the example code below:
89+
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
90+
model = AutoModel.from_pretrained("bert-base-uncased")
6691

67-
```python
68-
from mindnlp.transformers import AutoTokenizer, AutoModel
92+
inputs = tokenizer("Hello world!", return_tensors='ms')
93+
outputs = model(**inputs)
94+
```
6995

70-
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
71-
model = AutoModel.from_pretrained("bert-base-uncased")
96+
> **Note**: Due to differences in autograd and parallel execution mechanisms, any training or distributed execution code must utilize the interfaces provided by MindHF.
7297
73-
inputs = tokenizer("Hello world!", return_tensors='ms')
74-
outputs = model(**inputs)
75-
```
98+
### 2. ⚡ High-Performance Features Powered by MindSpore
7699

77-
You can also directly use the native HuggingFace library(like transformers, diffusers, etc.) via the following approach as demonstrated in the example code:
100+
MindHF leverages MindSpore's powerful capabilities to deliver exceptional performance and unique features:
78101

79-
- For huggingface transformers:
102+
#### PyTorch-Compatible API with MindSpore Acceleration
80103

81-
```python
82-
import mindspore
83-
import mindnlp
84-
from transformers import pipeline
104+
MindHF provides `mindtorch` (accessible via `mindhf.core`) for PyTorch-compatible interfaces, enabling seamless migration from PyTorch code while benefiting from MindSpore's acceleration on Ascend hardware:
85105

86-
chat = [
87-
{"role": "system", "content": "You are a sassy, wise-cracking robot as imagined by Hollywood circa 1986."},
88-
{"role": "user", "content": "Hey, can you tell me any fun things to do in New York?"}
89-
]
106+
```python
107+
import mindhf # Automatically enables proxy for torch APIs
108+
import torch
109+
from torch import nn
90110

91-
pipeline = pipeline(task="text-generation", model="Qwen/Qwen3-8B", ms_dtype=mindspore.bfloat16, device_map="auto")
92-
response = pipeline(chat, max_new_tokens=512)
93-
print(response[0]["generated_text"][-1]["content"])
94-
```
111+
# All torch.xx APIs are automatically mapped to mindhf.core.xx (via mindtorch)
112+
net = nn.Linear(10, 5)
113+
x = torch.randn(3, 10)
114+
out = net(x)
115+
print(out.shape) # core.Size([3, 5])
116+
```
95117

96-
- For huggingface diffuers:
118+
#### Advanced Features Beyond Standard MindSpore
97119

98-
```python
99-
import mindspore
100-
import mindnlp
101-
from diffusers import DiffusionPipeline
120+
MindHF extends MindSpore with several advanced features for better model development:
102121

103-
pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", ms_dtype=mindspore.float16, device_map='cuda')
104-
pipeline("An image of a squirrel in Picasso style").images[0]
105-
```
122+
1. **Dispatch Mechanism**: Operators are automatically dispatched to the appropriate backend based on `Tensor.device`, enabling seamless multi-device execution.
123+
2. **Meta Device Support**: Perform shape inference and memory planning without actual computations, significantly speeding up model development and debugging.
124+
3. **NumPy as CPU Backend**: Use NumPy as a CPU backend for acceleration, providing better compatibility and performance on CPU devices.
125+
4. **Heterogeneous Data Movement**: Enhanced `Tensor.to()` for efficient data movement across different devices (CPU/GPU/Ascend).
106126

107-
Notice ⚠️: Due to differences in autograd and parallel execution mechanisms, any training or distributed execution code must utilize the interfaces provided by MindNLP.
127+
These features enable better support for model serialization, heterogeneous computing, and complex deployment scenarios.
108128

109129
## Installation
110130

111131
#### Install from Pypi
112132

113-
You can install the official version of MindNLP which is uploaded to pypi.
133+
You can install the official version of MindHF which is uploaded to pypi.
114134

115135
```bash
116-
pip install mindnlp
136+
pip install mindhf
117137
```
118138

139+
> **Note**: The `mindnlp` package name is still available for backward compatibility, but we recommend using `mindhf` going forward.
140+
119141
#### Daily build
120142

121-
You can download MindNLP daily wheel from [here](https://repo.mindspore.cn/mindspore-lab/mindnlp/newest/any/).
143+
You can download MindHF daily wheel from [here](https://repo.mindspore.cn/mindspore-lab/mindhf/newest/any/).
122144

123145
#### Install from source
124146

125-
To install MindNLP from source, please run:
147+
To install MindHF from source, please run:
126148

127149
```bash
128-
pip install git+https://github.com/mindspore-lab/mindnlp.git
150+
pip install git+https://github.com/mindspore-lab/mindhf.git
129151
# or
130-
git clone https://github.com/mindspore-lab/mindnlp.git
131-
cd mindnlp
152+
git clone https://github.com/mindspore-lab/mindhf.git
153+
cd mindhf
132154
bash scripts/build_and_reinstall.sh
133155
```
134156

@@ -141,25 +163,16 @@ bash scripts/build_and_reinstall.sh
141163
| 0.2.x | >=2.1.0 | >=3.8, <=3.9 |
142164
| 0.3.x | >=2.1.0, <=2.3.1 | >=3.8, <=3.9 |
143165
| 0.4.x | >=2.2.x, <=2.5.0 | >=3.9, <=3.11 |
144-
| 0.5.0 | >=2.5.0, <=2.7.0 | >=3.10, <=3.11 |
145-
| 0.6.x | >=2.7.1. | >=3.10, <=3.11 |
166+
| 0.5.x | >=2.5.0, <=2.7.0 | >=3.10, <=3.11 |
146167

147-
## Introduction
148-
149-
MindNLP is an open source NLP library based on MindSpore. It supports a platform for solving natural language processing tasks, containing many common approaches in NLP. It can help researchers and developers to construct and train models more conveniently and rapidly.
150-
151-
The master branch works with **MindSpore master**.
152-
153-
#### Major Features
154-
155-
- **Comprehensive data processing**: Several classical NLP datasets are packaged into friendly module for easy use, such as Multi30k, SQuAD, CoNLL, etc.
156-
- **Friendly NLP model toolset**: MindNLP provides various configurable components. It is friendly to customize models using MindNLP.
157-
- **Easy-to-use engine**: MindNLP simplified the complicated training process in MindSpore. It supports Trainer and Evaluator interfaces to train and evaluate models easily.
168+
| MindHF version | MindSpore version | Supported Python version |
169+
|-----------------|-------------------|--------------------------|
170+
| 0.6.x | >=2.7.1. | >=3.10, <=3.11 |
158171

159172

160173
## Supported models
161174

162-
Since there are too many supported models, please check [here](https://mindnlp.cqu.ai/supported_models)
175+
Since there are too many supported models, please check [here](https://mindhf.cqu.ai/supported_models)
163176

164177
<!-- ## Tutorials
165178
@@ -178,7 +191,7 @@ The dynamic version is still under development, if you find any issue or have an
178191

179192
## MindSpore NLP SIG
180193

181-
MindSpore NLP SIG (Natural Language Processing Special Interest Group) is the main development team of the MindNLP framework. It aims to collaborate with developers from both industry and academia who are interested in research, application development, and the practical implementation of natural language processing. Our goal is to create the best NLP framework based on the domestic framework MindSpore. Additionally, we regularly hold NLP technology sharing sessions and offline events. Interested developers can join our SIG group using the QR code below.
194+
MindSpore NLP SIG (Natural Language Processing Special Interest Group) is the main development team of the MindHF framework. It aims to collaborate with developers from both industry and academia who are interested in research, application development, and the practical implementation of natural language processing. Our goal is to create the best NLP framework based on the domestic framework MindSpore. Additionally, we regularly hold NLP technology sharing sessions and offline events. Interested developers can join our SIG group using the QR code below.
182195

183196
<div align="center">
184197
<img src="./assets/qrcode_qq_group.jpg" width="250" />
@@ -197,10 +210,11 @@ and develop their own new semantic segmentation methods.
197210
If you find this project useful in your research, please consider citing:
198211

199212
```latex
200-
@misc{mindnlp2022,
201-
title={{MindNLP}: Easy-to-use and high-performance NLP and LLM framework based on MindSpore},
202-
author={MindNLP Contributors},
203-
howpublished = {\url{https://github.com/mindlab-ai/mindnlp}},
204-
year={2022}
213+
@misc{mindhf2022,
214+
title={{MindHF}: Easy-to-use and high-performance NLP and LLM framework based on MindSpore},
215+
author={MindHF Contributors},
216+
howpublished = {\url{https://github.com/mindspore-lab/mindnlp}},
217+
year={2022},
218+
note={Formerly known as MindNLP}
205219
}
206220
```

0 commit comments

Comments
 (0)