Skip to content

Commit

Permalink
Add friendly setup instructions to hello_hybrid_sparse_dense.py (#1995)
Browse files Browse the repository at this point in the history
Signed-off-by: Author Name <[email protected]>

Signed-off-by: codingjaguar <[email protected]>
  • Loading branch information
codingjaguar authored Mar 21, 2024
1 parent 16d70d7 commit c6c162e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions examples/hello_hybrid_sparse_dense.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# A demo showing hybrid semantic search with dense and sparse vectors using Milvus.
# You can optionally choose to use the BGE-M3 model to embed the text as dense
# and sparse vectors, or simply use random generated vectors as the example.

# To use BGE-M3 model, you need to install the optional `model` module in pymilvus:
# and sparse vectors, or simply use random generated vectors as an example.
# Note that the sparse vector search feature is only available in Milvus 2.4.0 or
# higher version. Make sure you follow https://milvus.io/docs/install_standalone-docker.md
# to set up the latest version of Milvus in your local environment.

# To connect to Milvus server, you need the python client library called pymilvus.
# To use BGE-M3 model, you need to install the optional `model` module in pymilvus.
# You can get them by simply running the following commands:
# pip install pymilvus
# pip install pymilvus[model]

# If true, use BGE-M3 model to generate dense and sparse vectors.
# If false, use random numbers to compose dense and sparse vectors.
use_bge_m3 = True

# The overall steps are as follows:
Expand Down Expand Up @@ -112,4 +121,4 @@ def random_embedding(texts):
# text: Artificial intelligence was founded as an academic discipline in 1956. distance 0.016129031777381897

# Drop the collection to clean up the data.
utility.drop_collection(col_name)
utility.drop_collection(col_name)

0 comments on commit c6c162e

Please sign in to comment.