Chat/Completion not working with ollama and local models
Before submitting your bug report
- [X] I believe this is a bug. I'll try to join the Continue Discord for questions
- [X] I'm not able to find an open issue that reports the same bug
- [X] I've seen the troubleshooting guide on the Continue Docs
Relevant environment info
- OS: Fedora 40
- Continue version: v0.9.225 (pre-release)
- IDE version: VSCode 1.95.1
- Model: granite-8b
- config.json:
{
"models": [
{
"model": "granite-code:8b",
"provider": "ollama",
"contextLength": 128000,
"completionOptions": {
"maxTokens": 4000,
"temperature": 0.1,
"topP": 0.9,
"topK": 40,
"presencePenalty": 0,
"frequencyPenalty": 0.1
},
"systemMessage": "You are Granite Code, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. You always respond to greetings (for example, hi, hello, g'day, morning, afternoon, evening, night, what's up, nice to meet you, sup, etc) with \"Hello! I am Granite Code, created by IBM. How can I help you today?\". Please do not say anything else and do not start a conversation.",
"title": "granite-code:8b"
}
],
"tabAutocompleteModel": {
"model": "granite-code:8b",
"provider": "ollama",
"contextLength": 128000,
"completionOptions": {
"maxTokens": 4000,
"temperature": 0.1,
"topP": 0.9,
"topK": 40,
"presencePenalty": 0,
"frequencyPenalty": 0.1
},
"systemMessage": "You are Granite Code, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. You always respond to greetings (for example, hi, hello, g'day, morning, afternoon, evening, night, what's up, nice to meet you, sup, etc) with \"Hello! I am Granite Code, created by IBM. How can I help you today?\". Please do not say anything else and do not start a conversation.",
"title": "granite-code:8b"
},
"customCommands": [
{
"name": "test",
"prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
"description": "Write unit tests for highlighted code"
}
],
"contextProviders": [
{
"name": "diff",
"params": {}
},
{
"name": "folder",
"params": {}
},
{
"name": "codebase",
"params": {}
}
],
"slashCommands": [
{
"name": "edit",
"description": "Edit selected code"
},
{
"name": "comment",
"description": "Write comments for the selected code"
},
{
"name": "share",
"description": "Export the current chat session to markdown"
},
{
"name": "commit",
"description": "Generate a git commit message"
}
],
"embeddingsProvider": {
"provider": "ollama",
"model": "nomic-embed-text:latest",
"title": "nomic-embed-text:latest"
}
}
Description
trying to use IBM granite on a lenovo thinkpad with 64Gb RAM, plenty of disk space and an Intel GPU.
model running fine with ollama CLI, thus creating this report.
To reproduce
Log output
debug LLM Prompt logs :
#### Prompt #####
self.csv_df = pd.concat([self.csv_df, df], ignore_index=True)
print('[combine]: category [%s] done' % category)
self.csv_df.sort_values(by = ['ST'], inplace = True, ignore_index = True)
print('[sort]: done')
# print(self.csv_df.head())
# print(self.csv_df.info())
def tagging(self):
event_list = list(self.csv_df['Event'])
tag_list = [[] for i in range(len(event_list))]
# print(len(event_list), event_list[:5])
for i in range(len(event_list)):
for keywords, tag in self.tag_dict.items():
if isinstance(keywords, str):
if event_list[i].find(keywords) != -1:
tag_list[i].append(tag)
elif sum([(event_list[i].find(k) != -1) for k in keywords]):
tag_list[i].append(tag)
tags = [' '.join(tag_list[i]) for i in range(len(event_list))]
self.csv_df['Tag'] = tags
print('[tagging]: done')
def output(self, output_file = 'output.csv', start_date = '2000-01-01', end_date = '2100-01-01'):
print('[output]: creating csv from [%s]' % start_date + 'to [%s].' % end_date)
<FIM>
bound = pd.to_datetime(pd.Series([start_date, end_date])).dt.tz_localize(self.tz)
output_df = self.csv_df[(self.csv_df['ST'] >= bound[0]) & (self.csv_df['ET'] < bound[1])]==========================================================================
==========================================================================
##### Completion options #####
{
"contextLength": 128000,
"maxTokens": 4000,
"temperature": 0.1,
"topP": 0.9,
"topK": 40,
"presencePenalty": 0,
"frequencyPenalty": 0.1,
"model": "granite-code:8b",
"stop": [
"System:",
"Question:",
"Answer:"
]
}
##### Request options #####
{}
##### Prompt #####
<system>
You are Granite Code, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. You always respond to greetings (for example, hi, hello, g'day, morning, afternoon, evening, night, what's up, nice to meet you, sup, etc) with "Hello! I am Granite Code, created by IBM. How can I help you today?". Please do not say anything else and do not start a conversation.
<user>
"""main.py (107-107)
print('[output]: done')
"""
please explain
+1
@sbouchet @msivasubramaniaan can you run ollama list and see which models are running?
@msivasubramaniaan which model are you using?
My intuition is it's trying to load multiple models at once. Or possible some massive model was renamed or something. It's probably not a Continue bug since there's no way to specify memory or multiple models, but I'd be curious to get to the bottom of this
3rd here possible sending some param to ollama causing this failure?
@sbouchet I'd call out that granite isn't trained for fill-in-the-middle code completion and is unlikely to work well for that, would be a solid chat model though!
@RomneyDa the current granite-code (gen 2) models are trained with FIM. The new gen3 are not, so that'll be a future problem.
FTR, granite-code:3b and :8b run fine in Continue on Mac (>= M2), as ollama can use the GPUs there. On Lenovos, ollama falls back to CPU, which requires more memory., which might explain the tab completion issue. However there's no good reason why Chat would work from CLI, but not from Continue UI
Hey @gabe-l-hart, sorry to drag you in, but do you have any insights on the ollama/granite failure on tab completion when running on CPU?
@sbouchet @msivasubramaniaan can you run
ollama listand see which models are running?
here is the output:
$ ollama list
NAME ID SIZE MODIFIED
granite-code:8b 36c3c3b9683b 4.6 GB 41 hours ago
granite-code:3b becc94fe1876 2.0 GB 42 hours ago
nomic-embed-text:latest 0a109f422b47 274 MB 42 hours ago
Hi @fbricon and team! I don't have any direct insight on this since I've done my work on an M3, but I have a few thoughts/ideas. There are really only a few things that can be different between running through Continue and running through the ollama CLI:
- The eventual template-expanded prompt that the model has to process is different
- The client-side connection to the server is different
- This is actually my strongest hunch: There's probably some kind of timeout logic on the client side in Continue that's causing it to fail on CPU for long context completions
- The endpoint that the client is using is different and the codepath in
ollamahas some difference- Ollama implements their own API behind
/api(/api/chat,/api/completions) which is slightly different than their OpenAI compatibility layer behind/v1(/v1/chat/completions,/v1/completions). The Ollama CLI uses the Ollama API directly. I'd have to dig to see what Continue is using.
- Ollama implements their own API behind
One thing I see after a small bit of digging: It looks like we don't yet have granite-code in the supported FIM templates. Following the logic in getTemplateForModel, this means it's falling back to the starcoder template (here). This appears to be close to the FIM template used by Granite Code, but not quite identical (e.g. <file_sep>, <fim_pad>).
@gabe-l-hart while granite v2 models can probably benefit from some FIM template tuning, v3 won't since they're not FIM-trained, as I was told.
Anyways the immediate issue with tab completion here is ollama erroring with "model requires more system memory" when running on CPU.
Ah, I missed the error in the screenshot. This points to the prompt expansion being the problem. I haven't plumbed the depths of the autocomplete module yet, but given some of the function naming in there, I suspect the context is getting too big causing the memory needed to grow significantly (i.e. additional context injection is the issue).
You could try to simulate this with ollama run by giving it a much larger blob of context and seeing if you get the same error.
fwiw, it is not only granite that is not working on latest continue for me. Fails with starcode2 and llama too - its as if result never gets back to the client.
I'm also having problems with some models on my Intel Arc, but I'm starting to believe it's an Intel/Ollama problem, not a Continue problem.
When I run deepseek-coder:6.7b-base via Docker I get no reply as indicated here, while the CLI seems to work at least somewhat. However, when I run the ollama arch package, using the CPU, I do get successful completions.
Most chat models work fine for me, but I've seem several other models that behave erratically. For example on deepseek-coder-v2 on GPU I just get """"""""""""""""""""""""""" as a response.
Some problem! I tried starcoder2 and deepseek-coder.
@qqshow are you using an Intel GPU?
Reported upstream: https://github.com/intel-analytics/ipex-llm/issues/12374
Im also experiencing issues with Ollama and local models; they suddenly stop working, specifically with the autocomplete feature. After some investigation, I realized this problem started after updating from Ollama v0.3.14 to v0.4.1.
To test my theory, I downgraded Ollama to v0.3.14, and the autocomplete functionality returned to normal. I then tested with v0.4.0, and the issue reappeared. Based on this, I suspect that an incompatibility with autocomplete was introduced in version v0.4.0.
For anyone else experiencing this, you can try downgrading via the releases page: Ollama GitHub Releases. For now, I’ll stick with v0.3.14 as a temporary workaround.
That's an interesting find @alejandroqh. It may be worth posting an issue in their tracker since I know that 0.4.* includes a major architectural overhaul to a new go-based server for running the individual model processes. It's quite likely that this is related somehow.
There are likely multiple unrelated issues here at play:
- People with Intel GPUs that have broken models
- People who have problems with 0.4
- ???
Personally 0.4 works for me when running on CPU, but running a 0.3 docker image that supports my intel GPU does not work.
So it'd be useful if people that are having trouble would mention
- the version they are using
- the CPU/GPU they are using
And for debugging it could be useful to run an older version or force it to use the CPU to eliminate GPU bugs.
I just set the "contextLength": 12768 in config.json as hard fix and try to run the continue chat on my intel based laptop, and it is working. Earlier it was stuck.
ollama version is 0.3.14
model granite-code:8b