Hacker News new | ask | show | jobs
by nhumrich 50 days ago
I've been running a bunch of benchmarks comparing typed python to untyped python, and untyped python actually performs better now. I don't think it's the case anymore that types improve clarity to the LLM.

My hunch: The LLM has already been trained on the library, already knows the types. The annotations are just wasted noise/tokens at this point. (Also, majority of python is untyped, so probably has better "training data")

2 comments

>and untyped python actually performs better now.

To be clear, you mean that the LLM performs better at working with un-annotated code?

(If you were talking about the runtime performance of the same code with and without annotations, then it's actually pretty obvious. The bytecode compiler doesn't use them to perform optimizations, because they can validly be complete garbage; and it adds overhead to have runtime `__annotate__` and `__annotations__` attributes, calls to do-nothing functions like `typing.cast`, etc.)

Yes, I'm talking about LLM performance. Not runtime of the code.
Huh. Your comment makes no sense, since types are ignored at runtime. Your performance benchmarks seems all noise. If it's about LLM speed, that's an atrocious thing to even compare. Writing code carelessly is fast, but it's also fast at adding bugs.

Types improve clarity to humans. Types also prevent future bugs by disallowing incompatible modifications. If you're not religiously writing types in function signatures, you're not developing professional software, just throwaway janky unprofessional scripts. I suggest looking at the OpenAI package to see just how well typed it is.

"performs better" means the LLM does better. Takes less turns. Creates better quality. Has nothing to do with runtime performance.