TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: MonkeyPatch – Cheap, fast and predictable LLM functions in Python

95 pointsby JackHopkinsover 1 year ago
Hi HN, Jack here! I&#x27;m one of the creators of MonkeyPatch, an easy tool that helps you build LLM-powered functions and apps that get cheaper and faster the more you use them.<p>For example, if you need to classify PDFs, extract product feedback from tweets, or auto-generate synthetic data, you can spin up an LLM-powered Python function in &lt;5 minutes to power your application. Unlike existing LLM clients, these functions generate well-typed outputs with guardrails to mitigate unexpected behavior.<p>After about 200-300 calls, these functions will begin to get cheaper and faster. We&#x27;ve seen 8-10x reduction in cost and latency in some use-cases! This happens via progressive knowledge distillation - MonkeyPatch incrementally fine-tunes smaller, cheaper models in the background, tests them against the constraints defined by the developer, and retains the smallest model that meets accuracy requirements, which typically has significantly lower costs and latency.<p>As an LLM researcher, I kept getting asked by startups and friends to build specific LLM features that they could embed into their applications. I realized that most developers have to either 1) use existing low-level LLM clients (GPT4&#x2F;Claude), which can be unreliable, untyped, and pricey, or 2) pore through LangChain documentation for days to build something.<p>We built MonkeyPatch to make it easy for developers to inject LLM-powered functions into their code and create tests to ensure they behave as intended. Our goal is to help developers easily build apps and functions without worrying about reliability, cost, and latency, while following best software engineering practices.<p>We&#x27;re only available in Python currently but actively working on a Typescript version. The repo has all the instructions you need to get up and running in a few minutes.<p>The world of LLMs is changing by the day and so we&#x27;re not 100% sure how MonkeyPatch will evolve. For now, I&#x27;m just excited to share what we&#x27;ve been working on with the HN community. Would love to know what you guys think!<p>Open-source repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;monkeypatch&#x2F;monkeypatch.py">https:&#x2F;&#x2F;github.com&#x2F;monkeypatch&#x2F;monkeypatch.py</a><p>Sample use-cases: <a href="https:&#x2F;&#x2F;github.com&#x2F;monkeypatch&#x2F;monkeypatch.py&#x2F;tree&#x2F;master&#x2F;examples">https:&#x2F;&#x2F;github.com&#x2F;monkeypatch&#x2F;monkeypatch.py&#x2F;tree&#x2F;master&#x2F;ex...</a><p>Benchmarks: <a href="https:&#x2F;&#x2F;github.com&#x2F;monkeypatch&#x2F;monkeypatch.py#scaling-and-finetuning">https:&#x2F;&#x2F;github.com&#x2F;monkeypatch&#x2F;monkeypatch.py#scaling-and-fi...</a>

20 comments

p10jkleover 1 year ago
Nice! If I were to write a test for invariant aspects of the function (eg, it produces valid json), will the system guarantee that those invariants are fulfilled? I suppose naively you could just do this by calling over and over and &#x27;telling off&#x27; the model if it didn&#x27;t get it right
评论 #38279139 未加载
Scipio_Afriover 1 year ago
Can I use open source LLMs with this? Would be great if everything was available self hosted with open source models.
评论 #38285191 未加载
ipsum2over 1 year ago
This is like calling a python package &quot;ListComprehension&quot;, that loops through a list and calls OpenAI&#x27;s API on each item. Confusing and unproductive.
评论 #38286120 未加载
mitthrowaway2over 1 year ago
There seems to be a lot of (justified) concern about the name. Maybe call it LLMonkeyPatch?
评论 #38293519 未加载
评论 #38286670 未加载
评论 #38286638 未加载
m_vyas123over 1 year ago
Hey Jack! Thanks for sharing this. The incremental fine-tuning of smaller and cheaper models for cost reduction is definitely a really interesting differentiator. I had a few questions regarding the reliability of the LLM-powered functions MonkeyPatch facilitates and the testing process. How does MonkeyPatch ensure the reliability of LLM-powered functions it helps developers create, and do the tests employed provide sufficient confidence in maintaining consistent output? If tests fall short of 100% guarantee, how does MonkeyPatch address concerns similar to historical challenges faced with testing traditional LLMs? Thanks.
评论 #38286078 未加载
OJFordover 1 year ago
Why &#x27;Monkeypatch&#x27;, when it&#x27;s for Python, where that has an established and as far as I can tell (?) completely irrelevant meaning?
评论 #38284528 未加载
CyberDildonicsover 1 year ago
MonkeyPatch is a specific programming term that people have been using for decades. What would posses someone to name a programming tool &quot;MonkeyPatch&quot; when the tool doesn&#x27;t even have something to do with patching?
评论 #38285220 未加载
sweetgiorniover 1 year ago
Slightly tangential: is it unfair&#x2F;unreasonable to judge a project by its name? It&#x27;s hard not to interpret this project&#x27;s name as the result of poor judgement. Is that sufficient cause to write off the project entirely? That may seem a tad dramatic but I feel that it&#x27;s a fairly strong signal for how little effort I need to put into evaluating it.
评论 #38288791 未加载
babyshakeover 1 year ago
Not including &quot;pass&quot; in a function definition in Python makes the code not compilable, and if we&#x27;re using VSCode, PyCharm, etc. our IDEs will complain about this whenever the code is viewed. Is this an intentional design decision?
评论 #38286795 未加载
whoiskatrinover 1 year ago
Would love to try a typescript implementation. Any plans to do that?
评论 #38280730 未加载
评论 #38284015 未加载
angryemuover 1 year ago
Tests to align your model seems neat. How reliable is it? Won’t models still hallucinate time to time? How do you think about performance monitoring&#x2F;management?
评论 #38278247 未加载
ian_dot_soover 1 year ago
This is really interesting! What would be a good example of when I would want to use monkeypatch vs langchain or OpenAI functions?
评论 #38279385 未加载
lamrogerover 1 year ago
The guardrails are cool!<p>I think more details of where the data goes and when it goes from few-shot to fine-tune will be helpful.
评论 #38289108 未加载
vutchover 1 year ago
tried a shot , quite impressed. I am implementing the bedrock interface (OpenAPI is limited access from my location). Look promised. Will check it out the fine-tuning with bedrock. But not sure we can do that or not. Appreciate your work
pietzover 1 year ago
Could you explain the differences to Marvin AI? I see a large overlap.
评论 #38284146 未加载
eychu94over 1 year ago
Awesome stuff! What other potential integrations are on the roadmap?
评论 #38286269 未加载
jondwillisover 1 year ago
Where in the codebase are you performing the distillation process?
评论 #38286047 未加载
fudged71over 1 year ago
This is incredibly cool, I’m excited to try it out
评论 #38286035 未加载
jackmcclellandover 1 year ago
this is super cool! what&#x27;s the use case you&#x27;re most excited about?
评论 #38279263 未加载
jacobopluover 1 year ago
Super cool Jack
评论 #38284468 未加载