NLContextualEmbedding
A model that computes sequences of embedding vectors for natural language utterances.
Declaration
class NLContextualEmbeddingOverview
NLContextualEmbedding provides a dense vector representation of natural language utterances using models trained with contextualized language understanding. Unlike static word embeddings provided by NLEmbedding, contextual embeddings dynamically adjust based on surrounding words, enabling deeper language comprehension.
If you are building text classification or word tagging models, you can use NLContextualEmbedding with Create ML by selecting MLTextClassifier.FeatureExtractorType.bertEmbedding as the feature extraction component in your model. For more information on how to create your own text classification model refer to Creating a text classifier model.
Before configuring your contextual embedding:
Select a model that’s appropriate for your target language when initializing the embedding.
Call requestAssets(completionHandler:) before computing the embedding to confirm assets are available.
Some models support multiple languages; for example, you can use the same object to compute embeddings for both English and Spanish. However, this isn’t always the case — languages like English and Chinese may require separate models. For more information about supported languages, refer to languages.