Quickstart

Intro

from micm_nlp import init, run, example

init('/path/to/your/workspace')
output = run(example('xsc_finetune.yml'))
  • init() loads .env and sets your workspace root. A bare init() is enough when PROJECT_ROOT_PATH is set in .env or the environment.

  • run() takes a config, and chains: load tokenizer → load and preprocess dataset → load model, with PEFT if configured → train → evaluate.

  • example() resolves the path of a config shipped inside the package.

  • output holds info about run, raw predictions, metric results, and the dir path where everything is written.

Drive the stages yourself

The chain, unwrapped — this is what run() does. Copy it to interact between stages, e.g. add your own dataset processing after dataset.preprocess(tokenizer).

from micm_nlp import CONFIG, init, example
from micm_nlp.tokenizers.tokenizer import load as load_tokenizer
from micm_nlp.datasets.dataset import DATASET
from micm_nlp.models.model import MODEL
from micm_nlp.training.runner import TRAINER

# Workspace
init('/path/to/your/workspace', pretty_output=True)

# Config
config = CONFIG.from_yaml(example('xsc_finetune.yml'))

# Tokenizer
tokenizer = load_tokenizer(config)

# Dataset
dataset = DATASET(config)
dataset.preprocess(tokenizer)

# Model
model = MODEL(config)

# Trainer
trainer = TRAINER(model, dataset, tokenizer)
output = trainer.run()

Examples

Three configs ship inside the package, covering one use case end to end — preprocessing, decoder-only PEFT fine-tuning on an FTP-reframed multilingual dataset from the HuggingFace Hub, and the same fine-tune as a group.

Config

What it does

xsc_preprocess.yml

loads FTP-reframed XStoryCloze (English) from the Hub, tokenizes it for BLOOM-560M, saves the result locally

xsc_finetune.yml

fine-tunes BLOOM-560M with Cross-Prompt Encoder PEFT on the Arabic split, then evaluates

groups/xsc_tune_across_seeds.yml

the same fine-tune at two seeds, one run directory each

micm-nlp init-examples
python -m micm_nlp run       --config       configs/examples/xsc_preprocess.yml
python -m micm_nlp run       --config       configs/examples/xsc_finetune.yml
python -m micm_nlp run-group --group-config configs/examples/groups/xsc_tune_across_seeds.yml

init-examples writes editable copies to configs/examples/; example() reaches the same files in place.
The package’s surface is broader than these three demonstrate. Examples for encoder-only text classification, encoder-decoder seq2seq and MLM pretraining are planned.

Note

The preprocessing phase can run in every unit run, whatever the mode, but we expose mode: preprocess separately for tokenizing once and reusing across many runs.