Q&A: Combining Math and LLMs

by Justin Skycak (@justinskycak) on

Want to get notified about new posts? Join the mailing list and follow on X/Twitter.


I recently posted the following tweet:

  • The coolest CS projects involve writing software to automatically make intelligent decisions within some domain. And when you're writing code that makes complicated decisions, often involving some kind of inference... that's typically where math comes in.

And received the following question:

  • If someone was just building agentic AIs, with inference outsourced to models, how could math be used here to optimise it?

I have used LLMs in some modeling workflows where was a massive help / performance boost / expense savings to build a mathematical postprocessing layer on top of LLM output instead of having the LLM carry out the full pipeline on its own. I was basically using the LLM as a feature extractor.

It’s been my experience that, while LLMs are powerful tools for language manipulation, they are susceptible to error (even 1% error rate can become super annoying to build a production system around) and they get easily confused and super forgetful and error prone when you ask them to do a lot of mathematically complex custom things, especially when they have to run concrete numbers through (as opposed to just symbols).

When you’re able to segment out a pipeline into natural language segments (using LLM) and mathematical processing segments (not using LLM), you need fewer LLM prompts, the prompts much smaller & less complicated, and consequently the error rate is much lower.

Raw math/algos and LLM are both powerful tools in your modeling toolkit and you’ll get best results from being able to use the right tool at the right time. If you’re missing either tool from your toolkit, then that will severely hamstring your modeling abilities and many problems will remain inaccessible to you.



Want to get notified about new posts? Join the mailing list and follow on X/Twitter.