Semlib is a Python library designed to build data pipelines powered by Large Language Models (LLMs). Rather than writing manual prompting and parsing logic, you describe your requirements using natural language. Semlib manages the heavy lifting—prompting, output parsing, concurrency, caching, and cost tracking—under the hood. It brings familiar functional programming primitives like map, reduce, sort, and filter to the world of AI.
Why adopt this approach? Deconstructing complex tasks into semantic steps offers several practical advantages:
map and reduce operations run concurrently, significantly reducing total execution time.pip install semlib
Here is a basic implementation:
# Retrieve a list of U.S. presidents
presidents = await prompt(
"Who were the 39th through 42nd presidents of the United States?",
return_type=Bare(list[str])
)
# Sort them based on political leaning
await sort(presidents, by="right-leaning", reverse=True)
# -> ['Ronald Reagan', 'George H. W. Bush', 'Bill Clinton', 'Jimmy Carter']
# Locate a specific entry
await find(presidents, by="former actor")
# -> 'Ronald Reagan'
# Calculate their age at inauguration
await map(
presidents,
"How old was {} when he took office?",
return_type=Bare(int),
)
# -> [52, 69, 64, 46]
Feeding a massive dataset into a single LLM prompt rarely yields optimal results. Semlib provides a more reliable path: decompose the workload, process it step-by-step, and maintain granular control over the pipeline.
Customer Support – Analyze thousands of support tickets to automatically classify issues and extract key information.
Academic Research – Semantically sort through large collections of abstracts to find and recommend relevant papers.
Sentiment Analysis – Aggregate and synthesize feedback from product reviews at scale.
Content Processing – Filter and extract structured data from resumes, reports, or diverse document sets.
AI Multi-Agent Stock Trading System: GPT-5 and Claude 4.5 Sonnet
Duck VPN Review: Stream Netflix & Unblock Social Apps Without Logs
ChatGPT-on-WeChat Setup Guide: Run GPT-4o, Claude & More on WeChat
Google Analytics MCP Server: Query GA4 Data With Gemini CLI
FossFLOW: Offline-Ready Isometric Diagram Builder for the Browser
Crawl4AI: Fast LLM-Ready Web Scraping Without the Bloat
PhoneAgent: An AI-Powered iPhone Assistant Using OpenAI
syftr: Optimize Agent Workflows with Pareto Front Search
II-Agent Review: An Open-Source LLM Assistant Built for Autonomous Tasks
AI Peer Review Tool for Neuroscience: LLM-Driven Meta-Review Framework
ACE-Step: 15x Faster Open-Source Music Generation Model
Spacedrive: An Open-Source Cross-Platform File Manager