Skip to content

hapi-ds/mPAPA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

mPAPA β€” my Personal Artificial Patent Attorney

Latest Release Python Version License

CI Pipeline Status Coverage

Your invention. Your machine. Your patent. Zero data leaks.


Stop uploading your billion-dollar idea to ChatGPT's servers. Stop waiting weeks for a first draft.

mPAPA is a fully local AI patent drafting system. It runs on YOUR machine*. Your invention data never touches the internet. Ever.

*Any recent PC will do. Just 6 GB+ (V)RAM for LLM. GPU optional (but strongly recommended). Works great with models like Gemma-4-E2B.


What it does in 30 minutes flat:

πŸ” Searches 5 patent/paper databases simultaneously β€” EPO, Google Patents, Google Scholar, ArXiv, PubMed. 100+ references collected and analyzed automatically.

πŸ’¬ AI Chat over your entire research β€” Ask questions, explore prior art, refine your claims. RAG-powered, context-aware, backed by every reference you've collected.

⚑ 9-step AI workflow generates your complete patent draft:

  1. Invention disclosure review
  2. Claims drafting (European patent format)
  3. Prior art landscape analysis
  4. Novelty assessment
  5. Consistency review
  6. Market potential analysis
  7. Legal & IP clarification
  8. Disclosure summary
  9. Full patent specification

Every step: AI generates β†’ you review β†’ you edit β†’ you continue. Full control. Full transparency.

πŸ“„ Export to DOCX β€” Professional formatting, proper styles, header/footer, ready for your attorney.

🎭 Agent Personality Modes β€” Not every step needs the same attitude. Switch between Critical (skeptical, no sugarcoating), Neutral (balanced, just the facts), and Innovation-Friendly (opportunity-focused, constructive). Novelty analysis tears your claims apart by default. Disclosure keeps it open-minded. You set the tone per agent, per topic β€” because a patent draft needs a devil's advocate, not a cheerleader.

Everything persisted locally in SQLite β€” per topic, per step, per setting. Close the browser, shut down your machine, come back in a week. Your entire workflow, research, drafts, and agent configurations are exactly where you left them.


Why mPAPA destroys the alternatives:

mPAPA ChatGPT / Claude Patent Attorney
Data privacy 100% local Your IP on their servers NDA required
Cost Free / Open Source $20-200/month $5,000-50,000
Speed 30 minutes Hours of prompting 2-8 weeks
Prior art search 5 sources, automated Manual, one at a time Manual, expensive
Structured workflow 9-step guided process Unstructured chat Black box
Editable at every step Yes Start over Revision rounds
Works offline Yes No No

The tech that makes it possible:

9 specialized AI agents work together in a coordinated pipeline β€” each one focused on a single task (disclosure analysis, claims drafting, novelty assessment, consistency review, …). They share context through a structured state graph, so every agent builds on what the previous ones discovered.

  • LM Studio β€” Run any open-source LLM locally. Llama, Qwen, Mistral. Your choice.
  • LangGraph β€” Multi-step AI workflows with human-in-the-loop review at every stage.
  • DSPy β€” Structured, optimizable prompts. Not fragile prompt strings.
  • LlamaIndex β€” RAG over your entire reference collection. Local embeddings.
  • NiceGUI β€” Clean web interface. No Electron bloat. No cloud dependency.
  • SQLite β€” Everything persisted. Close the app, reopen tomorrow, pick up where you left off.

Who is this for?

  • Independent inventors who can't afford $15K for a patent application
  • Startup founders who need to file fast before competitors
  • R&D engineers who want a solid first draft before engaging counsel
  • Patent professionals who want AI assistance without data privacy risks
  • Academic researchers exploring patentability of their work

Installation


Option A: Windows Executable ❌ (Currently Unavailable)

Why we don't provide an .exe file:

We've decided to temporarily discontinue providing Windows executables. Here's why:

  • False virus warnings: Windows Defender and other antivirus software flag Python-packaged executables as malicious, even though they're completely safe. This creates unnecessary concern and a poor user experience.
  • Build reliability issues: The automated exe build process is unstable, takes over 2 hours, and occasionally produces inconsistent results.
  • Trust and transparency: We believe you shouldn't have to blindly trust an executable file. Running from source lets you see exactly what you're running.

Good news: With modern Python tooling, running from source is nearly as simple as double-clicking an exe! See Option B below.


Option B: Run from Source (Recommended) ✨

The reliable, transparent, and surprisingly easy way to run mPAPA.

  1. Install uv (a fast Python package manager) - takes 30 seconds β†’ uv getting started
  2. Download the source code or clone with git: git clone https://github.com/OWNER/REPO.git
  3. Copy .env.example to .env and adjust settings if needed
  4. Run uv run mpapa (the first time it downloads all needed libraries automatically)
  5. Open http://localhost:8080 in your browser

Why this is actually better than an exe:

  • βœ… No antivirus warnings or security concerns
  • βœ… Smaller download size
  • βœ… Always up-to-date dependencies
  • βœ… Full transparency - inspect any part of the code
  • βœ… Easier to update and modify

On first launch, mPAPA automatically creates data/ and logs/ folders.


Setting Up LM Studio

mPAPA needs a local LLM running via LM Studio. Here's how to get it going:

1. Install LM Studio

  • Download from lmstudio.ai (Windows, macOS, Linux)
  • Run the installer β€” no special configuration needed

2. Download a model

Open LM Studio and search for a model in the Discover tab. Recommended options for small machines:

Model Size Notes
Gemma 3 4B ~3 GB Fast, good quality, runs on most machines
Qwen 2.5 7B ~5 GB Strong reasoning, good for patent language
Llama 3.1 8B ~5 GB Well-rounded, widely tested
Mistral 7B ~4 GB Good balance of speed and quality

Pick one that fits your RAM. 8 GB system RAM is enough for 4B models, 16 GB for 7-8B models. A GPU speeds things up but isn't required (but strongly recommended).

3. Download an embedding model

In LM Studio's Discover tab, also search for and download an embedding model:

  • nomic-embed-text-v1.5 (~270 MB) or any other "embed" model

4. Start the local server

  • Go to the Developer tab in LM Studio
  • Load your chosen chat model
  • Load the embedding model
  • Click Start Server
  • The server runs at http://localhost:1234/v1 by default β€” this matches mPAPA's default config

That's it. Leave LM Studio running and start mPAPA.

Tip: If you change the LM Studio port or URL, update PATENT_LM_STUDIO_BASE_URL in your .env file.


Usage

  1. Create a new topic in the left sidebar
  2. Insert your patent idea and some search terms
  3. Add your local reference resources/papers/patents
  4. Start search - reference patents and other literature will be downloaded and a RAG database is build
  5. Chat with AI - ask for better key words, first patent idea improvements and refine/repeat from step 2 - al based on found references and your input
  6. Click "Generate Patent Draft" to start the agent workflow
  7. The system walks through disclosure, search, analysis, drafting, and review
  8. Edit claims and description in the expandable editors
  9. Change and re-run as you like
  10. Export to DOCX when ready

You can make a break whenever you want - all results are saved to a local db and are recalled when you select a topic.

Tip: You can easily change the appearance of the export by customising the template in ./src/export/templates.

Configuration

All settings are managed via environment variables with the PATENT_ prefix, or a .env file in the project root. See .env.example for all available options.

Running Tests

uv run pytest -q

Project Structure

src/patent_system/
β”œβ”€β”€ main.py              # App entry point
β”œβ”€β”€ config.py            # Pydantic Settings
β”œβ”€β”€ logging_config.py    # Structured JSON logging
β”œβ”€β”€ exceptions.py        # Custom exception hierarchy
β”œβ”€β”€ db/                  # SQLite schema, models, repositories
β”œβ”€β”€ agents/              # LangGraph workflow and agent nodes
β”œβ”€β”€ dspy_modules/        # DSPy signatures and module wrappers
β”œβ”€β”€ rag/                 # Embedding service, RAG engine, citation graph
β”œβ”€β”€ parsers/             # Source-specific parsers (DEPATISnet, ArXiv, etc.)
β”œβ”€β”€ export/              # DOCX exporter with template support
β”œβ”€β”€ monitoring/          # Background prior art monitoring scheduler
└── gui/                 # NiceGUI web interface panels

Troubleshooting

πŸ”΄ Errors during "Prior Art Search"

Getting crashes or errors when the agent tries to analyze your collected references? Your LLM's context window is probably too small.

Fix: In LM Studio's Developer tab β†’ Model settings β†’ Crank Context Length to maximum (usually 32768, 40960, or even 262144 and more depending on your model). Prior art analysis needs to juggle multiple patent abstracts at once β€” give it room to breathe.

🐌 Agent stuck "thinking" forever

If the AI agent seems frozen in eternal contemplation (spinning wheel of death, no output for minutes), you're probably running on CPU only.

Fix: In LM Studio's Developer tab β†’ Model settings β†’ Check GPU Offload. If it's set to 0, you're not using your GPU at all. Bump it up β€” start with 50% of your model's layers, adjust from there. No GPU? Consider a smaller model (4B instead of 7B) or accept that patent drafting just became your new meditation practice.

Pro tip: Watch LM Studio's performance metrics while mPAPA runs. If you see 100% CPU and 0% GPU usage, that's your problem right there.

License

See LICENSE.


mPAPA β€” because your invention is too valuable to upload to someone else's server.

Built by koehler. Open source. Local first. Always.

About

my Personal Artificial Patent Agent - Full local 9-step AI workflow generates your complete patent prior art search/novelty&market potential analysis/full patent draft

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages