Penelope v0.5.0 Penelope.NLP.IntentClassifier View Source
The intent classifier transforms a natural language utterance into a named intent and a set of named parameters. It uses an ML classifier to infer the intent name and an entity recognizer to extract named entities as parameters. These components are both represented as ML pipelines.
The intent classifier also maintains a tokenizer pipeline for converting utterances into a list of tokens. This pipeline is executed first, and its results are run through the classifier/recognizer pipelines.
Classification results are returned as a tuple of
Example: pipeline = %{
tokenizer: [{:ptb_tokenizer, []}],
classifier: [{:count_vectorizer, []},
{:linear_classifier, [c: 2.0, probability?: true]}],
recognizer: [{:crf_tagger, []}],
} x = [
"you have four pears",
"three hundred apples would be a lot"
] y = [
{"intent_1", ["o", "o", "b_count", "b_fruit"]},
{"intent_2", ["b_count", "i_count", "b_fruit", "o", "o", "o", "o"]}
] classifier = Penelope.NLP.IntentClassifier.fit(%{}, x, y, pipeline)
{intents, params} = Penelope.NLP.IntentClassifier.predict_intent(
classifier,
%{},
"I have three bananas"
)
Link to this section Summary
Functions
imports parameters from a serialized model
exports a runtime model to a serializable data structure
fits the tokenizer, classifier, and recognizer models
predicts an intent and its parameters from an utterance string
Link to this section Types
Link to this section Functions
imports parameters from a serialized model
exports a runtime model to a serializable data structure
fits the tokenizer, classifier, and recognizer models
predicts an intent and its parameters from an utterance string