[GH-ISSUE #15582] bge-m3 returns HTTP 500 with json: unsupported value: NaN when embedding certain markdown files. #56461

Open
opened 2026-04-29 10:50:59 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @TadMSTR on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15582

What is the issue?

bge-m3 returns HTTP 500 with json: unsupported value: NaN when embedding certain markdown files.

The file is valid UTF-8 markdown (~1.9 KB) with standard YAML frontmatter. Other files in the same corpus embed without issue. The same file consistently triggers the error across restarts — it's deterministic, not a transient failure.

The error suggests the model produced a NaN value in the embedding vector that Ollama's JSON serializer cannot encode. This is model-level numerical instability for specific inputs, not a client or file issue.

Error:
ollama._types.ResponseError: failed to encode response: json: unsupported value: NaN (status code: 500)

Reproducer:

import ollama
client = ollama.Client(host="http://your-ollama-host")
with open("triggering_file.md") as f:
    text = f.read()
result = client.embed(model="bge-m3", input=[text])

Expected: valid embedding vector, or a descriptive error identifying the problematic input
Actual: HTTP 500, process/watcher crashes

Relevant log output

`failed to encode response: json: unsupported value: NaN (status code: 500)`

OS

Linux

GPU

Nvidia

CPU

AMD

Ollama version

0.20.2

Originally created by @TadMSTR on GitHub (Apr 14, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15582 ### What is the issue? `bge-m3` returns HTTP 500 with `json: unsupported value: NaN` when embedding certain markdown files. The file is valid UTF-8 markdown (~1.9 KB) with standard YAML frontmatter. Other files in the same corpus embed without issue. The same file consistently triggers the error across restarts — it's deterministic, not a transient failure. The error suggests the model produced a NaN value in the embedding vector that Ollama's JSON serializer cannot encode. This is model-level numerical instability for specific inputs, not a client or file issue. **Error:** `ollama._types.ResponseError: failed to encode response: json: unsupported value: NaN (status code: 500)` **Reproducer:** ```python import ollama client = ollama.Client(host="http://your-ollama-host") with open("triggering_file.md") as f: text = f.read() result = client.embed(model="bge-m3", input=[text]) ``` Expected: valid embedding vector, or a descriptive error identifying the problematic input Actual: HTTP 500, process/watcher crashes ### Relevant log output ```shell `failed to encode response: json: unsupported value: NaN (status code: 500)` ``` ### OS Linux ### GPU Nvidia ### CPU AMD ### Ollama version 0.20.2
GiteaMirror added the bug label 2026-04-29 10:50:59 -05:00
Author
Owner

@dominicx commented on GitHub (Apr 16, 2026):

also in 0.20.3

<!-- gh-comment-id:4258475183 --> @dominicx commented on GitHub (Apr 16, 2026): also in 0.20.3
Author
Owner

@PureBlissAK commented on GitHub (Apr 18, 2026):

🤖 Automated Triage & Analysis Report

Issue: #15582
Analyzed: 2026-04-18T18:19:27.909844

Analysis

  • Type: unknown
  • Severity: medium
  • Components: unknown

Implementation Plan

  • Effort: medium
  • Steps:

This issue has been triaged and marked for implementation.

<!-- gh-comment-id:4274304917 --> @PureBlissAK commented on GitHub (Apr 18, 2026): <!-- ollama-issue-orchestrator:v1 issue:15582 --> ## 🤖 Automated Triage & Analysis Report **Issue**: #15582 **Analyzed**: 2026-04-18T18:19:27.909844 ### Analysis - **Type**: unknown - **Severity**: medium - **Components**: unknown ### Implementation Plan - **Effort**: medium - **Steps**: *This issue has been triaged and marked for implementation.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#56461