Lesson 3 / 8
Module 2Lesson 3⏱ 45 min study

Personal Context Grounding, Semantic Indexing & App Intents

Understand how on-device semantic indexes ground LLMs in personal context, deconstruct the App Intents action framework, and explore screen-aware agentic orchestration.

✦ Key Architectural Takeaways
  • •Semantic Indexing transforms on-device emails, messages, photos, calendar events, and notes into localized vector embeddings for rapid contextual retrieval
  • •The App Intents framework allows language models to invoke native Swift functions and execute actions inside third-party applications safely
  • •Screen Awareness allows Siri to parse on-screen content (flight receipts, PDFs, chat messages) without requiring users to copy-paste data
  • •On-device acoustic modeling and conversational state management maintain context across speech pauses, self-corrections, and multi-turn dialogues

## Grounded Intelligence: Connecting Models to Personal Reality

Generic AI chatbots know vast amounts of general facts about the universe, but know virtually nothing about you: they do not know when your mother's flight lands, what hotel you booked for next weekend, or where you parked your car.

Apple Intelligence bridges this divide through Personal Context Grounding, allowing the on-device model to act as an intimate executive assistant while keeping all personal data confined to device storage.

§

1. The Semantic Index: Vector Retrieval on Edge Storage

To allow a 3B language model to find relevant context without scanning gigabytes of SQLite databases on every query, the operating system continuously maintains an on-device Semantic Index:

TEXTSYSTEM SCHEMATIC
  INCOMING PERSONAL DATA:
  [ Email: "Flight AA1204 lands at 4:15 PM" ]   [ iMessage: "Lunch at 1 PM tomorrow" ]
                         |                                         |
                         +--------------------+--------------------+
                                              |
                                              v
                              [ On-Device Embedding Engine ]
                              (Converts text/images into 512-dim vectors)
                                              |
                                              v
                              +---------------------------------+
                              | ON-DEVICE VECTOR DATABASE       |
                              | - Apple Neural Engine indexed   |
                              | - HNSW / Vector similarity tree |
                              | - Fully encrypted at rest       |
                              +---------------------------------+
                                              ^
                                              | Vector Semantic Search
  User asks: "When should I leave to pick up mom?"

Retrieval Pipeline in Action

  1. 1Query Embedding: The user's query is converted into a vector representation by the on-device embedding model.
  2. 2K-Nearest Neighbors Search: The vector engine queries the local index and retrieves the relevant flight email and calendar entry in under 15 milliseconds.
  3. 3Prompt Augmentation: The retrieved snippets are injected into the foundation model's context window along with real-time GPS traffic data.
  4. 4Grounded Answer: "Her flight lands at 4:15 PM. Traffic on I-95 is heavy; you should leave by 3:25 PM."
§

2. The App Intents Framework: Function Calling for Apps

An AI assistant that can only chat is of limited utility; true agentic power requires the ability to take actions across apps. Apple Intelligence achieves this through the App Intents framework:

TEXTSYSTEM SCHEMATIC
                       [ User: "Send the photos from yesterday to Sarah" ]
                                                |
                                                v
                             [ Siri / Foundation Model Core ]
                                                |
                            Deconstructs into structured intent:
                            - Action: AppIntent<SharePhotosIntent>
                            - Parameters: { filter: "yesterday", recipient: "Sarah" }
                                                |
                                                v
                             +-------------------------------------+
                             | APP INTENTS TOOL REGISTRY           |
                             |                                     |
                             | [ Photos App Intent ]               |
                             |   -> fetchPhotos(filter: .yesterday)|
                             |                                     |
                             | [ Messages App Intent ]             |
                             |   -> sendMessage(to: "Sarah",       |
                             |                  attachments: items)|
                             +-------------------------------------+

Swift AppIntent Example

Developers expose capabilities to the model by declaring strongly-typed Swift structures:

SWIFTSYSTEM SCHEMATIC
import AppIntents

struct SendDraftEmailIntent: AppIntent {
    static var title: LocalizedStringResource = "Send Draft Email"
    static var description = IntentDescription("Sends an email draft to specified recipients.")

    @Parameter(title: "Recipient Email")
    var recipient: String

    @Parameter(title: "Email Body")
    var body: String

    @MainActor
    func perform() async throws -> some IntentResult {
        let mailer = MailService.shared
        try await mailer.dispatch(to: recipient, content: body)
        return .result(dialog: "Your email has been sent successfully.")
    }
}
§

3. Screen Awareness & Conversational Resilience

Next-generation Siri incorporates on-screen visual perception:

  • If a friend texts you an address in WhatsApp, you can simply activate Siri and say, "Add this to their contact card." Siri parses the screen's accessibility tree and visual layout, extracts the street address, and writes it directly to the Contacts database.
  • Conversational Repair: Siri handles human speech imperfections, such as stuttering and mid-sentence corrections:

"Siri, set an alarm for 7 AM... no wait, make that 7:30 AM for my workout." The acoustic model updates its parsing token stream dynamically without failing or creating two duplicate alarms.