Skip to content

Commit

Permalink
fix: Fix sparse slice bug in hello_model.py(milvus-io#2414)
Browse files Browse the repository at this point in the history
Signed-off-by: jinjuan zhou <[email protected]>
  • Loading branch information
jinjuan zhou committed Dec 6, 2024
1 parent a225cbf commit 92bd144
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions examples/milvus_model/hello_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,16 @@ def log(msg):
# BM25EmbeddingFunction usage
log(fmt.format("BM25EmbeddingFunction Usage"))
ef_bm25 = BM25EmbeddingFunction()
docs_bm25 = [
"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.",
]
ef_bm25.load()
embs_bm25 = ef_bm25.encode_documents(docs)
log(f"Embedding Shape: {embs_bm25[0].shape} Dimension: {ef_bm25.dim}")
log(f"Embedding Shape: {embs_bm25[:, [0]].shape} Dimension: {ef_bm25.dim}")

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

# -----------------------------------------------------------------------------
log(fmt.format("Demonstrations Finished"))

0 comments on commit 92bd144

Please sign in to comment.