Skip to content

Repository files navigation

📄 Pharma Document Intelligence System

AI-powered document Q&A for pharma professionals. Upload any pharma PDF and ask questions in plain English — get instant answers with exact page references.


🎯 What It Does

Medical Affairs and HEOR professionals spend hours manually searching through dense pharma documents. This tool does it in seconds.

Upload any document → ask questions → get:

  • Direct answers from the document
  • Exact page number references
  • Source text preview for verification
  • Downloadable Q&A session report

🛠️ Built With

Tool Purpose
Python Core language
scikit-learn (TF-IDF + cosine similarity) Lexical search and retrieval
Claude API (Anthropic) AI answer generation
PyMuPDF PDF text extraction
Streamlit Web interface

Why lexical search, not embeddings?

Retrieval here is lexical (TF-IDF over unigrams and bigrams, ranked by cosine similarity), not semantic. There is no embedding model, no vector database, and no LangChain.

That started as a constraint: sentence-transformers/torch would not cooperate on Python 3.14. But it turned out to suit the problem. Pharma questions hinge on exact terms — EGFR, ALK, TPS ≥50%, a specific dose. Semantic search is built to find text that means roughly the same thing, which on a drug label is how you get a confident answer about the wrong threshold. Lexical search matches the term or returns nothing, and "nothing" is the safer failure here.

Trade-off, stated honestly: this will not find a passage that paraphrases your question without sharing its vocabulary. For long, well-structured regulatory documents where terminology is standardised, that is a good trade. For fuzzy multi-document discovery, it is not. This has not been benchmarked against an embedding baseline.


📁 Project Structure

├── document_loader.py   # PDF loading and chunking
├── vector_store.py      # TF-IDF vector search
├── rag_chain.py         # RAG pipeline
├── llm_response.py      # Claude AI integration
├── streamlit_app.py     # Streamlit web interface
├── requirements.txt     # Python dependencies
└── .env.example         # API key template

🚀 Quick Start

1. Clone the repo

git clone https://github.com/LifeSciForge/Pharma_Document_Intelligence.git
cd Pharma_Document_Intelligence

2. Create virtual environment

python3 -m venv venv
source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Add your API key

cp .env.example .env
# Edit .env and add your Anthropic API key

5. Run the app

streamlit run streamlit_app.py

💡 Example Documents to Try

Document Source Use Case
Keytruda FDA label FDA.gov Drug contraindications, dosing
Ozempic FDA label FDA.gov Diabetes/obesity evidence
NCCN Guidelines NCCN.org Treatment algorithms
Clinical trial report PubMed Endpoint results

🎯 Target Users

  • Medical Affairs — rapid evidence lookup
  • HEOR — endpoint and outcomes extraction
  • Regulatory Affairs — guideline and SOP queries
  • MSL — pre-call document preparation

🔑 API Key Setup

Get your free key at console.anthropic.com

Add to .env:

ANTHROPIC_API_KEY=your_key_here

App runs in placeholder mode without API key — document search still works, AI synthesis activates with key.


👤 Author

Pranjal Das AI & Automation for Life Sciences github.com/LifeSciForge

About

AI-powered pharma document Q&A — upload any FDA label, trial report, or guideline and ask questions with exact page references. Built with RAG, LangChain, and Claude AI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages