this post was submitted on 18 Oct 2024
254 points (99.2% liked)
Programming Horror
1935 readers
1 users here now
Welcome to Programming Horror!
This is a place to share strange or terrible code you come across.
For more general memes about programming there's also Programmer Humor.
Looking for mods. If youre interested in moderating the community feel free to dm @[email protected]
Rules
- Keep content in english
- No advertisements (this includes both code in advertisements and advertisement in posts)
- No generated code (a person has to have made it)
Credits
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
From my experience with ChatGPT:
If this isn’t joke code, that is scary.
I know a guy who was working on something like this, they just had the call to the model loop until the response met whatever criteria the code needed (e.g. one single number, a specifically formatted table, viable code, etc) or exit after a number of failed attempts. That seemed to work pretty well, it might mess up from time to time but it's unlikely to (with the right prompt) do so repeatedly when asked again.
I'm currently a guy working on something like this ! It's even simpler as you can have structured output on the chatgpt API. Basically you give it a JSON schema and it's guaranteed to respond with JSON that validates against that schema. Spent a couple weeks hacking at it and i'm positively impressed, I have had clean JSON 100% of the time, and the data extraction is pretty reliable too.
The tooling is actually reaching a sweet spot right now where it makes sense to integrate LLMs in production code (if the use case makes sense and you haven't just shoe-horned it in for the hype).
This works well too, and with many different models: https://github.com/guardrails-ai/guardrails
That's fucking badass thanks for the pointer this might prove useful. In the structured output department i'm hearing great things about dotTxt's outlines which lets you constrain output according to a regex, but i haven't tested it yet.