# 使用英文 docs_en = [ "Machine learning is changing our way of life.", "Deep learning performs exceptionally well in image recognition.", "Natural language processing is an important field in computer science.", "Autonomous driving relies on advanced algorithms.", "AI can help doctors diagnose diseases.", "Data analysis technology is widely applied in the financial field.", "Production efficiency can be improved through automation technology.", "The future of machine intelligence is full of potential.", "Big data support is key to the development of machine intelligence.", "The quantum tunneling effect allows electrons to pass through potential barriers that classical mechanics consider impassable, which has important applications in semiconductor devices." ]
生成文档集合的稀疏向量:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
from pymilvus.model.sparse import SpladeEmbeddingFunction
query_en = ["How does artificial intelligence affect the automotive industry?"]
# 打印向量搜索结果 defprint_vector_results(res): for hits in res: for hit in hits: entity = hit.get("entity") print(f"text: {entity['text']}") print(f"distance: {hit['distance']:.3f}") print("-"*50) print(f"数量:{len(hits)}")
# 打印向量搜索结果 defprint_vector_results_en(res): for hits in res: for hit in hits: entity = hit.get("entity") print(f"text_en: {entity['text_en']}") print(f"distance: {hit['distance']:.3f}") print("-"*50) print(f"数量:{len(hits)}")
然后使用 splade 搜索。
1 2 3 4 5 6 7 8 9
query1_en = ["How does artificial intelligence affect the automotive industry?"]
text_en: The future of machine intelligence is full of potential. distance: 10.020 -------------------------------------------------- text_en: Big data support is key to the development of machine intelligence. distance: 8.232 -------------------------------------------------- text_en: AI can help doctors diagnose diseases. distance: 7.291 -------------------------------------------------- text_en: Autonomous driving relies on advanced algorithms. distance: 7.213 -------------------------------------------------- text_en: Production efficiency can be improved through automation technology. distance: 6.999 -------------------------------------------------- text_en: Machine learning is changing our way of life. distance: 6.863 -------------------------------------------------- text_en: Data analysis technology is widely applied in the financial field. distance: 5.064 -------------------------------------------------- text_en: The quantum tunneling effect allows electrons to pass through potential barriers that classical mechanics consider impassable, which has important applications in semiconductor devices. distance: 3.695 -------------------------------------------------- text_en: Deep learning performs exceptionally well in image recognition. distance: 3.464 -------------------------------------------------- text_en: Natural language processing is an important field in computer science. distance: 3.044 -------------------------------------------------- 数量:10
text_en: The future of machine intelligence is full of potential. distance: 15.128 -------------------------------------------------- text_en: Big data support is key to the development of machine intelligence. distance: 12.945 -------------------------------------------------- text_en: Machine learning is changing our way of life. distance: 12.763 -------------------------------------------------- text_en: Production efficiency can be improved through automation technology. distance: 7.446 -------------------------------------------------- text_en: AI can help doctors diagnose diseases. distance: 6.055 -------------------------------------------------- text_en: Autonomous driving relies on advanced algorithms. distance: 5.309 -------------------------------------------------- text_en: Data analysis technology is widely applied in the financial field. distance: 4.857 -------------------------------------------------- text_en: The quantum tunneling effect allows electrons to pass through potential barriers that classical mechanics consider impassable, which has important applications in semiconductor devices. distance: 3.356 -------------------------------------------------- text_en: Deep learning performs exceptionally well in image recognition. distance: 3.317 -------------------------------------------------- text_en: Natural language processing is an important field in computer science. distance: 2.688 -------------------------------------------------- 数量:10