Divooka Reference

Text-to-Text Models

4 nodes

On this page 4

Load Text-to-Text Model

Function

Loads a text-to-text model and its tokenizer from a Hub repository or a folder.

Signature
LoadTextToTextModel -> Text To Text Model
    model: Text
    device: Compute Device
    precision: Precision
TextToTextModel LoadTextToTextModel(
    string model,
    ComputeDevice device = ComputeDevice.Auto,
    Precision precision = Precision.Auto)

Parameters

nametypedefaultdescription
modelText—A repository id such as google-t5/t5-small or google/flan-t5-small, or a folder.
deviceCompute DeviceAutoWhere it runs.
precisionPrecisionAutoThe number format of its weights.

Returns

ModelText To Text Model
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text-to-Text Models
Package
Machine Learning

Summarize

Function

A shorter text saying what a longer one says.

Signature
Summarize -> Text
    model: Text To Text Model
    text: Text
    settings: Generation Settings
    cleanUpSpaces: Truth
string Summarize(
    TextToTextModel model,
    string text,
    GenerationSettings settings,
    bool cleanUpSpaces = true)

Parameters

nametypedefaultdescription
modelText To Text Model—A text-to-text model trained to summarize, such as T5 or BART-CNN.
textText—The text to summarize.
settingsGeneration Settings—How it chooses its words; empty for the model's summarization settings.
cleanUpSpacesTruthTrueRemove the spaces the tokenizer leaves before punctuation and in contractions ("building . it" becomes "building. it"), as transformers' clean_up_tokenization does; off for the text byte for byte as transformers' pipeline gives it.

Returns

SummaryText
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text-to-Text Models
Package
Machine Learning

Transform Text

Function

The model's answer to a text as it is, with no task prefix: what instruction-tuned models such as Flan-T5 are asked with.

Signature
TransformText -> Text
    model: Text To Text Model
    input: Text
    settings: Generation Settings
    cleanUpSpaces: Truth
string TransformText(
    TextToTextModel model,
    string input,
    GenerationSettings settings,
    bool cleanUpSpaces = true)

Parameters

nametypedefaultdescription
modelText To Text Model—A text-to-text model.
inputText—The instruction or text.
settingsGeneration Settings—How it chooses its words; empty for the model's own defaults.
cleanUpSpacesTruthTrueRemove the spaces the tokenizer leaves before punctuation and in contractions ("building . it" becomes "building. it"), as transformers' clean_up_tokenization does; off for the text byte for byte as transformers' pipeline gives it.

Returns

OutputText
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text-to-Text Models
Package
Machine Learning

Translate

Function

Translates a text from one language to another, asked as T5 is asked: "translate English to German: ".

Signature
Translate -> Text
    model: Text To Text Model
    text: Text
    from: Text
    to: Text
    settings: Generation Settings
    cleanUpSpaces: Truth
string Translate(
    TextToTextModel model,
    string text,
    string from = "English",
    string to = "German",
    GenerationSettings settings,
    bool cleanUpSpaces = true)

Parameters

nametypedefaultdescription
modelText To Text Model—A text-to-text model that translates between the two languages, such as T5 (English to German, French or Romanian) or Flan-T5.
textText—The text to translate.
fromTextEnglishThe language it is in, in English: English, German...
toTextGermanThe language to translate it to.
settingsGeneration Settings—How it chooses its words; empty for the model's translation settings.
cleanUpSpacesTruthTrueRemove the spaces the tokenizer leaves before punctuation and in contractions ("building . it" becomes "building. it"), as transformers' clean_up_tokenization does; off for the text byte for byte as transformers' pipeline gives it.

Returns

TranslationText
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text-to-Text Models
Package
Machine Learning