Skip to content

jackcook/predictive-spy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Predictive Spy 🕵️

Code accompanying my blogpost, “A look at Apple’s new Transformer-powered predictive text model.” With this repository, you can snoop on activity from the new predictive text model in macOS Sonoma.

Note: At some point this summer, Apple removed the ability to spy on model predictions at some point, but I’m not sure which beta they did this in. I can confirm it works in macOS Sonoma beta 1, but not in beta 7.

Demo snooping on predictive text model predictions

Introduction

This repository has two scripts:

  • get_tokens.py: Generates a vocabulary file from the predictive text model
  • app.py: Spies on predictive text model activity

Both scripts only work on macOS Sonoma (14), neither will work on macOS Ventura (13) or earlier. If you’re just interested in getting the vocabulary file, you don’t need to follow any of the setup instructions.

Spying Setup

Note: I tested these instructions most recently on a virtual machine in Parallels, but these instructions should also work on a real machine. If you need to install a VM, I found a link to a macOS Sonoma beta 1 IPSW here.

Disable SIP

Follow this guide to disable system integrity protection. You’ll need to boot into recovery mode, run a command, and then reboot. If you’re doing this on a real machine, don’t forget to re-enable SIP once you’re done :-)

Install Command Line Tools

Usually, you should be able to install command line tools with the following command:

xcode-select --install

However, I had trouble doing this in my VM, so I downloaded the most recent Command Line Tools package from the Apple Developer website.

Install fq

To install fq, you can follow the instructions in their README, or install with Homebrew:

brew install wader/tap/fq

Install dependencies

pip3 install -r requirements.txt

Usage

Once everything is set up, you should be able to run it with sudo:

sudo python3 app.py

You may see the following error:

Failed to spawn: unable to find a process with name 'AppleSpell'

This is because AppleSpell needs to be running when you start the command. In order to ensure this is the case, open the Notes app (or any other app with a text field) and start typing, then try starting the script again.

License

predictive-spy is available under the MIT license. See the LICENSE file for more details.