nicholasveloso commented on issue #1121:
URL: https://github.com/apache/age/issues/1121#issuecomment-3738681942

   > WIP as i mess with it more
   > 
   > # Apache AGE + pgvector 
   > 
   > 
   > - **Apache AGE** (`age`) for Cypher queries
   > - **pgvector** (`vector`) for vector operations + ANN indexes
   > 
   > 
   > ## Required session setup
   > 
   > AGE requires loading the extension and setting `search_path`:
   > 
   > ```sql
   > LOAD 'age';
   > SET search_path = ag_catalog, public;
   > ```
   > 
   > Why `public`?
   > - `vector` is installed into the `public` schema in our stack
   > - Cypher queries that cast to `::vector` (or call distance functions) need 
`public` visible
   > - vector ops fail when `public` isn’t in the `search_path`, and start 
working once it is.
   > 
   > ## Basic Cypher execution from SQL
   > 
   > AGE is called through `cypher(graph_name, $$ ... $$)` and you must provide 
an `AS (...)` return type list:
   > 
   > ```sql
   > SELECT * FROM cypher('my_graph', $$ MATCH (n) RETURN n $$) AS (n agtype);
   > ```
   > 
   > ## Vector casts and operators inside Cypher
   > 
   > From the regression test, these casts are supported:
   > 
   > - `"[1.22,2.22,3.33]"::vector`
   > - `[1.22,2.22,3.33]::vector`
   > - `...::vector(3)` (dimension constrained)
   > 
   > And ordering by cosine distance works via the `<=>` operator:
   > 
   > ```sql
   > SELECT * FROM cypher('graph', $$
   >   MATCH (m:Movie)
   >   RETURN m.title
   >   ORDER BY m.embedding::vector(4) <=> [-0.1, 0.2, 0.3, -0.4]::vector(4)
   >   ASC LIMIT 10
   > $$) AS (title agtype);
   > ```
   > 
   > ## Vector indexes (HNSW) on AGE vertex properties
   > 
   > The regression test demonstrates creating a HNSW index on a vertex 
property by building an expression that extracts the property and casts it to 
`vector(N)`:
   > 
   > 1) Find the internal schema OID for the AGE graph
   > 2) `CREATE INDEX ... USING hnsw ((... )::vector(N)) vector_cosine_ops;`
   > 
   > This is the core recipe to make vector similarity in AGE fast.
   > 
   > 
   > 
   
   Am I right in interpreting that this only work woth 3-dimension vectors? Or 
does it it support N-mrnsional vectors?
   
   In ML, AI and Gen AI, vectors sizes are usualy in the order of tihousands 
dimension. For example,thr LLMs embedding vectors are in the order of 1500+ 
dimensions for smaller model, or 3000+ dimensions for larger models.
   
   If this method works with N-domensional vectors, it would be a great 
addition to the Apache AGE project and its community. And maybe it finally 
opens up the portunity to use AGE as graph database for both of my startups. 
   
   We are looking for an OSS graph database that can de as competitive as Neo4j 
a GraphDB and AWS Neptune, but thus far ageT was the closest databe to what we 
need, but the lack of ways for using vectors and vector embeddings is the only 
thing that is a d ql breaker for us. We already use pgvector as our vectorstore 
so integrating it with AGE would be the best case a scenario. Specialy if we 
eventually manage to generate graph embeddings using AGE ans pgvector.
   
   King regards, 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to