Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
zjjzyl opened this issue Dec 6, 2024 · 0 comments
Labels
kind/bug Something isn't working

Comments

@zjjzyl
Copy link
Contributor

zjjzyl commented Dec 6, 2024

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

@zjjzyl zjjzyl added the kind/bug Something isn't working label Dec 6, 2024
zjjzyl pushed a commit to zjjzyl/pymilvus that referenced this issue Dec 6, 2024
zjjzyl pushed a commit to zjjzyl/pymilvus that referenced this issue Dec 6, 2024
Signed-off-by: zhoujj20 <zhoujj20@asiainfo.com>
zjjzyl pushed a commit to zjjzyl/pymilvus that referenced this issue Dec 6, 2024
zjjzyl pushed a commit to zjjzyl/pymilvus that referenced this issue Dec 6, 2024
Signed-off-by: jinjuan zhou <zhoujj20@asiainfo.com>
sre-ci-robot pushed a commit that referenced this issue Dec 23, 2024
### What this PR does:
Fixes a bug in `examples/milvus_model/hello_model.py` where indexing a
sparse matrix with `x[0]` caused a `NotImplementedError`.

### Changes made:
- Updated the sparse matrix indexing from `x[0]` to `x[:, [0]]` to use
explicit 2D indexing, which is supported.

Signed-off-by: jinjuan zhou <zhoujj20@asiainfo.com>
Co-authored-by: jinjuan zhou <zhoujj20@asiainfo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant