Professional Documents
Culture Documents
Session 713
© 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
Natural
Intelligence
Language Input
Typed text
Transcribed speech
Recognized handwriting
NSLinguisticTagger
Language Identification
Tokenization
Natural
Intelligence
Part of Speech
Language Input
Lemmatization
Language Identification
Tokenization
Natural
Intelligence
Language Input Part of Speech
Lemmatization
import NaturalLanguage
recognizer.processString(“困死啦睡觉去了了”)
import NaturalLanguage
recognizer.processString(“困死啦睡觉去了了”)
import NaturalLanguage
recognizer.processString(“困死啦睡觉去了了”)
import NaturalLanguage
recognizer.processString(“困死啦睡觉去了了”)
import NaturalLanguage
recognizer.processString(“困死啦睡觉去了了”)
import NaturalLanguage
recognizer.processString(“困死啦睡觉去了了”)
import NaturalLanguage
tokenizer.string = str
import NaturalLanguage
tokenizer.string = str
import NaturalLanguage
tokenizer.string = str
import NaturalLanguage
tokenizer.string = str
import NaturalLanguage
tokenizer.string = str
import NaturalLanguage
tokenizer.string = str
困 死 啦 睡觉 去 了了
Tokenization
import NaturalLanguage
tokenizer.string = str
困 死 啦 睡觉 去 了了
< John M
困死啦睡觉去了了
Harry
Harry Potter
Harry Styles
import NaturalLanguage
let str = “Prince Harry and Meghan Markle had their wedding ceremony in Windsor”
tagger.string = str
import NaturalLanguage
let str = “Prince Harry and Meghan Markle had their wedding ceremony in Windsor”
tagger.string = str
import NaturalLanguage
let str = “Prince Harry and Meghan Markle had their wedding ceremony in Windsor”
tagger.string = str
import NaturalLanguage
let str = “Prince Harry and Meghan Markle had their wedding ceremony in Windsor”
tagger.string = str
import NaturalLanguage
let str = “Prince Harry and Meghan Markle had their wedding ceremony in Windsor”
tagger.string = str
import NaturalLanguage
let str = “Prince Harry and Meghan Markle had their wedding ceremony in Windsor”
tagger.string = str
Developer documentation
Examples
Concept Learning
Examples
Concept Learning
Classify
Examples and
Understand
Machine Learning
Classify
Training Data and
Understand
Types of Custom Model
Types of Custom Model
Text Classification
Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex
ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat
Label
cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum
Foles’ late TD pass leads Eagles to 1st Super Bowl title SPORTS
Apple introduces new 9.7 inch iPad with Apple Pencil support TECHNOLOGY
Noun phrase
Verb phrase
Prepositional phrase
Supervised Machine Learning
Training and inference
Supervised Machine Learning
Training and inference
Annotated data
Training
Supervised Machine Learning
Training and inference
Annotated data
Training
Training Data
Custom NLP Models
Training
Natural Language
Custom NLP Models
Training
Natural Language
Custom NLP Models
Training
Natural Language
Text Classifier
Annotated data
[
{
“text”: “I am really excited, would definitely recommend it highly!“,
“label”: “Positive”
},
{
“text”: “It was OK, something I could live with for now.“,
“label”: “Neutral”
},
{
“text”: “This was terrible, much worse than I expected.“,
“label”: “Negative”
},
]
Text Classifier
Annotated data
[
{
“text”: “I am really excited, would definitely recommend it highly!“,
“label”: “Positive”
},
{
“text”: “It was OK, something I could live with for now.“,
“label”: “Neutral”
},
{
“text”: “This was terrible, much worse than I expected.“,
“label”: “Negative”
},
]
Text Classifier
Training
import CreateML
import Foundation
withExtension: “json”)!)
import CreateML
import Foundation
withExtension: “json”)!)
import CreateML
import Foundation
withExtension: “json”)!)
import CreateML
import Foundation
withExtension: “json”)!)
[
{
“tokens": [“AirPods”, “are”, “a”, “fantastic”, “product”, “from”, “Apple”, “.”],
“labels”: [“PROD”, “NONE”, “NONE”, “NONE”, “NONE”, “NONE”, “ORG”, “NONE”]
},
{
“tokens": [“Apple”, “and”, “Tim”, “Cook”, “have”, “another”, “hit”, “.”],
“labels”: [“ORG”, “NONE”, “PER”, “PER”, “NONE”, “NONE”, “NONE”, “NONE”]
}
]
Word Tagger
Annotated data
[
{
“tokens": [“AirPods”, “are”, “a”, “fantastic”, “product”, “from”, “Apple”, “.”],
“labels”: [“PROD”, “NONE”, “NONE”, “NONE”, “NONE”, “NONE”, “ORG”, “NONE”]
},
{
“tokens": [“Apple”, “and”, “Tim”, “Cook”, “have”, “another”, “hit”, “.”],
“labels”: [“ORG”, “NONE”, “PER”, “PER”, “NONE”, “NONE”, “NONE”, “NONE”]
}
]
Word Tagger
Training
import CreateML
import Foundation
import CreateML
import Foundation
import CreateML
import Foundation
import CreateML
import Foundation
User data
import NaturalLanguage
withExtension: “mlmodelc”) {
}
Using a Custom Model
import NaturalLanguage
withExtension: “mlmodelc”) {
}
Using a Custom Model
import NaturalLanguage
withExtension: “mlmodelc”) {
}
Using a Custom Model
import NaturalLanguage
withExtension: “mlmodelc”) {
}
Using Custom Models with NLTagger
tagger.string = myString
}
Using Custom Models with NLTagger
tagger.string = myString
}
Using Custom Models with NLTagger
tagger.string = myString
}
Using Custom Models with NLTagger
tagger.string = myString
}
Using Custom Models with NLTagger
tagger.string = myString
}
Using Custom Models with NLTagger
tagger.string = myString
}
Wade
Bookmark organization
Demo
Swift APIs for NLP Custom NLP models
Swift APIs for NLP Custom NLP models Performance
Natural Language
Training
Data Tokenization Machine CoreML
Feature Extraction Learning Toolkit Convertor
Text Processing
Typical ML inference
Tokenization
Feature Extraction
Training Data
Standarized Text Processing
Natural Language
Natural Language
Tokenization
Machine
Feature
Learning
Extraction
Standarized Text Processing
Natural Language
Natural Language
Tokenization
Machine
Feature
Learning
Extraction
Standarized Text Processing
Natural Language
Natural Language
Tokenization
Machine
Feature
Learning
Extraction
Standarized Text Processing
Natural Language
Natural Language
Low latency
Low latency
Chunking 30 MB 1.8 MB
Maximum Entropy
ML Algorithms
Text classification
Training
Data
Training
Data
Training
Data
Evaluation Training
Data
Evaluation Training
Data
Evaluation Training
Data
Retrain model
Evaluation Training
Data
Workflow for ML
Evaluation Training
Swift APIs for NLP Custom NLP models Performance
Swift APIs for NLP Custom NLP models Performance Privacy
Privacy Preserving ML Applied to NLP
Natural Language Framework
Summary
Performance
Privacy
More Information
https://developer.apple.com/wwdc18/713