[GH-ISSUE #1822] empty output #1037

Closed
opened 2026-04-12 10:46:12 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @quanpinjie on GitHub (Jan 6, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/1822

i create a model ggml-model-f16.gguf codellama-34b

ollama run empty output

image

image

Originally created by @quanpinjie on GitHub (Jan 6, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/1822 i create a model ggml-model-f16.gguf codellama-34b ollama run empty output ![image](https://github.com/jmorganca/ollama/assets/2564119/1014dcd6-9c53-4a55-8dbe-a410aed021c6) ![image](https://github.com/jmorganca/ollama/assets/2564119/ac5dd1ec-40df-4c4f-90bd-d7b2ab5aa513)
Author
Owner

@pdevine commented on GitHub (Mar 11, 2024):

This does seem to be working:

% ./ollama run codellama:34b-instruct
>>> """
... Where is the problem with this code?
...
... def fib(n):
...     if n <= 0:
...         return n
...     else:
...         return fib(n-1) + fib(n-2)
...
... """

The problem with this code is that it does not work for negative inputs. The function is defined as a recursive function,
but the base case of `n <= 0` is not handled correctly. Specifically, when `n` is negative, the function will recurse
infinitely because `fib(n-1)` and `fib(n-2)` are both undefined for negative values of `n`.

To fix this problem, you can add a base case for negative inputs, such as:

def fib(n):
    if n <= 0:
        return 0
    else:
        return fib(n-1) + fib(n-2)

This will make the function return 0 for any input that is less than or equal to 0, which makes more sense in this context.
Alternatively, you can raise an error if the input is negative, like this:

def fib(n):
    if n <= 0:
        raise ValueError("Input must be greater than zero")
    else:
        return fib(n-1) + fib(n-2)

This will make the function more robust and fail explicitly when it encounters an invalid input.

You should check that you have the latest version of Ollama and codellama. It's possible if you converted codellama yourself that you don't have the prompt template correct or it wasn't converted correctly.

I'm going to go ahead and close this, but feel free to reopen it or keep commenting.

<!-- gh-comment-id:1989452266 --> @pdevine commented on GitHub (Mar 11, 2024): This does seem to be working: ``` % ./ollama run codellama:34b-instruct >>> """ ... Where is the problem with this code? ... ... def fib(n): ... if n <= 0: ... return n ... else: ... return fib(n-1) + fib(n-2) ... ... """ The problem with this code is that it does not work for negative inputs. The function is defined as a recursive function, but the base case of `n <= 0` is not handled correctly. Specifically, when `n` is negative, the function will recurse infinitely because `fib(n-1)` and `fib(n-2)` are both undefined for negative values of `n`. To fix this problem, you can add a base case for negative inputs, such as: def fib(n): if n <= 0: return 0 else: return fib(n-1) + fib(n-2) This will make the function return 0 for any input that is less than or equal to 0, which makes more sense in this context. Alternatively, you can raise an error if the input is negative, like this: def fib(n): if n <= 0: raise ValueError("Input must be greater than zero") else: return fib(n-1) + fib(n-2) This will make the function more robust and fail explicitly when it encounters an invalid input. ``` You should check that you have the latest version of Ollama and codellama. It's possible if you converted codellama yourself that you don't have the prompt template correct or it wasn't converted correctly. I'm going to go ahead and close this, but feel free to reopen it or keep commenting.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1037