You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/WWDCNotes/WWDCNotes.docc/WWDC25/WWDC25-248-Explore-prompt-design-and-safety-for-ondevice-foundation-models.md
+152-4Lines changed: 152 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,159 @@ Design generative AI experiences that leverage the strengths of the Foundation M
8
8
@CallToAction(url: "https://developer.apple.com/videos/play/wwdc2025/248", purpose: link, label: "Watch Video (22 min)")
9
9
10
10
@Contributors {
11
-
@GitHubUser(<replacethiswithyourGitHubhandle>)
11
+
@GitHubUser(terlan98)
12
12
}
13
13
}
14
14
15
-
😱 "No Overview Available!"
15
+
## Key Takeaways
16
16
17
-
Be the hero to change that by watching the video and providing notes! It's super easy:
> Note: Errors occurring in **proactive features**, not driven by user actions, are safe to ignore. However, any errors originating from **user-initiated features** should show suitable UI feedback to the user.
96
+
97
+
### Build trust and safety
98
+
- Disallow inappropriate content
99
+
- Handle user input with care
100
+
- Evaluate potential consequences of users acting on your app's output
101
+
102
+
### Add safety instructions
103
+
@Row {
104
+
@Column {}
105
+
@Column(size: 2) {
106
+
@Image(source: "WWDC25-248-Safety-Instructions")
107
+
}
108
+
@Column {}
109
+
}
110
+
111
+
> Important: Instructions should only come from you as the developer. Never include untrusted user content in your instructions.
112
+
113
+
### User input handling patterns
114
+
- Direct user input (high flexibility, high risk)
115
+
```swift
116
+
let prompt = userInput
117
+
```
118
+
- Combined prompts (balanced approach)
119
+
```swift
120
+
let prompt ="Generate a story about \(userInput)"
121
+
```
122
+
- Curated prompts (low flexibility, low risk)
123
+
```swift
124
+
enumTopic: String{
125
+
caseadventure="an adventure in an ancient forest"
126
+
casefantasy="a fantasy on an uninhibited island"
127
+
}
128
+
129
+
let topic: Topic = .adventure
130
+
let prompt ="Generate a story about \(topic.rawValue)"
131
+
```
132
+
133
+
### Use case-specific mitigations
134
+
Consider the real-world impact of the generated content in your app. Here are some examples:
135
+
- Bagel flavor generation app
136
+
- Show an allergen warning
137
+
- Add the ability to disable some ingredients in app settings
138
+
- Trivia generation app
139
+
- Use denying keywords in your instructions to avoid controversial political topics or inappropriate content
140
+
- Train a classifier for more reliable outputs
141
+
142
+
### Layering-based approach
143
+
The aforementioned safety recommendations act as multiple layers. Each layer has its weaknesses but when stacked together, the chances of a safety violation passing through all of them is very low.
144
+
145
+
@Row {
146
+
@Column {}
147
+
@Column {
148
+
@Image(source:"WWDC25-248-Layers")
149
+
}
150
+
@Column {}
151
+
}
152
+
153
+
## Evaluate and test
154
+
- Curate a dataset with prompts for all use cases and safety issues
155
+
- Create automated tests with manual checks
156
+
- Use another LLM to grade responses
157
+
- Test failure scenarios with safety violations to see how your app behaves
158
+
159
+
The model will be updated continuously. Make sure to report any safety issues you encounter.
0 commit comments