FalkorDB / FalkorDB

A super fast Graph Database uses GraphBLAS under the hood for its sparse adjacency matrix graph representation. Our goal is to provide the best Knowledge Graph for LLM (GraphRAG).

Home Page:https://www.falkordb.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CALL to db.idx.vector.queryRelationships not returning score (always 0)

schwab opened this issue · comments

I'm testing this on falkor db version:

Modules

module:name=graph,ver=40001,api=1,filters=0,usedby=[],using=[],options=[]

(Also tried with docker's falkordb:edge

There appear to be 2 presented ways to use db.idx.vector to call for matches.
The first is on the blog page: https://www.falkordb.com/blog/falkordb-4-0-0-first-milestone

Which appears gives results, but does not return the similarity score. In this case one of the values it returns is what I'd call a close match, but it's unclear based on the payload which is the best match, or how close to each other they are.

For example this query using db.idx.vector.query with a type of RELATIONSHIP always gives a 0 for the score:

CALL db.idx.vector.query({type:'RELATIONSHIP', label:'is_a', attribute:'vector', query:vector32f([-0.05033291503787041, 0.06810781359672546, -0.034139279276132584, 0.047742538154125214, -0.05636652931571007, 0.03344268724322319, -0.01769072748720646, -0.05538520589470863, 0.003390759928151965, -0.04393560439348221]), k:12}) YIELD entity, score MATCH (c:Clinician)-[r]->() WHERE r = entity RETURN  entity, score
   1) 1) "entity"
   2) "score"
2) 1) 1) 1) 1) "id"
            2) "372"
         2) 1) "type"
            2) "is_a"
         3) 1) "src_node"
            2) "11"
         4) 1) "dest_node"
            2) "19"
         5) 1) "properties"
            2) 1) 1) "description"
                  2) "Al%20Rstum%2C%20Zainulabdeen%20MD%20is%20a%20Primary%20Surgeon%20in%20the%20or_advisor_mhhs%20topic."
               2) 1) "vector"
                  2) "<-0.030863, 0.063076, -0.065760, -0.005678, -0.093262, -0.032395, -0.052681, -0.006623, -0.044823, -0.011993>"
      2) "0"
   2) 1) 1) 1) "id"
            2) "867"
         2) 1) "type"
            2) "is_a"
         3) 1) "src_node"
            2) "71"
         4) 1) "dest_node"
            2) "19"
         5) 1) "properties"
            2) 1) 1) "description"
                  2) "Black%2C%20Dalliah%20Mashon%20MD%20is%20a%20Primary%20Surgeon%20in%20the%20or_advisor_mhhs%20topic."
               2) 1) "vector"
                  2) "<-0.055951, 0.052131, -0.024289, 0.034946, -0.082955, -0.008182, -0.071409, -0.014381, -0.054078, -0.050569>"
      2) "0"
   3) 1) 1) 1) "id"
            2) "782"
         2) 1) "type"
            2) "is_a"
         3) 1) "src_node"
            2) "153"
         4) 1) "dest_node"
            2) "19"
         5) 1) "properties"
            2) 1) 1) "description"
                  2) "Dimachkieh%2C%20Omar%20Saad%20MD%20is%20a%20Primary%20Surgeon%20in%20the%20or_advisor_mhhs%20topic."
               2) 1) "vector"
                  2) "<-0.033705, 0.002309, -0.033583, 0.006068, -0.038070, 0.010948, -0.049151, 0.013273, -0.023922, -0.005145>"
      2) "0"

So I also found there is a different method documented in graph.query.md called queryRelationships . However using that one also does not give the score (always 0):

Example:

CALL db.idx.vector.queryRelationships('is_a','vector',10, vecf32([-0.05033291503787041, 0.06810781359672546, -0.034139279276132584, 0.047742538154125214, -0.05636652931571007, 0.03344268724322319, -0.01769072748720646, -0.05538520589470863, 0.003390759928151965, -0.04393560439348221])) YIELD relationship, score
1) 1) "relationship"
   2) "score"
2) 1) 1) 1) 1) "id"
            2) "867"
         2) 1) "type"
            2) "is_a"
         3) 1) "src_node"
            2) "71"
         4) 1) "dest_node"
            2) "19"
         5) 1) "properties"
            2) 1) 1) "description"
                  2) "Black%2C%20Dalliah%20Mashon%20MD%20is%20a%20Primary%20Surgeon%20in%20the%20or_advisor_mhhs%20topic."
               2) 1) "vector"
                  2) "<-0.055951, 0.052131, -0.024289, 0.034946, -0.082955, -0.008182, -0.071409, -0.014381, -0.054078, -0.050569>"
      2) "0"

Is there another way to enable the similarity score?

@schwab thanks for pointing it out.
The Blog is outdated (we'll fix it) and the API was changed since the first alpha.

Please see the docs:
https://docs.falkordb.com/commands/graph.query.html#query-vector-index

Hi @schwab,
Sorry for the confusion. we've made a slight modification to the Vector Query API documented here

With regard to the scoring, my apologies it seems like indeed there's a bug there, I'm currently working on fixing it.
the score output will hold the distance of the current entity vector and the query vector.

Once this fix is implemented I'll close this issue.

Thanks Roi. I was hoping to use the score for a sort order or perhaps to filter out results that are "too far" away.

Also, I changed the title to reflect the missing score, because the "procedure not registered" goes way when you use the edge release.

I just pulled latest and tested. Scores are coming back. Thanks for the quick turn around!