Ollamacli
Need to summarize text documents, but don't want to share them with OpenAI or some other business with nebulous, ever-shifting data privacy policies and promises? Local models can handle summarization tasks directly from the command line interface, enabling one to harness search and processing in conjunction with unix commands on macOS, Linux, and (I'm guessing) Windows through the Linux subsystem.
LLMs on the command line
Here's a simple unix command that runs files through ollama
to generate a summary and then pipes the output to a text file. (Of course, you can omit that redirect to send the text to the standard output.)
If you haven't tried ollama
, see this guide: Attach:Main.LLM2025/llm_2.pdf
Let's take the directory of email messages from the RAG demo and summarize the first ten text files. In the unix shell, we can use:
An alternative is to pipe the text files using the standard input:
Of course, the cat
argument can be replaced with a particular file or glob of files. You only have to worry about the amount of text being sent relative to the context length of the model. In fact, the longer context length of llama3.1:8B
might make it a better choice here than command-r7b
.
The texts I'm sending are pretty generic emails to the university community, but we get the following summary:
The information provided highlights a series of communications and events related to the University of Delaware. The messages
focus on inviting alumni, students, and faculty to various gatherings and celebrations that take place throughout the year.
These events are intended to foster connections, celebrate achievements, and strengthen the community's bonds. Specific
details include:
- Invitations to join a special gathering for students, which will feature guest speakers and networking opportunities.
- A celebration of academic achievement, highlighting outstanding student accomplishments.
- An event focused on career development, featuring industry experts who will share their insights and provide advice.
- A recognition ceremony honoring distinguished alumni who have made significant contributions to the university and society.
- Invitations to alumni reunions, encouraging graduates to reconnect with peers and share experiences.
- A message promoting community engagement and participation in various initiatives aimed at enhancing campus life.
- Updates about upcoming events, including dates and locations for gatherings and activities.
Overall, these communications aim to foster a sense of belonging and pride among the university's community members,
encouraging active involvement and continued support for the institution.
I'd say that that is just about as good as anything an Associate Dean or Associate Provost is going to send you!
More document types
The simple illustration above only processes plain text files. You can expand the file types using a range of other unix programs and conversion tools.
More in a bit...