A beautiful, locally-hosted patent analysis and Q&A application built with Streamlit and Ollama. Upload patent links from Excel, download full documents, auto-summarize them, and chat with individual patents using retrieval-augmented generation (RAG).
- 📊 Excel Batch Ingestion: Upload an Excel file with a list of patent URLs (requires
urlcolumn) - 📥 Auto-Download & Extract: Automatically fetch PDF documents from patent links and extract full text
- ✨ AI Summarization: Generate concise patent summaries using local Ollama LLM (supports any Ollama model)
- 💬 Patent Q&A Chat: Ask questions about individual patents; responses are grounded in the patent text using semantic retrieval
- 📁 Local Storage: All downloaded PDFs, extracted text, and indexes stored locally in
data/patents/folder - ⬇️ Export Options: Download summaries as CSV or all PDFs as ZIP archive
- 🎨 Beautiful UI: Modern gradient background, top navigation, tabbed patent workspace
- 🔄 Patent Switching: Easy dropdown navigation between processed patents
- 🚫 No Sidebar: Clean interface with top navigation bar and prominent back button
Patent Summarizer/
├── app.py # Main Streamlit app (upload, process, view results)
├── functions.py # Core utilities (download, extract, summarize, chat, retrieval)
├── pages/
│ └── patent_viewer.py # Patent workspace (PDF, Summary, Chat tabs)
├── .streamlit/
│ └── config.toml # Streamlit configuration
├── data/
│ └── patents/ # Local storage for processed patents
│ └── pat_[hash]/ # Per-patent folder
│ ├── document.pdf
│ ├── document.txt
│ ├── summary.txt
│ ├── chunks.json
│ └── index.json
├── requirements.txt # Python dependencies
└── README.md # This file
- Python 3.9+ (this project uses 3.13.12)
- Ollama installed and running locally on
localhost:11434- Download from: https://ollama.ai
- Default model:
llama3:8b(see configuration below)
-
Clone the repository:
git clone <repo-url> cd "Patent Summarizer"
-
Create and activate a Python virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure Ollama (optional):
- The app uses
llama3:8bby default - To use a different model, change the default in the UI or modify
functions.py - Ensure your chosen model is pulled:
ollama pull <model-name>
- The app uses
-
Start Ollama (in a separate terminal):
ollama serve
-
Run the app:
streamlit run app.py
The app will open at
http://localhost:8501
- Go to the main Patent Studio page
- Upload an Excel file with a
urlcolumn containing patent links - (Optional) Change Ollama model name
- (Optional) Check "Reprocess existing" to re-download/re-summarize existing patents
- Click Process Patents
Example Excel structure:
| url |
|--------------------------------------------------|
| https://patents.google.com/patent/US10000001B2 |
| https://patents.google.com/patent/US10000002B2 |
- ✅ Successful patents appear in the "Processed Patents" list with status (cached/done)
- ❌ Failed URLs are shown in the "Failed URLs" table with error messages
- Download summaries as CSV or all PDFs as ZIP
- Click Open next to any patent in the list
- In the patent workspace, use the top navigation dropdown to switch between patents
- Three tabs available:
- PDF: View the full patent document
- Summary: Read the AI-generated summary
- Chat: Ask questions about the patent
- Go to the Chat tab
- Type a question (e.g., "What problem does this patent solve?")
- The system retrieves relevant patent excerpts and uses Ollama to generate an answer
- You can expand "Retrieved context" to see which excerpts were used
- Click Clear chat to reset conversation for the current patent
Excel Upload
↓
URL Normalization & Deduplication
↓
Patent Link Extraction (Selenium)
↓
PDF Download & Local Storage
↓
Text Extraction (PyMuPDF)
↓
AI Summarization (Ollama)
↓
Persistent Local Artifacts
User Question
↓
Text Chunking (with overlap)
↓
Sparse Vector Embedding (token-based)
↓
Semantic Retrieval (top-4 chunks)
↓
Prompt Composition (system + context + history)
↓
Ollama LLM Response
download_pdf(url, filename)- Download PDF from URLextract_text(pdf_path)- Extract text using PyMuPDFsummarize_text(text, model)- Generate summary via Ollamachunk_text(text, chunk_size, overlap)- Split text into overlapping chunksensure_retrieval_index(text, index_path, chunks_path)- Build or load semantic indexretrieve_chunks(question, chunks, embeddings, top_k)- Find relevant chunkschat_with_patent(question, patent_text, ...)- Full RAG chat flowget_pdf_link(url)- Extract PDF link from patent page (Selenium)
check_ollama()- Health check for Ollama connectivityparse_urls_from_excel(file_obj)- Validate and normalize Excel inputprocess_patent_url(url, model_name, force_reprocess)- Single patent pipelinecreate_pdf_zip(results)- Export PDFs as ZIP
- Top navigation (back button, patent dropdown, model selector)
- PDF viewing (native Streamlit PDF viewer)
- Summary display
- Chat interface with per-patent history
Change the default model in the UI on the main page, or modify in functions.py:
def summarize_text(text, model="llama3:8b"): # Change here
...Available models: https://ollama.ai/library
[client]
toolbarMode = "minimal"This hides the Streamlit toolbar and Deploy button for a cleaner UI.
- Summarization:
temperature=0.1(factual, concise) - Chat:
temperature=0.0(precise Q&A),top_p=0.85(focused output)
All artifacts are stored in data/patents/{patent_id}/:
document.pdf- Original PDF filedocument.txt- Extracted patent textsummary.txt- AI-generated summarychunks.json- Text chunks for retrievalindex.json- Sparse vector embeddingsmetadata.json- Processing metadata (if added in future)
Patent IDs are deterministic (SHA1 hash of URL), so re-running with the same patents reuses cached artifacts.
- Ensure Ollama is running:
ollama servein a separate terminal - Check it's accessible:
curl http://localhost:11434/api/tags
- Make sure your uploaded Excel file has a column named exactly
url - Whitespace and case-sensitivity matter
- Refresh the page (Ctrl+R or Cmd+R)
- Check that the PDF file exists locally in
data/patents/{patent_id}/document.pdf
- Ollama inference takes time (depends on model size and hardware)
- Look for the "Thinking over patent context..." spinner
- Consider using a smaller/faster model if available
- This should not happen with the latest build
- If it does, clear browser cache or hard refresh (Ctrl+Shift+R)
| Package | Purpose |
|---|---|
streamlit |
Web UI framework |
streamlit[pdf] |
PDF rendering component |
pandas |
Excel/CSV data handling |
requests |
HTTP downloads |
pymupdf |
PDF text extraction |
openpyxl |
Excel backend |
selenium |
Browser automation for link extraction |
- Patent Link Extraction: Selenium-based scraping is fragile; some patent sites may block or change structure
- Sparse Embeddings: Uses token-overlap similarity, not semantic embeddings (no ML model needed locally, but less accurate than dense embeddings)
- Single-User: No authentication; designed for local/personal use
- No Database: Relies on file storage; metadata not indexed
- Token Limits: Very large patents may exceed Ollama's context window
- Support for dense embeddings (sentence-transformers)
- Patent database/SQLite storage for metadata queries
- Batch comparison across multiple patents
- Export chat conversations
- Multi-user authentication
- Cloud Ollama support
- REST API for programmatic access
[Specify your license here, e.g., MIT, Apache 2.0]
Contributions welcome! Please:
- Test locally before submitting
- Follow PEP 8 style guidelines
- Update README for new features
- Add error handling and validation
For issues or questions:
- Check the Troubleshooting section
- Review Ollama docs: https://ollama.ai/docs
- Check Streamlit docs: https://docs.streamlit.io
PROPERTY CAN BE INTELLECTUAL, DIGITAL OR PHYSICAL PROPERTY. INTELLECTUAL PROPERTY IS CREATION OF MIND. AS PER OUR CURRENT (2026 CE)) LIMITED KNOWLEDGE OF UNIVERSE INTELLECTUAL PROPERTY SEPARATES HUMANS FROM NON HUMAN ANIMALS BECAUSE ANIMALS ONLY EAT, SLEEP, PLAY, FIGHT, REPRODUCE & DIE BUT HUMANS ARE MORE CONCIOUS THEN MOST ANIMALS THEY SEE VARIAOUS PROBLEMS THEY TRY TO SOLVE IT USING MIND. IDENATIFY PATTERNS OR ALSO SATISFY THEIR CURIOSITY.
BY THIS LOGIC INTELLECTUAL PROPERTY IS MORE IMPORTANT THEN PHYSICAL PROPERTY AND IT I THE BAISIS OF DIGITAL & PHYSICAL PREOPRTY. LIKE AC & MOTOR IS CREATETION OF MND & EFFORT OF MICHAEL FARADAY & TESLA.
Built with ❤️ using Streamlit + Ollama