Skip to content

API reference

The Python and JavaScript packages share names and options. In JavaScript every task returns a Promise and options go in a final object ({ langs, precision, model }).

Tasks

Python JavaScript Returns
punct(text, lang) punct(text, lang, opts) the text with punctuation and capitals
switch(text, langs=None, region=None) switch(text, { langs, region }) / switchLangs [Word(text, lang, score)]
segment(text, lang) segment(text, lang, opts) [word, ...]
suggest(text, lang) suggest(text, lang, opts) Suggestion(text, source, score)
mend(text, lang, restore=True, ...) mend(text, lang, { restore, ... }) MendResult(text, suggestion, mode) (beta)
flag(text, lang) flag(text, lang, opts) [(word, flagged), ...] (beta)

Every task also takes:

Option Default What it does
precision "auto" "auto", "int8" or "fp32"
model built-in your own model: Hub repo id, local folder (Python) or base URL (JavaScript)
revision "main" Hub revision of model

Task settings (each defaults to the language's calibrated value; see the task pages):

Task Python JavaScript
suggest eagerness, cutoff, bigram_cutoff, min_chars eagerness, cutoff, bigramCutoff, minChars
mend eagerness, mode, threshold, margin, restore_confidence, restore eagerness, mode, threshold, margin, restoreConfidence, restore
flag eagerness, threshold eagerness, threshold
switch langs, region, sensitivity langs, region, sensitivity

eagerness (0–1, default 0.5 = calibrated) is one knob for how many suggestions or corrections appear; the other settings win over it. Punctuation and word boundaries have no thresholds; switch returns a score for every word, so you can set your own bar on it.

Helpers

Python JavaScript What it does
languages(task) languages(task) every language label a task supports
tasks() tasks() {task: stability} for this version
suggest_settings(lang) suggestSettings(lang) the calibrated suggestion settings for a language
preload(task, lang=..., region=..., model=...) preload(task, { lang, region, model }) download and load ahead of time
register(task, source, languages=None) register(task, source, { languages }) use your own model for its languages
configure({ ort, host, store, fetch }) runtime options

Command line

yellowmist punct "text" --lang yor_Latn
yellowmist switch "text" --langs hin_Latn,eng_Latn [--json]
yellowmist segment "text" --lang tha_Thai
yellowmist suggest "text typed so far" --lang eng_Latn
yellowmist languages punct
yellowmist download punct --lang yor_Latn

Training (pip install "yellowmist[train]")

Function What it does
train.Encoder.load(region_or_repo_or_folder) load an encoder; .add_languages({lang: texts}) for new languages
train.continue_pretraining(enc, texts, steps=2000) keep pretraining on your text
train.finetune_switch(enc, texts, steps=3000) code-switching detector for your languages
train.finetune_punct(enc, texts, steps=6000) punctuation and capitals on your text
model.save(folder) weights + ONNX export, ready for register / model=
train.push_to_hub(folder, repo_id) upload as a Hub model repo (private by default)