3 ms·
You're absolutely right that using a robust calendar/date library (like dateutil in Python) is the standard approach and often the best one. It's definitely eas
by michaelulin 2y ago
You're absolutely right that using a robust calendar/date library (like dateutil in Python) is the standard approach and often the best one. It's definitely easier to debug and test in the traditional sense.
The potential value of the LLM approach comes in when:
The natural language input is very fuzzy or varied, potentially going beyond what standard libraries parse easily out-of-the-box.
You want to simplify the application code that interprets the user's intent before calling a date library function. The LLM handles the interpretation step.
Regarding edge cases like leap years: That's a valid concern for any date logic. However, capable LLMs (even models like GPT-3.5-Turbo or GPT-4o mini), when given the proper context (like today's date, as shown in the example prompt), handle standard date calculations including leap years quite well. More importantly, the validation layer (using Pydantic/Instructor in the example) is crucial here.
Caching is also possible for the LLM responses (based on input text + date context) if needed. It's definitely a different set of trade-offs compared to using a library directly!
- rini17 2y agoI meant that LLM will be used, but not to compute date directly, but to generate python code from user input. That does not need to be thrown out of cache every day.