appendix-b

appendix B  LLM-powered summarization

 

In appendix A, we added /search, giving the newsreader the ability to find articles by using fuzzy search with vectors instead of relying solely on keywords. The key infrastructure for that was Qdrant, a vector database that stores high-dimensional representations of each article, and Ollama, a local model server running nomic-embed-text to convert article text into those vectors. But returning a ranked list of article titles still puts the burden on the reader to figure out what matters. This appendix takes the next step: using those search results to generate a human-­readable summary with a large language model (LLM).

Qdrant will continue to provide retrieval, finding articles related to the topic we want to summarize. Ollama will gains second responsibility: alongside running nomic-embed-text for embedding, it will also serve llama3, a text generation model that synthesizes retrieved articles into prose. The domain.Storage and domain.Searchable interfaces from appendix A require no changes; the new summary handler consumes them directly. Our focus is to add a new summarizer package and a new HTTP handler that uses LLMs while keeping our design flexible for the future.

B.1 LLM technologies

B.1.1 Ollama: Running models locally

B.1.2 LangChain: A consistent interface for LLMs

B.2 Infrastructure setup

B.3 Creating the summary module

B.3.1 Configuration and initialization

B.3.2 The Summarize method

B.3.3 Building the prompt

B.4 Wiring it into the API

B.4.1 What the handler needs

B.4.2 The summary handler

B.4.3 Updating the API

B.5 End-to-end test

B.6 What to try next

Summary