http://franz.com/ns/allegrograph/8.0.0/llm/similarity

Compute the dot product of the embeddings of two strings. The strings can be literal strings or objects in the vector store. An object is a resource such as http://franz.com/vdb/id/298. Given a string its embedding will be calculated. Given an object the embedding is known and stored in the vector database.

This operation only works when run on a vector triple store.

This example shows how to scan all objects in a vector store and return in order those objects whose text string most closely has a meaning close to "poverty".

prefix vdb: <http://franz.com/vdb/gen/>  
prefix llm: <http://franz.com/ns/allegrograph/8.0.0/llm/>  
select * {  
  ?obj a vdb:Object .  
  ?obj vdb:text ?text .  
  ?similar llm:similarity (?obj "poverty") .  
  filter (?similar > 0.4)  
 }  
order by desc (?similar)  

Notes

The following namespace abbreviations are used:

The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.