Skip to content

[Bug]: NotImplementedError: We have not yet implemented 1D sparse slices; please index using explicit indices, e.g. x[:, [0]] #2414

@zjjzyl

Description

@zjjzyl

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When running the script examples/milvus_model/hello_model.py with the sparse vector model example, I encountered the following error:
NotImplementedError: We have not yet implemented 1D sparse slices; please index using explicit indices, e.g. x[:, [0]]

Expected Behavior

The script should execute successfully and return the expected results for sparse vector operations.

Steps/Code To Reproduce behavior

from pymilvus.model.sparse import BM25EmbeddingFunction, SpladeEmbeddingFunction
from pymilvus.model.hybrid import BGEM3EmbeddingFunction
fmt = "=== {:30} ==="

docs = [
    "Artificial intelligence was founded as an academic discipline in 1956.",
    "Alan Turing was the first person to conduct substantial research in AI.",
    "Born in Maida Vale, London, Turing was raised in southern England.",
]

# BM25EmbeddingFunction usage
print(fmt.format("BM25EmbeddingFunction Usage"))
ef_bm25 = BM25EmbeddingFunction()
ef_bm25.load()
embs_bm25 = ef_bm25.encode_documents(docs)
print(f"Embedding Shape: {embs_bm25[0].shape} Dimension: {ef_bm25.dim}")

# -----------------------------------------------------------------------------
# SpladeEmbeddingFunction usage
print(fmt.format("SpladeEmbeddingFunction Usage"))
ef_splade = SpladeEmbeddingFunction(device="cpu")
embs_splade = ef_splade(["Hello world", "Hello world2"])
print(f"Embedding Shape: {embs_splade[0].shape} Dimension: {ef_splade.dim}")

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):cpu
- Method of installation (Docker, or from source):source
- Milvus version (v0.3.1, or v0.4.0):2.5.0
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

no

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions