hindsight icon indicating copy to clipboard operation
hindsight copied to clipboard

ollama with lama3.1 - llm response missing fields

Open thezolon opened this issue 11 months ago • 5 comments

zolon@zaipc:/bulk/AnimaNet$ hindsight memory retain test 'Zolon Farsane is the owner of this system.' Memory retained successfully (document: cli_put_20251217_142301) Stored count: 1

[api] 2025-12-17 20:23:02,298 - DEBUG - hindsight_api.engine.retain.fact_extraction - LLM response missing 'facts' field or returned empty list. Response: {'Zolon Farsane': -1.1}. Input: date: 2025-12-17T20:23:01.910970+00:00, context: none, text: Zolon Farsane is the owner of this system.

[GIN] 2025/12/17 - 20:22:45 | 200 | 1.060582ms | 127.0.0.1 | GET "/api/tags" time=2025-12-17T20:23:01.973Z level=DEBUG source=sched.go:626 msg="evaluating already loaded" model=/models/blobs/sha256-667b0c1932bc6ffc593ed1d03f895bf2dc8dc6df21db3042284a6f4416b06a29 time=2025-12-17T20:23:01.976Z level=DEBUG source=prompt.go:63 msg="truncating input messages which exceed context length" truncated=2 time=2025-12-17T20:23:01.976Z level=DEBUG source=server.go:1465 msg="completion request" images=0 prompt=296 format=""json"" time=2025-12-17T20:23:01.976Z level=TRACE source=server.go:1466 msg="completion request" prompt="<|start_header_id|>user<|end_header_id|>\n\nExtract facts from the following text chunk.\n\n\nChunk: 1/1\nEvent Date: Wednesday, December 17, 2025 (2025-12-17T20:23:01.910970+00:00)\nContext: none\n\nText:\nZolon Farsane is the owner of this system.<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" time=2025-12-17T20:23:01.977Z level=DEBUG source=cache.go:104 msg="loading cache slot" id=0 cache=89 prompt=76 used=42 remaining=34 [GIN] 2025/12/17 - 20:23:02 | 200 | 383.076488ms | 172.19.0.1 | POST "/v1/chat/completions" time=2025-12-17T20:23:02.296Z level=DEBUG source=sched.go:385 msg="context for request finished" runner.name=registry.ollama.ai/library/llama3.1:latest runner.inference="[{ID:GPU-400c4340-d61b-41cd-9760-1841ba7aaa49 Library:CUDA}]" runner.size="5.1 GiB" runner.vram="5.1 GiB" runner.parallel=1 runner.pid=4655 runner.model=/models/blobs/sha256-667b0c1932bc6ffc593ed1d03f895bf2dc8dc6df21db3042284a6f4416b06a29 runner.num_ctx=4096 time=2025-12-17T20:23:02.296Z level=DEBUG source=sched.go:290 msg="runner with non-zero duration has gone idle, adding timer" runner.name=registry.ollama.ai/library/llama3.1:latest runner.inference="[{ID:GPU-400c4340-d61b-41cd-9760-1841ba7aaa49 Library:CUDA}]" runner.size="5.1 GiB" runner.vram="5.1 GiB" runner.parallel=1 runner.pid=4655 runner.model=/models/blobs/sha256-667b0c1932bc6ffc593ed1d03f895bf2dc8dc6df21db3042284a6f4416b06a29 runner.num_ctx=4096 duration=5m0s time=2025-12-17T20:23:02.296Z level=DEBUG source=sched.go:308 msg="after processing request finished event" runner.name=registry.ollama.ai/library/llama3.1:latest runner.inference="[{ID:GPU-400c4340-d61b-41cd-9760-1841ba7aaa49 Library:CUDA}]" runner.size="5.1 GiB" runner.vram="5.1 GiB" runner.parallel=1 runner.pid=4655 runner.model=/models/blobs/sha256-667b0c1932bc6ffc593ed1d03f895bf2dc8dc6df21db3042284a6f4416b06a29 runner.num_ctx=4096 refCount=0 [GIN] 2025/12/17 - 20:23:15 | 200 | 23.52µs | 127.0.0.1 | HEAD "/"

docker run --rm -it --pull always -p 8888:8888 -p 9999:9999
-e HINDSIGHT_API_LLM_PROVIDER=ollama
-e HINDSIGHT_API_LLM_BASE_URL=http://192.168.2.22:11434/v1
-e HINDSIGHT_API_LLM_MODEL=llama3.1
-e HINDSIGHT_API_DATABASE_URL=postgresql://hindsight:[email protected]:10432/hindsight
-e HINDSIGHT_LOG_LEVEL=${HINDSIGHT_LOG_LEVEL:-debug}
-e HINDSIGHT_API_LOG_LEVEL=debug
-v /bulk/hindsight-docker:/home/hindsight/.pg0
ghcr.io/vectorize-io/hindsight:latest

Not worried about the secrets as this is for testing. When ready to move outside dev environement, they will be changing.

As you can see, it is talking between all the different layers, but no matter what I do, it seems to not like what is coming back from ollama.

I am unsure how to get past these errors, and how to see what ollama is responding with. The model does work when accessed via other means, but hindsight refuses to save memories because of these errors.

Other models have been tried: phi3, qwen2.5

thezolon avatar Dec 17 '25 20:12 thezolon

We shouldn't use llama3.1 as the example. I am working on improving a locally hosted method, but so far have had success with ollama and gpt-oss:latest with an expansion of the context size. The default of 8k is too small.

Get the latest gpt-oss model for ollama: https://ollama.com/library/gpt-oss

cat > ~/gpt-oss-large.Modelfile <<EOF FROM gpt-oss:latest PARAMETER num_ctx 32768 EOF

then ollama create gpt-oss-20b-lctx -f ~/gpt-oss-large.Modelfile

and then use HINDSIGHT_API_LLM_MODEL=gpt-oss-20b-lctx

dcbouius avatar Dec 17 '25 21:12 dcbouius

I'm experimenting with smaller open source models. for now the only one that is tested and works correctly is the openai-oss one (both 20b and 120b). The main challenge of these models is that they are not doing a good job on structured output

nicoloboschi avatar Dec 17 '25 21:12 nicoloboschi

We shouldn't use llama3.1 as the example. I am working on improving a locally hosted method, but so far have had success with ollama and gpt-oss:latest with an expansion of the context size. The default of 8k is too small.

Get the latest gpt-oss model for ollama: https://ollama.com/library/gpt-oss

cat > ~/gpt-oss-large.Modelfile <<EOF FROM gpt-oss:latest PARAMETER num_ctx 32768 EOF

then ollama create gpt-oss-20b-lctx -f ~/gpt-oss-large.Modelfile

and then use HINDSIGHT_API_LLM_MODEL=gpt-oss-20b-lctx

[api] 2025-12-17 21:27:08,460 - DEBUG - hindsight_api.engine.retain.link_utils - [6.3.3] Generate 0 links: 0.000s [api] 2025-12-17 21:27:08,460 - DEBUG - hindsight_api.engine.retain.link_utils - [6.3] Entity link creation: 0 links for 3 unique entities in 0.002s [api] 2025-12-17 21:27:08,462 - INFO - hindsight_api.engine.retain.orchestrator - [api] ============================================================ [api] RETAIN_BATCH START: test [api] Batch size: 1 content items, 42 chars [api] ============================================================ [api] [1] Extract facts: 1 facts, 1 chunks from 1 contents in 13.717s [api] [2] Generate embeddings: 1 embeddings in 0.019s [api] [2.5] Document tracking: 1 documents in 0.001s [api] [3] Store chunks: 1 chunks for 1 documents in 0.004s [api] [4] Deduplication: 0 duplicates in 0.003s [api] [5] Insert facts: 1 units in 0.003s [api] [6] Process entities: 0 links in 0.003s [api] [7] Temporal links: 0 links in 0.000s [api] [8] Semantic links: 0 links in 0.000s [api] [9] Entity links: 0 links in 0.000s [api] [10] Causal links: 0 links in 0.000s [api] ============================================================ [api] RETAIN_BATCH COMPLETE: 1 units in 13.755s [api] Documents: cli_put_20251217_152654 [api] ============================================================ [api]

That worked! Thank you.

thezolon avatar Dec 17 '25 21:12 thezolon

Have another issue I have discovered.

Even with everything set to 32768 .. The model runners are only running at 16k.

If I run the model outside of Hindsight, it is at 32k. It is specifically hindsight that is reloading it into 16k.

Any way to force hindsight to use 32k?

thezolon avatar Feb 16 '26 01:02 thezolon

Have another issue I have discovered.

Even with everything set to 32768 .. The model runners are only running at 16k.

If I run the model outside of Hindsight, it is at 32k. It is specifically hindsight that is reloading it into 16k.

Any way to force hindsight to use 32k?

@thezolon yes you can tweak the retain options, see: https://hindsight.vectorize.io/developer/configuration#retain

HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS=32000

nicoloboschi avatar Feb 16 '26 07:02 nicoloboschi