Utils¶
MindNLP utilities module provides common helper functions and utilities.
Overview¶
The utils module contains:
- Generic utilities: Common helper functions
- Import utilities: Dynamic import helpers for checking library availability
Usage¶
from mindnlp.utils import is_mindspore_available
if is_mindspore_available():
import mindspore
Import Utilities¶
The import utilities help check for optional dependencies:
is_mindspore_available()- Check if MindSpore is installedis_torch_available()- Check if PyTorch is installed (for compatibility)
Constants¶
DUMMY_INPUTS- Example input IDs for testingDUMMY_MASK- Example attention masks for testingSENTENCEPIECE_UNDERLINE- The sentencepiece underscore character