this post was submitted on 18 Oct 2024
250 points (99.2% liked)

Programming Horror

1864 readers
2 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

Credits

founded 1 year ago
MODERATORS
 
top 32 comments
sorted by: hot top controversial new old
[–] [email protected] 54 points 4 days ago (4 children)

From my experience with ChatGPT:

  1. It will NEVER consistently give you only the value in the response. It will always eventually add in some introductory text like it’s talking to a human. No matter how many times I tried to get it to just give me back the answer alone, it never consistently did.
  2. ChatGPT is terrible with numbers. It can’t count, do math, none of that. So asking it to do byte math is asking for a world of hurt.

If this isn’t joke code, that is scary.

[–] [email protected] 56 points 4 days ago (1 children)

I refuse to believe you are not certain this is a joke

[–] [email protected] 23 points 4 days ago (1 children)

I know it is, but I’ve also seen people try to use ChatGPT for similar things as a serious endeavor.

[–] [email protected] 25 points 4 days ago (3 children)
[–] [email protected] 5 points 3 days ago

Where's my 1 million dollars?

[–] [email protected] 6 points 4 days ago

Neat! Never seen this one before.

[–] [email protected] 2 points 4 days ago (2 children)

how is it different from a calculator or say a Python REPL? i'm asking b/c i'm too old to try out young folks inefficiently engineered "solutions".

[–] [email protected] 8 points 3 days ago

You input some text, chatGPT guesses the answer using the linear algebra that powers LLMs

The project was made as a satire of companies putting AI into everything

[–] [email protected] 6 points 3 days ago

have you ever wanted your calculator to be able to be wrong like a human?
Like, not just calculating the wrong answer or returning an error, i mean outright brainfart and just giving a nonsense answer

[–] [email protected] 3 points 3 days ago* (last edited 2 days ago) (2 children)

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.

[–] [email protected] 5 points 3 days ago (2 children)

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).

[–] [email protected] 1 points 2 days ago (1 children)

Fair play to Open AI - I still think LLMs are overhyped, but they're moving things along constantly in impressive ways.

[–] [email protected] 1 points 2 days ago (1 children)

Honestly the use case i'm working on is pretty mind blowing. User records an unstructured voice note like "i am out of item 12, also prices of items 13 & 15 is down to 4 dollars 99, also shipping for all items above 1kg is now 3 dollars 99" and the LLM will search the database for items >1kg (using tool calling) then generate a JSON representing the changes to be made. We use that JSON to make a simple UI where the user can review the changes - then voilà it's sent to the backend which persists the change in database. In the ideal case the user never even pulls up the virtual keyboard on their phone, it's just "talk, check, click, done".

[–] [email protected] 1 points 2 days ago

Human in the loop systems with LLMs really nicely deal with a lot of their problems. Very cool! Do you have specific change "types" that the system is able to propose? I guess restricting the response to the right types is covered by your JSON schema?

[–] [email protected] 0 points 2 days ago (1 children)
[–] [email protected] 2 points 2 days ago

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.

[–] [email protected] 2 points 2 days ago

That’s a good approach. I think for my use case the struggle was trying to not use a ton of tokens (upper management was being stingy on that front). I kept trying to push to make it more robust but you know how those things go. Axed ahead of their time or zombified.

[–] [email protected] 4 points 3 days ago

Response:

Observation 1: ChatGPT is designed to provide context for responses to enhance clarity for human users. Requests for answers without accompanying text may result in inconsistent behavior due to its conversational model. It is not optimized for providing pure data outputs without context.

Observation 2: ChatGPT is not inherently equipped to perform complex mathematical operations with high reliability. Numerical inaccuracies or rounding errors may occur due to the model’s structure. While capable of basic arithmetic, it is not a specialized tool for precise calculations, particularly in domains like byte math, where accuracy is critical.

Statement acknowledged.

[–] [email protected] 2 points 4 days ago

For 1, that's why you say "Format your answer in this exact sentence: The number of bytes required (rounded up) is exactly # bytes., where # is the number of bytes." And then regex for that sentence. What could go wrong?

Also, it can do math somewhat consistently if you let it show its work, but I still wouldn't rely on it as a cog in code execution. It's not nearly reliable enough for that.

[–] [email protected] 39 points 4 days ago

knowing GPT users, this is probably not satire.

[–] [email protected] 43 points 4 days ago

Money generator for bug bounty hunters

[–] [email protected] 4 points 3 days ago (1 children)

Malloc doesn't even exist! He's not canon!

/j

[–] [email protected] 2 points 2 days ago

I saw the best minds of my generation....

[–] [email protected] 13 points 4 days ago (3 children)

You don't need to cast the return value from malloc.

[–] [email protected] 6 points 3 days ago* (last edited 3 days ago)

This isn't malloc though. I have to assume the cast is because the user has experience with the output from an LLM being untrustworthy.

[–] [email protected] 2 points 2 days ago (1 children)
[–] [email protected] 2 points 2 days ago (1 children)

In c++ you should use new.

[–] [email protected] 1 points 2 days ago

that is besides the point. You can still call malloc, it will still return void*, and it would still reqoire casting in c++

[–] [email protected] 10 points 4 days ago (1 children)

True. Although given how easy it is to cast void pointers to the wrong damn thing, it would be nice if you did, makes refactoring much easier. Makes me appreciate std::any all the more.

[–] [email protected] 3 points 2 days ago* (last edited 2 days ago)

Void pointer should be avoided anyways. Even I find them rare and I mostly work in embedded RTOS

[–] [email protected] 6 points 4 days ago

Someone needs to put this in DreamBerd

[–] [email protected] 5 points 4 days ago