Automate Your Reading List with Local LLMs
Many people save articles with the intention of reading them later, only to find their lists grow unmanageable. Even as read-it-later apps can help with organization, they don’t address the core problem: deciding which articles are worth your time. A growing solution involves using Large Language Models (LLMs) to summarize articles, allowing for quick assessment and efficient content consumption.
The Problem with Growing Reading Lists
The modern internet presents a constant stream of interesting content. Saving articles for later seems like a quality idea, but often results in an overwhelming backlog. Simply storing links doesn’t solve the problem of prioritization. The key is to quickly understand the core takeaways of each article without fully reading it.
Summarization as a Solution
Summarizing articles allows you to grasp the main points in a fraction of the time it would take to read them in full. With the increasing accessibility of LLMs, automating this process is now feasible. This approach helps you stay informed without sacrificing valuable time.
Setting Up a Local LLM Summarization Workflow
A streamlined workflow involves a plain text file containing URLs, a Python script to fetch and summarize the content, and a locally run LLM. This setup prioritizes privacy and avoids the costs associated with API access to services like ChatGPT or Claude.
Software Requirements
- Ollama: A framework for running LLMs locally. Installation can be done with the following command:
curl -fsSL https://ollama.com/install.sh | sh - Llama 3 (or other LLM): Download a local LLM model using Ollama. For example:
ollama pull llama3 - Python: Required for the summarization script.
- Requests & BeautifulSoup4: Python libraries for web scraping. Install with:
pip install requests beautifulsoup4
The Python Script
The script fetches content from URLs in a designated file, extracts the article text using BeautifulSoup, and then prompts the local LLM to generate a concise summary. Here’s the code:
import requests from bs4 import BeautifulSoup from datetime import date OLLAMA_URL = "http://localhost:11434/api/generate" MODEL = "llama3" READING_LIST = "reading_list.txt" OUTPUT_FILE = f"digest_{date.today()}.txt" def fetch_article_text(url): strive: r = requests.get(url, timeout=15, headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"}) soup = BeautifulSoup(r.text, "html.parser") for tag in soup(["script", "style", "nav", "footer", "header"]): tag.decompose() return soup.get_text(separator=" ", strip=True)[:8000] except: return None def summarize(text): prompt = f"Summarize the following article in 3-5 sentences. Be concise and focus on the key points:n{text}" r = requests.post(OLLAMA_URL, json={"model": MODEL, "prompt": prompt, "stream": False}) return r.json().get("response", "").strip() with open(READING_LIST) as f: urls = [line.strip() for line in f if line.strip()] with open(OUTPUT_FILE, "w") as out: for url in urls: text = fetch_article_text(url) summary = summarize(text) if text else "Could not fetch article." out.write(f"## {url}n{summary}n---n") open(READING_LIST, "w").close() # Clear the list when done
The script limits articles to the first 8,000 characters. The summaries are saved to a file named digest_YYYY-MM-DD.txt.
Automation with Cron
To automate the process, a cron job can be scheduled to run the script daily. For example, to run the script at 2 AM, add the following line to your crontab:
0 2 * * * cd /path/to/scripts && python3 summarize.py
Benefits and Limitations
This workflow significantly improves content consumption by prioritizing articles based on summaries. While not a perfect solution – LLMs may occasionally miss key details, and some websites may be challenging to scrape – it offers a substantial improvement over simply accumulating unread links. It’s a valuable tool for anyone overwhelmed by the sheer volume of information available online.
Keep reading