A powerful Streamlit-based application that uses LangChain and Ollama to generate intelligent summaries from multiple document formats. Upload documents, provide custom instructions, and get professionally formatted summaries tailored to your needs.
- Multi-Format Support: Load and process PDF, DOCX, PPTX, TXT, and HTML documents
- Custom Instructions: Control summarization style through natural language (e.g., "Teach this to a beginner", "Extract key financial risks")
- Multiple Summarization Methods:
- Stuff: Fast, for smaller documents
- Map Reduce: Scalable, processes large documents in chunks
- Refine: Iterative refinement for comprehensive summaries
- Chat Interface: Interactive conversation-style interface with chat history
- Real-time Processing: Live feedback during document loading and summarization
- Clean Markdown Output: Professionally formatted summaries with headers, bullets, and tables
- Python 3.10 or higher
- Ollama installed and running locally
- A compatible Ollama model (default:
mistral-large-3:675b-cloud)
-
Clone or navigate to the project directory:
cd /path/to/summarization -
Install dependencies using
uv(recommended):uv sync
Or with pip:
pip install -r requirements.txt
-
Ensure Ollama is running:
ollama serve
-
Pull your desired model (if not already available):
ollama pull mistral-large-3:675b-cloud # Or use another model like: # ollama pull llama3 # ollama pull mistral
uv run streamlit run main.pyOr with standard Python:
streamlit run main.pyThe app will open in your browser at http://localhost:8501.
- Ollama Model: Enter the model name (default:
mistral-large-3:675b-cloud) - Method: Choose summarization approach:
Stuff- Best for documents under ~4000 tokensMap Reduce- Best for large documentsRefine- Best for iterative, comprehensive summaries
- Click "Upload Files" in the sidebar
- Select one or more documents (PDF, DOCX, PPTX, TXT, or HTML)
- Click "Process Documents"
- Wait for confirmation: "Ready! Loaded X chunks."
- Type your instruction in the chat input (examples below)
- Press Enter
- View the formatted summary in the chat area
"Summarize the main points in bullet format""Teach this material to a Year 2 nursing student""Extract financial risks and present in a table""Give me a 3-paragraph executive summary""Explain this like I'm 10 years old"
summarization/
├── main.py # Streamlit UI and chat interface
├── loaders.py # Document loading logic for all formats
├── summarizer.py # LLM and summarization chain logic
├── utils.py # Logging utilities
├── pyproject.toml # Project dependencies (uv/pip)
├── README.md # This file
└── .venv/ # Virtual environment (auto-created)
- langchain (0.3.14): LLM orchestration framework
- langchain-community (0.3.14): Community loaders and tools
- langchain-ollama: Ollama integration for LangChain
- langchain-text-splitters: Text chunking utilities
- streamlit: Web UI framework
- pypdf: PDF parsing
- python-docx: DOCX parsing
- python-pptx: PowerPoint parsing
- beautifulsoup4 + lxml: HTML parsing
- docx2txt: Additional DOCX support
-
Document Loading (
loaders.py):- Files are saved to a temporary directory
- Appropriate loader selected based on file extension
- Documents converted to LangChain
Documentobjects
-
Text Splitting (
summarizer.py):- Documents split into manageable chunks (default: 2000 chars, 200 overlap)
- Preserves context across chunk boundaries
-
Summarization:
- User instruction combined with formatting directive
- Chain selected based on method (Stuff/Map Reduce/Refine)
- LLM generates summary following instructions
- Output extracted and formatted for display
-
Chat Interface (
main.py):- Session state maintains document chunks and chat history
- Real-time streaming and status updates
- Clean Markdown rendering
Edit main.py or summarizer.py:
model_name = st.text_input("Ollama Model", value="llama3") # Change here based on the ollama model you pulledEdit summarizer.py:
def split_documents(documents, chunk_size=3000, chunk_overlap=300): # You can adjust here depending on your interest Edit the prompt templates in summarizer.py to customize how the LLM processes documents.
"No module named 'langchain.chains'"
- Ensure
langchain==0.3.14is installed (not 1.2.0) - Run:
uv syncor reinstall dependencies
"Connection refused to Ollama"
- Make sure Ollama is running:
ollama serve - Check Ollama is on default port
11434
"Model not found"
- Pull the model:
ollama pull mistral-large-3:675b-cloud - Or change to an available model in the sidebar
Slow summarization
- Use a smaller/faster model (e.g.,
mistralinstead ofmistral-large-3) - Reduce chunk size or use "Stuff" method for smaller docs
This project is provided as-is for educational and personal use.
Contributions welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
For issues or questions, please open an issue in the repository.
Built with ❤️ using LangChain, Streamlit, and Ollama