googleapis / googleapis/langchain-google-spanner-python

SpannerGraphVectorContextRetriever doesn't support Approximate Nearest Neighbor search

Aperta
#163 0 commenti 0 reazioni 1 assegnatario Rivendicata da @gauravpurohit06 Vedi su GitHub
api: spanner
Lingua principale
Python
Stelle
44
Fork
24
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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](https://cloud.google.com/support/) 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-spanner` version: 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.
```python
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.
```sql
GRAPH TestGraph
MATCH (node:Node1)
WHERE node.embedding is not NULL
ORDER BY APPROX_DOT_PRODUCT(node.embedding, ARRAY[
-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!

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.