这篇文章我会记录使用 MindNLP 仓库的一些需要记录、防止遗忘的东西
MindNLP is an open source NLP library based on MindSpore,
Prerequisites
- create a conda env
- pip install mindspore from mindspore website. (一定要cudnn)
- cd mindnlp && pip install -e .
Check by python -c "import mindspore;mindspore.run_check()"
First Model[^first-model]
what i learned?
- Mindnlp 的 dataset 机制
- 定义 Register 类
- 定义 load_dataset 和 process 作为 Register 类的对象
- 在所有新的数据集类前 加入 @load_dataset.register warp一下
- 同样的,@process.register 来 warp dataset process
- 我们通过
imdb_train = process('imdb', imdb_train, tokenizer=tokenizer, vocab=vocab, ...)来使用 imdb 类的数据 - imdb 数据集的路径为
mindnlp/mindnlp/dataset/text_classification/imdb.py,其中包括了数据集和Process类
- Tokenizer 类都在
mindnlp/mindnlp/transforms/tokenizers中,没有仔细看
refs
[^first-model] https://github.com/cjl99/mindnlp/tree/master#get-started