Closed G-walk closed 1 month ago
https://milvus.io/docs/v2.3.x/example_code.md 你能试一下这个吗,看一下直接连接milvus有没有问题?
试了链接里的代码,直连似乎没什么问题:
python .\hello_milvus.py
=== start connecting to Milvus ===
Does collection hello_milvus exist in Milvus: False
=== Create collection `hello_milvus` ===
=== Start inserting entities ===
Number of entities in Milvus: 3001
=== Start Creating index IVF_FLAT ===
=== Start loading ===
=== Start searching based on vector similarity ===
hit: id: 2998, distance: 0.0, entity: {'random': 0.9728033590489911}, random field: 0.9728033590489911
hit: id: 999, distance: 0.09934990108013153, entity: {'random': 0.9519034206569449}, random field: 0.9519034206569449
hit: id: 1310, distance: 0.10135538130998611, entity: {'random': 0.26669865443188623}, random field: 0.26669865443188623
hit: id: 2999, distance: 0.0, entity: {'random': 0.02316334456872482}, random field: 0.02316334456872482
hit: id: 2502, distance: 0.13083189725875854, entity: {'random': 0.9289998713260136}, random field: 0.9289998713260136
hit: id: 2669, distance: 0.1590736359357834, entity: {'random': 0.6080847854541138}, random field: 0.6080847854541138
search latency = 0.2353s
=== Start querying with `random > 0.5` ===
query result:
-{'random': 0.6378742006852851, 'embeddings': [np.float32(0.8367804), np.float32(0.20963514), np.float32(0.6766955), np.float32(0.39746654), np.float32(0.8180806), np.float32(0.1201905), np.float32(0.9467144), np.float32(0.6947491)], 'pk': '0'}
search latency = 0.4097s
query pagination(limit=4):
[{'pk': '0', 'random': 0.6378742006852851}, {'pk': '100', 'random': 0.5763523024650556}, {'pk': '1000', 'random': 0.9425935891639464}, {'pk': '1001', 'random': 0.7893211256191387}]
query pagination(offset=1, limit=3):
[{'random': 0.5763523024650556, 'pk': '100'}, {'random': 0.9425935891639464, 'pk': '1000'}, {'random': 0.7893211256191387, 'pk': '1001'}]
=== Start hybrid searching with `random > 0.5` ===
hit: id: 2998, distance: 0.0, entity: {'random': 0.9728033590489911}, random field: 0.9728033590489911
hit: id: 999, distance: 0.09934990108013153, entity: {'random': 0.9519034206569449}, random field: 0.9519034206569449
hit: id: 1553, distance: 0.12913644313812256, entity: {'random': 0.7723335927084438}, random field: 0.7723335927084438
hit: id: 2502, distance: 0.13083189725875854, entity: {'random': 0.9289998713260136}, random field: 0.9289998713260136
hit: id: 2669, distance: 0.1590736359357834, entity: {'random': 0.6080847854541138}, random field: 0.6080847854541138
hit: id: 2628, distance: 0.1914074718952179, entity: {'random': 0.940077754658375}, random field: 0.940077754658375
search latency = 0.4089s
=== Start deleting with expr `pk in ["0" , "1"]` ===
query before delete by expr=`pk in ["0" , "1"]` -> result:
-{'random': 0.6378742006852851, 'embeddings': [np.float32(0.8367804), np.float32(0.20963514), np.float32(0.6766955), np.float32(0.39746654), np.float32(0.8180806), np.float32(0.1201905), np.float32(0.9467144), np.float32(0.6947491)], 'pk': '0'}
-{'random': 0.43925103574669633, 'embeddings': [np.float32(0.27875876), np.float32(0.95355743), np.float32(0.976228), np.float32(0.54545516), np.float32(0.16776836), np.float32(0.82360446), np.float32(0.65080017), np.float32(0.21096307)], 'pk': '1'}
query after delete by expr=`pk in ["0" , "1"]` -> result: []
=== Drop collection `hello_milvus` ===
哦我找到问题在哪了,我使用的是windows powershell运行的cli.py
,因为途中有步骤需要连hugging face所以我给powershell设置了代理$env:HTTP_PROXY="xxxx"
,设置完代理后能连接上hugging face但是就连不上本地的milvus了。我之后试试用别的方式设置代理,看看能不能绕过这个问题。
感谢作者,不是你提供的直连方案我也找不出这个问题
试试 export HF_ENDPOINT=https://hf-mirror.com
这个可以,或者直接让代理绕过本地地址也行:
# os.environ['http_proxy'] = "<proxy>"
# os.environ['https_proxy'] = "<proxy>"
# os.environ['no_proxy'] = 'localhost,127.0.0.1'
另外访问太多hugging face好像会被ban ip……我直接把bge-base-zh-v1.5
和bge-reranker-large
下载到本地用了。
然后如果模型不用chatgpt换成国内的模型(比如qwen)的话就可以彻底告别代理了。
程序运行得很顺利,comment closed
作者您好,我在运行
cli.py
,并进行build
后发生如下错误,不知道该怎么解决:我运行
docker ps
后发现Milvus服务应该是正常运行的: