Why
Lawyers are expensive so many people upload sensitive documents (e.g. leases, NDAs, employment or contractor agreements, sale and purchase deeds, wills etc.) to Cloud AI providers. Even paid models may entail user's data to be ingested to train or improve an LLM.
My goal was to allow people to understand, question and draft responses, all while giving peace of mind their privacy was protected.
What is Privy Pilot
Privy Pilot is a privacy-absolute legal AI assistant.
Once you download the local model and upload a document, it extracts facts, flags risks and helps a user to draft responses based on their input preferred position.
By using local models to read documents, it can pull out structured risks and facts without a lawyer's input, and deterministically map them into formatted precedents based on a user's query without Cloud API risks which adheres to privacy by design.
The head-banging build
It is a native iOS app using SwiftUI and SwiftData and is powered by Apple’s MLX framework, running a 4-billion parameter Qwen3 model locally on an iPhone.
Because I am a qualified and practicing lawyer, I knew the quality of the outputs required as well as valid concerns with accuracy. In effect, I built an agentic harness around the model for contract analysis locally.
RevenueCat handles the premium subscription access required to monetise this offline contract analysis tool.
Challenges and reading 2026 academic articles for answers
On-device LLM processing of PDFs on mobile inherently presents a trade-off problem: heating up and jetsaming if I required accuracy, vs the memory given users prioritise speed.
As the operating system aggressively terminates apps using too much RAM, I spent many weekends testing processing capacity and times, as well as seeking holy grail answers through recent academic literature, learning how to optimise for KV cache, quantization (i.e. forcing constraints onto the documents or how to chunks different segments), and LoRA to save space, and MeSP to save memory.
I troubleshooted by testing creative workarounds such as background processing to notify a user once a document had finished parsing and placing a limit of <20 pages uploaded in one go and forcing users to auto-delete docs uploaded in the settings.
The Wins
Successfully deploying a multi-stage NLP app that runs entirely on-device only is a massive milestone for a first-time mobile developer.
I'm proud of building a custom scoring algorithm to evaluate evidence quality by weighting model confidence to prevent AI slop or inaccuracies. The evidence reconciler handles LLM hallucinations, ensuring conflicting facts were flagged as unresolved rather than blindly accepted by the drafting engine to reduce any risks of users being provided false information via a built in audit trail, but also that does this without putting the user to sleep.
The Lessons
Everything really, but I mainly discovered:
- that deterministic schemas combined with localised LLM yield much safer results than open-ended chat prompts;
- that the open source model itself doesn't matter so much as the technical constraints to return value, having reduced it from 8 Bit. I also learned how to troubleshoot complex Swift Package Manager dependencies like MLXLLM in Xcode.
What's next for Privy Pilot
Coming soon is creating the Google/Android equivalents, and reactivating a dormant audio pipeline using WhisperKit to transcribe live meetings that I originally started with in terms of trying to tackle the problem by reducing admin time for lawyers.
To sustain this, I will need to optimise for the premium end of market share given marketplace competitors being LocalRAG!, ChatPDF, LegalLens. All of which are different in price points, some being Freemium vs paid-only players.
Certain features were out of scope of v1.0 and because I think I would need to move to Mac platform. Moving to a desktop app then opens up way more GPU on-device that will allow for more meaningful features.
Built With
- avfoundation
- foundationdb
- grdb
- localauthentication
- mlxllm
- mlxllmcommon
- network
- pdfkit
- revenuecat
- swift
- swiftdata
- swiftui
- uikit
- uniformtypeidentifiers
- zipfoundation
Log in or sign up for Devpost to join the conversation.