View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Make apps smarter with Natural Language

    Explore how you can leverage the Natural Language framework to better analyze and understand text. Learn how to draw meaning from text using the framework's built-in word and sentence embeddings, and how to create your own custom embeddings for specific needs.

    We'll show you how to use samples to train a custom text classifier or word tagger to extract important pieces of information out of text— all powered by the transfer learning algorithms in Natural Language. Find out how you can create apps that can answer user questions, recognize similarities in text, and find relevant documents, images, and more.

    To get the most out of this session, you should have a basic understanding of the Natural Language framework. For an overview, watch “Introducing Natural Language Framework” and “Advances in Natural Language Framework.” You can also brush up on model training using Create ML through “Introducing the Create ML App.”

    Recursos

      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC23

    • Explore Natural Language multilingual models

    WWDC19

    • Advances in Natural Language Framework
  • Buscar neste vídeo...
    • 3:53 - Confidence Scores: tagHypotheses

      import NaturalLanguage 
      
      let tagger = NLTagger(tagSchemes: [.nameType])
      let str = "Tim Cook is very popular in Spain."
      let strRange = Range(uncheckedBounds: (str.startIndex, str.endIndex))
      tagger.string = str
      tagger.setLanguage(.english, range: strRange)
       
      tagger.enumerateTags(in: str.startIndex..<str.endIndex, unit: .word, scheme: .nameType, options: .omitWhitespace) { (tag, tokenRange) -> Bool in
          let (hypotheses, _) = tagger.tagHypotheses(at: tokenRange.lowerBound, unit: .word, 
                                                     scheme: .nameType, maximumCount: 1)
          print(hypotheses)
          return true
      }
    • 12:19 - Word Embedding

      import NaturalLanguage
      
      if let embedding = NLEmbedding.wordEmbedding(for: .english) {
          let word = "bicycle"
          
          if let vector = embedding.vector(for: word) {
              print(vector)
          }
          
          let dist = embedding.distance(between:word, and: "motorcycle")
          print(dist)
          
          embedding.enumerateNeighbors(for: word, maximumCount: 5) { neighbor, distance in
              print("\(neighbor): \(distance.description)")
              return true
          }
      }
    • 16:32 - Sentence Embedding

      import NaturalLanguage
      
      if let embedding = NLEmbedding.sentenceEmbedding(for: .english) {
          let sentence = "This is a sentence."
          
          if let vector = sentenceEmbedding.vector(for: sentence) {
              print(vector)
          }
          
          let dist = sentenceEmbedding.distance(between: sentence, and: "That is a sentence.")
          print(dist)
      }
    • 18:36 - Finding nearest neighbor with sentence embedding

      func answerKey(for string: String) -> String? {
              guard let embedding = NLEmbedding.sentenceEmbedding(for: .english) else { return nil }
              guard let queryVector = embedding.vector(for: string) else { return nil }
      
              var answerKey: String? = nil
              var answerDistance = 2.0
      
              for (key, vectors) in self.faqEmbeddings {
                  for (vector) in vectors {
                      let distance = self.cosineDistance(vector, queryVector)
                      if (distance < answerDistance) {
                          answerDistance = distance
                          answerKey = key
                      }
                  }
              }
      
              return answerKey
          }
    • 22:19 - Sentence embedding compressed as custom embedding

      import NaturalLanguage
      import CreateML
      
      
      let embedding = try MLWordEmbedding(dictionary: sentenceVectors)
      
      try embedding.write(to: URL(fileURLWithPath: "/tmp/Verse.mlmodel"))
    • 22:47 - Finding nearest neighbor with sentence embedding and custom embedding

      func answerKeyCustom(for string: String) -> String? {
              guard let embedding = NLEmbedding.sentenceEmbedding(for: .english) else { return nil }
              guard let queryVector = embedding.vector(for: string) else { return nil }
      
              guard let (nearestLineKey, _) = self.customEmbedding.neighbors(for: queryVector, maximumCount: 1).first else { return nil }
      
              return self.poemKeyFromLineKey(nearestLineKey)
          }
    • 33:29 - WordTagger

      import CreateML
      
      let modelParameters = MLWordTagger.ModelParameters(algorithm: .crf(revision: 1))
    • 36:46 - Using custom word tagger

      func findTags(for string: String) {
              let model = try! NLModel(contentsOf: Bundle.main.url(forResource: "Nosh", withExtension: "mlmodelc")!)
              let tagger = NLTagger(tagSchemes: [NoshTags])
      
              tagger.setModels([model], forTagScheme: NoshTags)
              tagger.string = string
      
              tagger.enumerateTags(in: string.startIndex..<string.endIndex, unit: .word, scheme: NoshTags, options: .omitWhitespace) { (tag, tokenRange) -> Bool in
      
                  let name = String(string[tokenRange])
      
                  switch tag {
                      case NoshTagRestaurant:
                          self.noteRestaurant(name)
                      case NoshTagFood:
                          self.noteFood(name)
                      case NoshTagFromCity:
                          self.noteFromCity(name)
                      case NoshTagToCity:
                          self.noteToCity(name)
                      default:
                          break
                  }
                  return true
              }
          }

Developer Footer

  • Vídeos
  • WWDC20
  • Make apps smarter with Natural Language
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines