[GH-ISSUE #7490] Return an empty embed list #66820

Closed
opened 2026-05-04 08:16:49 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @somnifex on GitHub (Nov 4, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7490

What is the issue?

When I use the bge-m3 model, the return is an empty list regardless of the input.
My test code:

import requests
url = "http://localhost:12121/api/embeddings"
payload = {
    "model": "bge-m3",
    "input": "lol"
}
response = requests.post(url, json=payload)
print(response.text)

run program output

{"embedding":[]}

OS

Docker

GPU

Nvidia

CPU

Intel

Ollama version

0.3.14

Originally created by @somnifex on GitHub (Nov 4, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7490 ### What is the issue? When I use the [bge-m3](https://ollama.com/library/bge-m3) model, the return is an empty list regardless of the input. My test code: ```python import requests url = "http://localhost:12121/api/embeddings" payload = { "model": "bge-m3", "input": "lol" } response = requests.post(url, json=payload) print(response.text) ``` run program output ``` {"embedding":[]} ``` ### OS Docker ### GPU Nvidia ### CPU Intel ### Ollama version 0.3.14
GiteaMirror added the bug label 2026-05-04 08:16:49 -05:00
Author
Owner

@rick-github commented on GitHub (Nov 4, 2024):

/api/embeddings is deprecated, use /api/embed. The reason the returned embedding is empty is because /api/embeddings uses prompt not input for the text to process.

<!-- gh-comment-id:2454786332 --> @rick-github commented on GitHub (Nov 4, 2024): `/api/embeddings` is [deprecated](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embedding), use `/api/embed`. The reason the returned embedding is empty is because `/api/embeddings` uses `prompt` not `input` for the text to process.
Author
Owner

@somnifex commented on GitHub (Nov 4, 2024):

/api/embeddings is deprecated, use /api/embed. The reason the returned embedding is empty is because /api/embeddings uses prompt not input for the text to process.

thanks

<!-- gh-comment-id:2454790553 --> @somnifex commented on GitHub (Nov 4, 2024): > `/api/embeddings` is [deprecated](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embedding), use `/api/embed`. The reason the returned embedding is empty is because `/api/embeddings` uses `prompt` not `input` for the text to process. thanks
Author
Owner

@lucid-newt commented on GitHub (Jan 16, 2025):

I had the same issue. /api/embeddings seems to be depreciated, but input is necessary to get embeddings (using prompt returns an empty embedding). At least with Ollama API Version 0.5.4 on Windows 11.

Here is a test script to help anyone with troubleshooting

'''
January 16, 2025
This script tests the Ollama API endpoints for the embedding models.
* Generated with GPT-4.

https://github.com/ollama/ollama/issues/7490
https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md
https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings
'''
import requests
import pprint

EMBEDDING_MODEL: str = "nomic-embed-text:latest"

def get_ollama_api_version():
    url = "http://localhost:11434/api/version"
    try:
        response = requests.get(url, timeout=10)
        if response.status_code == 200:
            data = response.json()
            version = data.get("version", "Version not found")
            print(f"API version: {version}\n")
        else:
            print(f"Failed to get API version. Status code: {response.status_code}")
            return None
    except requests.exceptions.RequestException as e:
        print(f"Error connecting to the version endpoint: {e}")
        return None


def get_ollama_running_models():
    """
    Test the /api/ps endpoint at http://localhost:11434/api/ps.
    """
    url = "http://localhost:11434/api/ps"
    headers = {
        "Content-Type": "application/json"
    }

    try:
        response = requests.get(url, headers=headers, timeout=10)
        if response.status_code == 200:
            data = response.json()
            print("PS response:")
            pprint.pprint(data)
        else:
            print(f"Endpoint returned an error. Status code: {response.status_code}")
            print("Response headers:", response.headers)
            print("Response body:", response.text)
    except requests.exceptions.RequestException as e:
        print(f"Error connecting to the endpoint: {e}")


def test_embedding_endpoint():
    """
    Test the embedding endpoint at http://localhost:11434/api/embeddings.
    """
    url = "http://localhost:11434/api/embed"
    payload = {
        "model": EMBEDDING_MODEL,
        "input": "This is a sample text to test embeddings."
    }
    headers = {
        "Content-Type": "application/json"
    }

    try:
        response = requests.post(url, json=payload, headers=headers, timeout=30)
        if response.status_code == 200:
            data = response.json()
            print(f"\nEmbedding response:")
            pprint.pprint(data)
            if not data.get("embeddings"):
                print("Warning: Embedding is empty.")
            else:
                print(f"Embedding generated successfully.")
        else:
            print(f"Endpoint returned an error. Status code: {response.status_code}")
            print("Response headers:", response.headers)
            print("Response body:", response.text)
    except requests.exceptions.RequestException as e:
        print(f"Error connecting to the endpoint: {e}")


if __name__ == "__main__":
    # Test the API version endpoint
    api_version = get_ollama_api_version()

    # Get the running models
    get_ollama_running_models()

    # Test the embedding endpoint
    test_embedding_endpoint()

Example output:

API version: 0.5.4

PS response:
{'models': [{'details': {'families': ['nomic-bert'],
                         'family': 'nomic-bert',
                         'format': 'gguf',
                         'parameter_size': '137M',
                         'parent_model': '',
                         'quantization_level': 'F16'},
             'digest': '0a109f422b47e3a30ba2b10eca18548e944e8a23073ee3f3e947efcf3c45e59f',
             'expires_at': '2025-01-16T01:31:05.7450267-05:00',
             'model': 'nomic-embed-text:latest',
             'name': 'nomic-embed-text:latest',
             'size': 370002944,
             'size_vram': 0}]}

Embedding response:
{'embeddings': [[0.030008234,
                 0.058340646,
                 -0.16748141,
                  ...
                 -0.01700322]],
 'load_duration': 4340300,
 'model': 'nomic-embed-text:latest',
 'prompt_eval_count': 12,
 'total_duration': 21831900}
Embedding generated successfully.
<!-- gh-comment-id:2594642633 --> @lucid-newt commented on GitHub (Jan 16, 2025): I had the same issue. `/api/embeddings` seems to be depreciated, but `input` is necessary to get embeddings (using `prompt` returns an empty embedding). At least with Ollama API Version 0.5.4 on Windows 11. ## Here is a test script to help anyone with troubleshooting ```python ''' January 16, 2025 This script tests the Ollama API endpoints for the embedding models. * Generated with GPT-4. https://github.com/ollama/ollama/issues/7490 https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings ''' import requests import pprint EMBEDDING_MODEL: str = "nomic-embed-text:latest" def get_ollama_api_version(): url = "http://localhost:11434/api/version" try: response = requests.get(url, timeout=10) if response.status_code == 200: data = response.json() version = data.get("version", "Version not found") print(f"API version: {version}\n") else: print(f"Failed to get API version. Status code: {response.status_code}") return None except requests.exceptions.RequestException as e: print(f"Error connecting to the version endpoint: {e}") return None def get_ollama_running_models(): """ Test the /api/ps endpoint at http://localhost:11434/api/ps. """ url = "http://localhost:11434/api/ps" headers = { "Content-Type": "application/json" } try: response = requests.get(url, headers=headers, timeout=10) if response.status_code == 200: data = response.json() print("PS response:") pprint.pprint(data) else: print(f"Endpoint returned an error. Status code: {response.status_code}") print("Response headers:", response.headers) print("Response body:", response.text) except requests.exceptions.RequestException as e: print(f"Error connecting to the endpoint: {e}") def test_embedding_endpoint(): """ Test the embedding endpoint at http://localhost:11434/api/embeddings. """ url = "http://localhost:11434/api/embed" payload = { "model": EMBEDDING_MODEL, "input": "This is a sample text to test embeddings." } headers = { "Content-Type": "application/json" } try: response = requests.post(url, json=payload, headers=headers, timeout=30) if response.status_code == 200: data = response.json() print(f"\nEmbedding response:") pprint.pprint(data) if not data.get("embeddings"): print("Warning: Embedding is empty.") else: print(f"Embedding generated successfully.") else: print(f"Endpoint returned an error. Status code: {response.status_code}") print("Response headers:", response.headers) print("Response body:", response.text) except requests.exceptions.RequestException as e: print(f"Error connecting to the endpoint: {e}") if __name__ == "__main__": # Test the API version endpoint api_version = get_ollama_api_version() # Get the running models get_ollama_running_models() # Test the embedding endpoint test_embedding_endpoint() ``` ### Example output: ``` API version: 0.5.4 PS response: {'models': [{'details': {'families': ['nomic-bert'], 'family': 'nomic-bert', 'format': 'gguf', 'parameter_size': '137M', 'parent_model': '', 'quantization_level': 'F16'}, 'digest': '0a109f422b47e3a30ba2b10eca18548e944e8a23073ee3f3e947efcf3c45e59f', 'expires_at': '2025-01-16T01:31:05.7450267-05:00', 'model': 'nomic-embed-text:latest', 'name': 'nomic-embed-text:latest', 'size': 370002944, 'size_vram': 0}]} Embedding response: {'embeddings': [[0.030008234, 0.058340646, -0.16748141, ... -0.01700322]], 'load_duration': 4340300, 'model': 'nomic-embed-text:latest', 'prompt_eval_count': 12, 'total_duration': 21831900} Embedding generated successfully. ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#66820