googleapis / googleapis/langchain-google-spanner-python
SpannerGraphVectorContextRetriever doesn't support Approximate Nearest Neighbor search
@gauravpurohit06 ya está trabajando en esto.
Desde el 13/3/2025.
- Lenguaje dominante
- Python
- Estrellas
- 44
- Forks
- 24
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
- Search the issues already opened: https://github.com/googleapis/langchain-google-spanner-python/issues
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python
If you are still having issues, please be sure to include as much information as possible:
Environment details
- OS type and version: MacOS Darwin Kernel Version 23.6.0 arm64
- Python version: 3.12.9
- pip version: pip 25.0.1
langchain-google-spannerversion: 0.8.1
Steps to reproduce
I'm unable to use APPROX_DOT_PRODUCT metric for vector search in the SpannerGraphVectorContextRetriever. Upon checking the implementation, I found that the __get_distance_function only supports COSINE and EUCLIDEAN distance.
def __get_distance_function(
self, distance_strategy=DistanceStrategy.EUCLIDEAN
) -> str:
"""Gets the vector distance function."""
if distance_strategy == DistanceStrategy.COSINE:
return "COSINE_DISTANCE"
return "EUCLIDEAN_DISTANCE"
Here is an example Spanner Graph query I'm trying to create.
GRAPH TestGraph
MATCH (node:Node1)
WHERE node.embedding is not NULL
ORDER BY APPROX_DOT_PRODUCT(node.embedding, ARRAY<FLOAT32>[
-0.036149498,
0.07207133,
-0.020961108,
-0.005176733,
0.047590617,
0.006568967,
-0.047031555,
0.04741984
],
OPTIONS => JSON '{"num_leaves_to_search": 5}') DESC
LIMIT 5
RETURN node.col1, node.col2;
Can you help me in how can I create a Spanner Graph query which uses Approximate Nearest Neighbors vector index.
Thanks!
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.