import Azure HnswVectorSearchAlgorithmConfiguration comes Error: cannot import name 'HnswVectorSearchAlgorithmConfiguration'

huangapple go评论245阅读模式
英文:

import Azure HnswVectorSearchAlgorithmConfiguration comes Error: cannot import name 'HnswVectorSearchAlgorithmConfiguration'

问题

以下是您要翻译的部分:

"Here is the reference document I follow with:
https://esteininger.medium.com/building-a-vector-search-engine-using-hnsw-and-cosine-similarity-753fb5268839
&
https://github.com/Azure/cognitive-search-vector-pr/blob/main/demo-python/code/azure-search-vector-python-sample.ipynb

from azure.search.documents.models import Vector
from azure.search.documents.indexes.models import (
SearchIndex,
SearchField,
SearchFieldDataType,
SimpleField,
SearchableField,
SearchIndex,
SemanticConfiguration,
PrioritizedFields,
SemanticField,
SearchField,
SemanticSettings,
VectorSearch,
HnswVectorSearchAlgorithmConfiguration
)

enter image description here

At first, I faced import error which is about import Vector. I saw its solution on stackoverflow by updating azure.search.documents to the version ==11.4.0b6; While HnswVectorSearchAlgorithmConfiguration would be alwasy error no matter which version I used. I've tried azure.search.documents 11.4.0b6 and 11.4.0b4

If the import error remain unsolved, the folling part would be error too.

vector_search = VectorSearch(

algorithm_configurations=[

    HnswVectorSearchAlgorithmConfiguration(

        name="my-vector-config",

        kind="hnsw",

        parameters={

            "m": 4,

            "efConstruction": 400,
            "efSearch": 500,
            "metric": "cosine"
        }
    )
]

)

I also tried to walkaround by import hnswlib, but it didn't work...
enter image description here

If someone has conquer this issue, please let me know. Thank you!

英文:

Here is the reference document I follow with:
https://esteininger.medium.com/building-a-vector-search-engine-using-hnsw-and-cosine-similarity-753fb5268839
&
https://github.com/Azure/cognitive-search-vector-pr/blob/main/demo-python/code/azure-search-vector-python-sample.ipynb

from azure.search.documents.models import Vector
from azure.search.documents.indexes.models import (  
    SearchIndex,  
    SearchField,  
    SearchFieldDataType,  
    SimpleField,  
    SearchableField,  
    SearchIndex,  
    SemanticConfiguration,  
    PrioritizedFields,  
    SemanticField,  
    SearchField,  
    SemanticSettings,  
    VectorSearch, 
    HnswVectorSearchAlgorithmConfiguration 
)

enter image description here

At first, I faced import error which is about import Vector. I saw its solution on stackoverflow by updating azure.search.documents to the version ==11.4.0b6; While HnswVectorSearchAlgorithmConfiguration would be alwasy error no matter which version I used. I've tried azure.search.documents 11.4.0b6 and 11.4.0b4

If the import error remain unsolved, the folling part would be error too.

vector_search = VectorSearch(

    algorithm_configurations=[

        HnswVectorSearchAlgorithmConfiguration(

            name="my-vector-config",

            kind="hnsw",

            parameters={

                "m": 4,

                "efConstruction": 400,
                "efSearch": 500,
                "metric": "cosine"
            }
        )
    ]
)

I also tried to walkaround by import hnswlib, but it didn't work...
enter image description here

If someone has conquer this issue, please let me know. Thank you!

答案1

得分: 2

使用 Azure Cognitive Search 的向量功能,您无需单独安装 hnswlib。

您可以确保使用最新的 azure-search-documents pip 包吗?

尝试 pip install azure-search-documents --pre --upgrade

包含向量搜索功能的最新 Python SDK 预发行版本可以在此处找到:https://pypi.org/project/azure-search-documents/11.4.0b8/

英文:

Using Azure Cognitive Search’s Vector feature you don’t have to install hnswlib separately.

Can you ensure you’re using the latest azure-search-documents pip package?

Try pip install azure-search-documents --pre --upgrade.

The latest Python SDK pre-release version that includes Vector search capabilities can be found here: https://pypi.org/project/azure-search-documents/11.4.0b8/

答案2

得分: 0

继续Farzzy的有用回答:

我遇到了同样的问题,对我来说只运行以下命令并没有解决问题:

pip install azure-search-documents --pre --upgrade

所以我还运行了以下命令之一:

pip install azure-search --pre --upgrade
pip install azure-core --pre --upgrade

其中一个命令解决了这个问题。

英文:

Continuing Farzzy's helpful answer:

I had the same issue, For me just running
pip install azure-search-documents --pre --upgrade
didn't fix it, so I also ran the following commands:

pip install azure-search --pre --upgrade
pip install azure-core --pre --upgrade

And one of them fixed that.

huangapple
  • 本文由 发表于 2023年8月10日 16:11:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76873793.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定