A custom model trained to classify or tag natural language text.


class NLModel : NSObject


With Create ML, you can create MLTextClassifier or MLWordTagger models. Use the NLModel to integrate those models into your app. This integration ensures that your tokenization and tagger configurations are identical when you train your model and use it in your app.


Creating a Model

init(mlModel: MLModel)

Creates a new natural language model based on a Core ML model.

init(contentsOf: URL)

Creates a new natural language model based on a Core ML model.

Making Predictions

func predictedLabel(for: String) -> String?

Predicts a label for the input string.

func predictedLabels(forTokens: [String]) -> [String]

Predicts a label for each input string.

Inspecting a Model

var configuration: NLModelConfiguration

A configuration describing the natural language model.

class NLModelConfiguration

The configuration parameters of a natural language model.


Inherits From

Conforms To

See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software