Fuck You, Show Me The Prompt.
Summary
Many LLM frameworks, such as Guardrails, Guidance, Langchain, Instructor, and DSPy, aim to improve model outputs by rewriting or constructing prompts, often disintermediating users from the underlying prompt logic. This article demonstrates how to quickly understand these "inscrutable" frameworks by intercepting their API calls using `mitmproxy`, a free and open-source HTTPS proxy. By inspecting the actual prompts and API call patterns, developers can assess a framework's necessity, identify accidental complexity, optimize prompts, and evaluate the efficiency of multi-step LLM interactions. Examples reveal varied approaches, from Guardrails' XML-based structured output to DSPy's hundreds of iterative API calls for prompt optimization, underscoring the value of transparency in LLM development. This method empowers users to make informed decisions and avoid blindly adopting abstractions without understanding their operational details.
Key takeaway
Using `mitmproxy` to intercept LLM API calls reveals the hidden prompts generated by frameworks, enabling critical evaluation of their underlying mechanisms. This exposes inefficiencies like DSPy's hundreds of optimization calls or Guidance's 7 redundant idea-generation calls, contrasting with Instructor's efficient single-call function schema usage. AI/ML professionals can leverage this insight to assess framework necessity, optimize costs, improve prompt quality, and avoid accidental complexity in LLM application development.
Topics
- LLM Frameworks
- Prompt Engineering
- API Interception
- mitmproxy
- Accidental Complexity
Code references
Best for: AI Engineer, Machine Learning Engineer, Prompt Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Hamel Husain's Blog.