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:
- fti - <http://franz.com/ns/allegrograph/2.2/textindex/>
- geo - <http://franz.com/ns/allegrograph/3.0/geospatial/>
- geofn - <http://franz.com/ns/allegrograph/3.0/geospatial/fn/>
- nd - <http://franz.com/ns/allegrograph/5.0/geo/nd#>
- ndfn - <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
- sna - <http://franz.com/ns/allegrograph/4.11/sna/>
The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.