micm_nlp.enums¶
Every categorical choice the configuration layer recognises.
String enums, so a YAML value compares equal to its member without conversion:
config.mode == ModeSE.FINETUNE works on the raw string 'finetune'.
Roughly three families live here — pipeline vocabulary (ModeSE, DeviceSE),
dataset and task vocabulary (DsCatSE, DsTypeSE, DsSplitSE, TaskCatSE,
TaskNameSE, EvalTypeSE), and per-architecture special-token tables
(BertTokenSE, RobertaTokenSE, XLMRobertaTokenSE, T5TokenSE, …) that
the tokenizer factory consults when adding special tokens and post-processors.
Note model.architecture is deliberately not validated against ModelArchSE:
it is a free-form string used for run-directory naming.
Classes¶
BERT's special tokens. |
|
Where a run executes. |
|
Top level of the |
|
Dataset split names. |
|
How far a dataset has been processed, and which variant is on disk -- |
|
How a dataset is loaded. |
|
ELECTRA's special tokens -- identical to BERT's. |
|
What kind of |
|
What a run does: train from scratch, finetune a checkpoint, evaluate, |
|
Architecture families the tokenizer factory knows how to dress -- it |
|
Where a pretrained model or tokenizer comes from: the Hub, or a local path. |
|
RoBERTa's special tokens. |
|
On-disk format when writing a dataset: CSV, or HuggingFace's own |
|
Sentence splitter to use. |
|
Stand-in for |
|
T5's special tokens. |
|
Task family, which decides the head and the loss. |
|
The concrete task: masked and permutation language modelling, sentiment |
|
Training algorithm for a SentencePiece tokenizer: BPE or unigram. |
|
Subword algorithm to train or load. |
|
Word tokenizer to use when a step needs words rather than subwords -- |
|
XLM-R's special tokens -- identical to RoBERTa's. |
|
XLNet's special tokens, including the end-of-paragraph and |
Module Contents¶
- class micm_nlp.enums.BertTokenSE¶
Bases:
enum.StrEnumBERT’s special tokens.
One member per role, so the tokenizer factory can ask any of these tables for
BOS/EOS/PAD/… without knowing which architecture it is holding.additional()returns the tokens beyond that common set.Initialize self. See help(type(self)) for accurate signature.
- classmethod additional()¶
Special tokens beyond the common BOS/EOS/SEP/CLS/PAD/UNK/MASK set.
- BOS = '[CLS]'¶
- CLS = '[CLS]'¶
- EOS = '[SEP]'¶
- MASK = '[MASK]'¶
- PAD = '[PAD]'¶
- SEP = '[SEP]'¶
- UNK = '[UNK]'¶
- class micm_nlp.enums.DeviceSE¶
Bases:
enum.StrEnumWhere a run executes.
GPUandCUDAare both accepted spellings.Initialize self. See help(type(self)) for accurate signature.
- CPU = 'cpu'¶
- CUDA = 'cuda'¶
- GPU = 'gpu'¶
- class micm_nlp.enums.DsCatSE¶
Bases:
enum.StrEnumTop level of the
artefacts/datasetstree: raw text, corpora, benchmarks, or collections.Initialize self. See help(type(self)) for accurate signature.
- BENCHMARKS = 'benchmarks'¶
- COLLECTIOS = 'collections'¶
- CORPORA = 'corpora'¶
- RAW = 'raw'¶
- class micm_nlp.enums.DsSplitSE¶
Bases:
enum.StrEnumDataset split names.
NONEis the empty string, for a dataset held as a single unsplit table.Initialize self. See help(type(self)) for accurate signature.
- NONE = ''¶
- TEST = 'test'¶
- TRAIN = 'train'¶
- VALIDATION = 'validation'¶
- class micm_nlp.enums.DsStateSE¶
Bases:
enum.StrEnumHow far a dataset has been processed, and which variant is on disk – tokenized, split, subsetted, or filtered by length.
Initialize self. See help(type(self)) for accurate signature.
- LONG = 'long'¶
- SHORT = 'short'¶
- SPLITS = 'splits'¶
- SUBSET = 'subset'¶
- TOKENIZED = 'tokenized'¶
- class micm_nlp.enums.DsTypeSE¶
Bases:
enum.StrEnumHow a dataset is loaded.
HUGGINGFACEpulls from the Hub;HUGGINGFACE_SAVEDreads a localsave_to_diskdirectory.Initialize self. See help(type(self)) for accurate signature.
- CSV = 'csv'¶
- HUGGINGFACE = 'huggingface'¶
- HUGGINGFACE_SAVED = 'huggingface_saved'¶
- JSON = 'json'¶
- TEXT = 'text'¶
- class micm_nlp.enums.ElectraTokenSE¶
Bases:
enum.StrEnumELECTRA’s special tokens – identical to BERT’s.
One member per role, so the tokenizer factory can ask any of these tables for
BOS/EOS/PAD/… without knowing which architecture it is holding.additional()returns the tokens beyond that common set.Initialize self. See help(type(self)) for accurate signature.
- classmethod additional()¶
Special tokens beyond the common BOS/EOS/SEP/CLS/PAD/UNK/MASK set.
- BOS = '[CLS]'¶
- CLS = '[CLS]'¶
- EOS = '[SEP]'¶
- MASK = '[MASK]'¶
- PAD = '[PAD]'¶
- SEP = '[SEP]'¶
- UNK = '[UNK]'¶
- class micm_nlp.enums.EvalTypeSE¶
Bases:
enum.StrEnumWhat kind of
evaluateobject to load. A metric scores predictions against labels, a comparison scores two models against each other, and a measurement describes a dataset rather than a model.Initialize self. See help(type(self)) for accurate signature.
- COMPARISON = 'comparison'¶
- MEASUREMENT = 'measurement'¶
- METRIC = 'metric'¶
- class micm_nlp.enums.ModeSE¶
Bases:
enum.StrEnumWhat a run does: train from scratch, finetune a checkpoint, evaluate, test, clean a workspace, or preprocess a dataset without training.
Initialize self. See help(type(self)) for accurate signature.
- CLEAN = 'clean'¶
- EVALUATE = 'evaluate'¶
- FINETUNE = 'finetune'¶
- PREPROCESS = 'preprocess'¶
- TEST = 'test'¶
- TRAIN = 'train'¶
- class micm_nlp.enums.ModelArchSE¶
Bases:
enum.StrEnumArchitecture families the tokenizer factory knows how to dress – it selects the special-token table and post-processor.
Note this is not what
model.architecturein a config is validated against; that field is free-form and used for run-directory naming.Initialize self. See help(type(self)) for accurate signature.
- AYA = 'aya'¶
- BERT = 'bert'¶
- ELECTRA = 'electra'¶
- ROBERTA = 'roberta'¶
- T5 = 't5'¶
- XGLM = 'xglm'¶
- XLMR = 'xlmr'¶
- XLNET = 'xlnet'¶
- class micm_nlp.enums.PretSourceSE¶
Bases:
enum.StrEnumWhere a pretrained model or tokenizer comes from: the Hub, or a local path.
Initialize self. See help(type(self)) for accurate signature.
- HUGGINGFACE = 'huggingface'¶
- LOCAL = 'local'¶
- class micm_nlp.enums.RobertaTokenSE¶
Bases:
enum.StrEnumRoBERTa’s special tokens.
One member per role, so the tokenizer factory can ask any of these tables for
BOS/EOS/PAD/… without knowing which architecture it is holding.additional()returns the tokens beyond that common set.Initialize self. See help(type(self)) for accurate signature.
- classmethod additional()¶
Special tokens beyond the common BOS/EOS/SEP/CLS/PAD/UNK/MASK set.
- BOS = '<s>'¶
- CLS = '<s>'¶
- EOS = '</s>'¶
- MASK = '<mask>'¶
- PAD = '<pad>'¶
- SEP = '</s>'¶
- UNK = '<unk>'¶
- class micm_nlp.enums.SaveDatasetAsSE¶
Bases:
enum.StrEnumOn-disk format when writing a dataset: CSV, or HuggingFace’s own
save_to_disklayout.Initialize self. See help(type(self)) for accurate signature.
- CSV = 'csv'¶
- HUGGINGFACE = 'huggingface'¶
- class micm_nlp.enums.SentTokTypeSE¶
Bases:
enum.StrEnumSentence splitter to use.
KAselectsKaSenTok, the Georgian splitter; the others are NLTK’s and spaCy’s.Initialize self. See help(type(self)) for accurate signature.
- KA = 'kast'¶
- NLTK = 'nltkst'¶
- SPACY = 'spacyst'¶
- class micm_nlp.enums.StrEnum¶
Bases:
str,enum.EnumStand-in for
enum.StrEnumon Python 3.10, which does not have it.Subclassing
strgives the same property the real thing does, and the one this module depends on: a member compares equal to its value, so a YAML string matches without conversion.Initialize self. See help(type(self)) for accurate signature.
- class micm_nlp.enums.T5TokenSE¶
Bases:
enum.StrEnumT5’s special tokens.
One member per role, so the tokenizer factory can ask any of these tables for
BOS/EOS/PAD/… without knowing which architecture it is holding.additional()returns the tokens beyond that common set.Initialize self. See help(type(self)) for accurate signature.
- classmethod additional()¶
Special tokens beyond the common BOS/EOS/SEP/CLS/PAD/UNK/MASK set.
- BOS = '<s>'¶
- CLS = '<s>'¶
- EOS = '</s>'¶
- MASK = '<mask>'¶
- PAD = '<pad>'¶
- SEP = '</s>'¶
- UNK = '<unk>'¶
- class micm_nlp.enums.TaskCatSE¶
Bases:
enum.StrEnumTask family, which decides the head and the loss.
TEXT_GENERATIONis for decoder-only models,TEXT_TO_TEXTfor encoder-decoder ones.Initialize self. See help(type(self)) for accurate signature.
- LANGUAGE_MODELING = 'language_modeling'¶
- STRUCTURAL_ANALYSIS = 'structural_analysis'¶
- TEXT_CLASSIFICATION = 'text_classification'¶
- TEXT_GENERATION = 'text_generation'¶
- TEXT_PAIR_CLASSIFICATION = 'text_pair_classification'¶
- TEXT_SIMILARITIY = 'text_similarity'¶
- TEXT_TO_TEXT = 'text_to_text'¶
- TOKEN_CLASSIFICATION = 'token_classification'¶
- class micm_nlp.enums.TaskNameSE¶
Bases:
enum.StrEnumThe concrete task: masked and permutation language modelling, sentiment analysis, NER, POS tagging, topic detection.
Initialize self. See help(type(self)) for accurate signature.
- DMLM = 'dmlm'¶
- MLM = 'mlm'¶
- NER = 'ner'¶
- PLM = 'plm'¶
- POS = 'pos'¶
- SA = 'sa'¶
- TOPIC = 'topic'¶
- class micm_nlp.enums.TokAlgSE¶
Bases:
enum.StrEnumTraining algorithm for a SentencePiece tokenizer: BPE or unigram.
Initialize self. See help(type(self)) for accurate signature.
- BPE = 'bpe'¶
- UNIGRAM = 'unigram'¶
- class micm_nlp.enums.TokTypeSE¶
Bases:
enum.StrEnumSubword algorithm to train or load.
BYTE_LEVELis the ByT5-style byte vocabulary; the SentencePiece entries distinguish the native trainer from HuggingFace’s.Initialize self. See help(type(self)) for accurate signature.
- BPE = 'bpe'¶
- BYTE_LEVEL = 'byte_level'¶
- BYTE_LEVEL_BPE = 'byte_level_bpe'¶
- HUGGINGFACE_SENTPIECE = 'huggingface_sentpiece'¶
- NATIVE_SENTPIECE = 'native_sentpiece'¶
- WORDPIECE = 'wordpiece'¶
- class micm_nlp.enums.WordTokTypeSE¶
Bases:
enum.StrEnumWord tokenizer to use when a step needs words rather than subwords – NLTK’s whitespace or punctuation tokenizer.
Initialize self. See help(type(self)) for accurate signature.
- NLTK_PUNCT = 'nltk_punct'¶
- NLTK_WHITESPACE = 'nltk_whitespace'¶
- class micm_nlp.enums.XLMRobertaTokenSE¶
Bases:
enum.StrEnumXLM-R’s special tokens – identical to RoBERTa’s.
One member per role, so the tokenizer factory can ask any of these tables for
BOS/EOS/PAD/… without knowing which architecture it is holding.additional()returns the tokens beyond that common set.Initialize self. See help(type(self)) for accurate signature.
- classmethod additional()¶
Special tokens beyond the common BOS/EOS/SEP/CLS/PAD/UNK/MASK set.
- BOS = '<s>'¶
- CLS = '<s>'¶
- EOS = '</s>'¶
- MASK = '<mask>'¶
- PAD = '<pad>'¶
- SEP = '</s>'¶
- UNK = '<unk>'¶
- class micm_nlp.enums.XLNetTokenSE¶
Bases:
enum.StrEnumXLNet’s special tokens, including the end-of-paragraph and end-of-document markers it adds beyond the usual set.
One member per role, so the tokenizer factory can ask any of these tables for
BOS/EOS/PAD/… without knowing which architecture it is holding.additional()returns the tokens beyond that common set.Initialize self. See help(type(self)) for accurate signature.
- classmethod additional()¶
Special tokens beyond the common BOS/EOS/SEP/CLS/PAD/UNK/MASK set.
- BOS = '<s>'¶
- CLS = '<cls>'¶
- EOD = '<eod>'¶
- EOP = '<eop>'¶
- EOS = '</s>'¶
- MASK = '<mask>'¶
- PAD = '<pad>'¶
- SEP = '<sep>'¶
- UNK = '<unk>'¶