Divooka Reference

Text Tasks

10 nodes

On this page 10

Answer Question

Function

Answers a question with the passage of a text that answers it.

Signature
AnswerQuestion -> (Answer: Text, score: Number)
    answerer: Question Answerer
    question: Text
    context: Text
string AnswerQuestion(
    QuestionAnswerer answerer,
    string question,
    string context,
    out double score)

Parameters

nametypedefaultdescription
answererQuestion Answerer—A question-answering model.
questionText—The question.
contextText—The text the answer is taken from; a long text is read in overlapping windows.

Returns

AnswerText
scoreNumber
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Classify Text

Function

The labels that best describe a text, best first.

Signature
ClassifyText -> (Labels: Text Array, scores: Number Array)
    classifier: Text Classifier
    text: Text
    top: Integer
string[] ClassifyText(
    TextClassifier classifier,
    string text,
    int top,
    out double[] scores)

Parameters

nametypedefaultdescription
classifierText Classifier—A text classifier.
textText—The text.
topInteger—How many labels to give; 0 for all of them.

Returns

LabelsText Array
scoresNumber Array
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Classify Text Zero-Shot

Function

Scores a text against labels written in words, best first.

Signature
ClassifyTextZeroShot -> (Labels: Text Array, scores: Number Array)
    classifier: Zero Shot Text Classifier
    text: Text
    labels: Text Array
    template: Text
    multiLabel: Truth
string[] ClassifyTextZeroShot(
    ZeroShotTextClassifier classifier,
    string text,
    string[] labels,
    string template,
    bool multiLabel,
    out double[] scores)

Parameters

nametypedefaultdescription
classifierZero Shot Text Classifier—A zero-shot text classifier.
textText—The text.
labelsText Array—The candidate labels, such as "technology", "sports", "cooking".
templateText—The sentence each label is put into; {} stands for the label.
multiLabelTruth—Score each label on its own, so several can apply, rather than sharing one probability among them.

Returns

LabelsText Array
scoresNumber Array
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Fill Mask

Function

The likeliest words for the mask token in a text, best first, with the text each makes.

Signature
FillMask -> (Words: Text Array, texts: Text Array, scores: Number Array)
    filler: Mask Filler
    text: Text
    top: Integer
string[] FillMask(
    MaskFiller filler,
    string text,
    int top,
    out string[] texts,
    out double[] scores)

Parameters

nametypedefaultdescription
fillerMask Filler—A masked language model.
textText—A text with the model's mask token in it once, such as "Paris is the [MASK] of France."
topInteger—How many guesses to give.

Returns

WordsText Array
textsText Array
scoresNumber Array
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Load Entity Recognizer

Function

Loads a named-entity recognizer from a Hub repository or a folder.

Signature
LoadEntityRecognizer -> Entity Recognizer
    model: Text
    device: Compute Device
    precision: Precision
    backend: Model Backend
EntityRecognizer LoadEntityRecognizer(
    string model,
    ComputeDevice device = ComputeDevice.Auto,
    Precision precision = Precision.Auto,
    ModelBackend backend = ModelBackend.TorchSharp)

Parameters

nametypedefaultdescription
modelText—A repository id such as dslim/bert-base-NER, or a folder.
deviceCompute DeviceAutoWhere it runs, on TorchSharp.
precisionPrecisionAutoThe number format of its weights, on TorchSharp.
backendModel BackendTorch sharpTorchSharp, or the managed ONNX backend on the CPU.

Returns

RecognizerEntity Recognizer
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Load Mask Filler

Function

Loads a masked language model from a Hub repository or a folder.

Signature
LoadMaskFiller -> Mask Filler
    model: Text
    device: Compute Device
    precision: Precision
    backend: Model Backend
MaskFiller LoadMaskFiller(
    string model,
    ComputeDevice device = ComputeDevice.Auto,
    Precision precision = Precision.Auto,
    ModelBackend backend = ModelBackend.TorchSharp)

Parameters

nametypedefaultdescription
modelText—A repository id such as distilbert/distilbert-base-uncased or FacebookAI/roberta-base, or a folder.
deviceCompute DeviceAutoWhere it runs, on TorchSharp.
precisionPrecisionAutoThe number format of its weights, on TorchSharp.
backendModel BackendTorch sharpTorchSharp, or the managed ONNX backend on the CPU.

Returns

FillerMask Filler
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Load Question Answerer

Function

Loads an extractive question-answering model from a Hub repository or a folder.

Signature
LoadQuestionAnswerer -> Question Answerer
    model: Text
    device: Compute Device
    precision: Precision
    backend: Model Backend
QuestionAnswerer LoadQuestionAnswerer(
    string model,
    ComputeDevice device = ComputeDevice.Auto,
    Precision precision = Precision.Auto,
    ModelBackend backend = ModelBackend.TorchSharp)

Parameters

nametypedefaultdescription
modelText—A repository id such as deepset/roberta-base-squad2, or a folder.
deviceCompute DeviceAutoWhere it runs, on TorchSharp.
precisionPrecisionAutoThe number format of its weights, on TorchSharp.
backendModel BackendTorch sharpTorchSharp, or the managed ONNX backend on the CPU.

Returns

AnswererQuestion Answerer
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Load Text Classifier

Function

Loads a text classifier from a Hub repository or a folder.

Signature
LoadTextClassifier -> Text Classifier
    model: Text
    device: Compute Device
    precision: Precision
    backend: Model Backend
TextClassifier LoadTextClassifier(
    string model,
    ComputeDevice device = ComputeDevice.Auto,
    Precision precision = Precision.Auto,
    ModelBackend backend = ModelBackend.TorchSharp)

Parameters

nametypedefaultdescription
modelText—A repository id such as distilbert/distilbert-base-uncased-finetuned-sst-2-english, or a folder.
deviceCompute DeviceAutoWhere it runs, on TorchSharp.
precisionPrecisionAutoThe number format of its weights, on TorchSharp.
backendModel BackendTorch sharpTorchSharp, or the managed ONNX backend on the CPU.

Returns

ClassifierText Classifier
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Load Zero-Shot Text Classifier

Function

Loads a zero-shot text classifier (a model trained on natural-language inference) from a Hub repository or a folder.

Signature
LoadZeroShotTextClassifier -> Zero Shot Text Classifier
    model: Text
    device: Compute Device
    precision: Precision
    backend: Model Backend
ZeroShotTextClassifier LoadZeroShotTextClassifier(
    string model,
    ComputeDevice device = ComputeDevice.Auto,
    Precision precision = Precision.Auto,
    ModelBackend backend = ModelBackend.TorchSharp)

Parameters

nametypedefaultdescription
modelText—A repository id such as MoritzLaurer/xtremedistil-l6-h256-zeroshot-v1.1-all-33, or a folder.
deviceCompute DeviceAutoWhere it runs, on TorchSharp.
precisionPrecisionAutoThe number format of its weights, on TorchSharp.
backendModel BackendTorch sharpTorchSharp, or the managed ONNX backend on the CPU.

Returns

ClassifierZero Shot Text Classifier
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning

Recognize Entities

Function

The names a text mentions and what each is - PER, LOC, ORG, MISC for most English models - in the order they appear.

Signature
RecognizeEntities -> (Entities: Text Array, types: Text Array, scores: Number Array, starts: Integer Array)
    recognizer: Entity Recognizer
    text: Text
string[] RecognizeEntities(
    EntityRecognizer recognizer,
    string text,
    out string[] types,
    out double[] scores,
    out int[] starts)

Parameters

nametypedefaultdescription
recognizerEntity Recognizer—An entity recognizer.
textText—The text.

Returns

EntitiesText Array
typesText Array
scoresNumber Array
startsInteger Array
Ships with
Divooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Text Tasks
Package
Machine Learning