How a Decorator Crashed My Flask App: Lessons Learned

TL;DR: Always use functools.wraps for your decorators. Decorators in python are wonderful. They let you modify or extend the behavior of functions or methods without permanently modifying their source code. I’ve used them in several places in my code to add features to my functions. But recently, I came across a weird, or rather interesting, bug that I felt was worth sharing. The Issue So we had a Flask API that was responsible for ML inference....

July 1, 2024 · 7 min ·  python

Prompt Tuning with DSPy

What is it and why is it needed? Last week, I spent some time writing prompts for classifying documents into a fixed set of classes based on their OCR text. I spent some time tweaking and experimenting with the prompt for the model to behave exactly how I wanted it to behave. But prompt tuning, for those who have tried it, knows how painfully daunting it is to make these models behave exactly how you’d like them to behave… that also consistently....