13

I have had various experiences with ChatGPT when it comes to getting it to count something. I have tried telling it to give me "8 letter words", "count number of 'r's in 'forrest', write a paragraph with 'x' many sentences, etc. Sometimes it gives me the exact correct thing I am looking for, and sometimes it is blatantly wrong, but it still acts as if it got the right answer, for example

Sure, here is an 8 letter word  
<<proceeds to give 9 letter word>>  

I would like to know once and for all, is ChatGPT (or text generation LLM AI's like it) capable of counting?

It seems to do simple math (like it gets 1+1 = 2 every time), but that could just be because of how its training works. I doubt it can do any kind of trigonometry or calculus operation.

3

3 Answers 3

4

Counting means having some sort of state, and iteratively updating it. That is not something a transformer does, as it would have to have some sort of loop and updatable storage internally. So if you just ask it how many letters there are in a certain word, it's closer to a guess than a count.

However, a transformer does consider the output it already generated when generating the next token; and we can use this to make it count. Consider the following prompt: "Here's a way to count letters in a string: split off the first letter and count 1, then attach the second to it and count 2, and so on. E.g. to count the letters in "horse", you do h - 1, ho - 2, hor - 3, and so on and so on. Use this method to count the letters in 'skdfkjgjgjasgdjfgajhgajdsgfjaooo'".

This works correctly (most of the time I've tried it in gpt4) even with long strings. So in that sense, it can count; the occasional failures, as far as I can tell, are failures in instruction following.

At least impressionistically, if maybe not rigorously, this is related to how finite automata cannot count, but Turing machines can (because they have a tape where they can keep state).

4
  • That's still not counting. You can get a similar result with a prompt like this: "List the whole numbers from 1 to 30. Also list the letters in sadofhslfsdlfjsdfjsdfsdif. Write the two lists next to each other." It can generate a list of numbers, and it can put that list next to something else. That isn't really counting I would say.
    – blues
    Commented Aug 2, 2023 at 9:18
  • What's your definition of counting?
    – d.hoeffer
    Commented Aug 3, 2023 at 4:30
  • I tried the prompt above and Chat GPT still failed at counting. “Applying the method you described: • Manchester United: 13 letters • Jose Mourinho: 12 letters • Roger Federer: 12 letters • Rafael Nadal: 10 letters • Novak Djokovic: 12 letters “ Commented Dec 14, 2023 at 3:30
  • Just don't use gpt3.5. It's ancient underpowered technology at this point, and you cannot use it to determine what LLMs can not do.
    – d.hoeffer
    Commented Dec 15, 2023 at 4:11
3

No, ChatGPT doesn't know how to count. Based on statistics and probability, it knows how to put one word after another. Remember that ChatGPT responses might vary; if you ask it to do the same thing hundreds of times, there are chances that not all the responses will be the same.

It's worth mentioning that several weeks ago, OpenAI launched support for plugins. From https://openai.com/blog/chatgpt-plugins

ChatGPT plugins

We’ve implemented initial support for plugins in ChatGPT. Plugins are tools designed specifically for language models with safety as a core principle, and help ChatGPT access up-to-date information, run computations, or use third-party services.

Please note that one of the highlighted features is to run computations. From this, we can fairly accept the initial claim in the answer as accurate.

The counting capability of other GenAI tools will depend on each implementation, how it was trained, and whether it's a "pure" LLM, enhanced with other technologies or integrated with other tools that might be or not Artificial Intelligence.

3

OpenAI's CEO explicitly mentioned in March 2023 in the GPT-4 announcement video that GPT-4 isn't hooked up to a calculator.

Related:

2
  • 1
    I am talking about the free chatgpt web application. Is it possible that although chatgpt itself does not perform calculations, the web application somehow has basic counting logic built into it? For example if i ask for an 8 letter word, may be it can query chatgpt until it returns an 8, letter word
    – user13267
    Commented Jul 25, 2023 at 23:07
  • @user13267 possible but extremely unlikely. If it did, it'd likely do math better, e.g. it gets 519841651 + 156516849761 + 156516849761 + 156516849761 = wrong. (outputs 470391066934 instead of 470070390934). Commented Jul 25, 2023 at 23:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.