On-device or cloud
Apple Intelligence runs a language model on the device itself, which apps reach through Apple's Foundation Models framework in Swift. Pythilo's Python cannot call that model yet, so this course practises the ideas with small stand-in models written in Python.
The two kinds of model trade different things:
- On the device: private, free, works offline, but small. Its context window is about 4,096 tokens, and it is good at summarising, extracting and classifying, not at knowing facts about the world.
- In the cloud: larger and more knowledgeable, but it needs a network, costs money, and the text leaves the device.
An app decides per request, and privacy comes first: private text never goes to the cloud, even when the device model cannot handle it.
def where(private, online):
if private or not online:
return "device"
return "cloud"
print(where(True, True))
print(where(False, True))Your task
Write route(request) for a dict with tokens (int) and optional private, online and needs_knowledge (defaults False, True, False). A request fits the device when tokens <= DEVICE_LIMIT (3000). Private or offline requests return "device" if they fit, else "refuse"; the others return "cloud" when they need knowledge or do not fit, else "device".
The explanation opens here once every check passes.