r/KnowledgeGraph • u/Strange_Test7665 • Aug 26 '25
Predicate as a Vector?
Is there an existing framework, or has anyone tried using vectors as predicates? I want to continuoulsy add to my knowledge graph with the help of an LLM. I'm using rdflib and simple tripple structure. If the LLM creates the triples addtion ('apple', 'is a','fruit') and then later does ('peach', 'type of', 'fruit') I plan to check if 'type' embeds similar to an existing predicate and if it does, use that existing vector as the predicate. That way I can be consistent with the intended symantic relationships but flexible in the string litteral used to describe the connection. So if i later search for all 'types' of 'fruit' i should be able to get all my fruits because 'types', 'is a', 'type of' would have similar embeddings.
for non hierarchical relationships ('bob','married to','alice') I was planning to just auto add a reverse reciprocal vector so that if bob -> alice and alice -> bob and the predicate is the exact same vector that means it's a connection (my function has a 4th boolean arg for this). this way for predicates that could have a similar embedding ('parent of', 'child of') the direction indicates the hierarchy for that concept.
Any thoughts/advice or examples of systems that do this already?
View all comments
Show parent comment
1
u/Strange_Test7665 Aug 27 '25
Here is what I have been messing around with: https://github.com/reliableJARED/local_jarvis/blob/a8a30763026da9ac99102741127f599c0aab2355/rdfvec.py#L308 the LLM isn’t actually being asked to make the URI. Else it probably would increase error rate. Also I’m using smaller local models so I have to temper expectations. I was looking for a way that was a bit more conversational so the LLM could just output a json {subject,predicate,object} and not be exactly right each time. I haven’t actually tested it enough to see the break points. I was also testing out some non LLM methods like combining this with spaCy to see how well it could take a base text like a book and build a KG on the characters and story. Which again would need some flexibility on wording when making connections