relate asks what Jev knows about the names.
relate gets a list of names and their kinds, and no text. Jev answers from what it knows. recognize --relation links names by what a text states.
Here four people, five songs, and three albums go in. The rules file names two relations. sings runs from a person to a song, and it asks one yes or no question for each pair. One person sings the lead on many songs. on_album runs from a song to an album. A song first appears on one album, so the rule says "single": true. It asks one menu for each song: which listed album, or none of these. Every answer at 0.5 or more comes out as an edge.
{"name":"John Lennon","kind":"person"}
{"name":"Paul McCartney","kind":"person"}
{"name":"George Harrison","kind":"person"}
{"name":"Ringo Starr","kind":"person"}
{"name":"Come Together","kind":"song"}
{"name":"Yesterday","kind":"song"}
{"name":"Something","kind":"song"}
{"name":"Taxman","kind":"song"}
{"name":"Octopus's Garden","kind":"song"}
{"name":"Help!","kind":"album"}
{"name":"Revolver","kind":"album"}
{"name":"Abbey Road","kind":"album"}{
"version": 1,
"relate": {
"relations": [
{
"name": "sings",
"source": "person",
"target": "song",
"reads": "sings the lead vocal on"
},
{
"name": "on_album",
"source": "song",
"target": "album",
"reads": "is on the album",
"single": true
}
]
}
}Run it
thinkthen relate @rules.json \
--jsonl \
--input names.jsonl \
--replay recording |
jq -c '[.source.name, .relation,
.target.name, .probability]'["John Lennon","sings","Come Together",0.8] ["Paul McCartney","sings","Yesterday",0.84] ["George Harrison","sings","Something",0.89] ["Ringo Starr","sings","Octopus's Garden",0.94] ["Come Together","on_album","Abbey Road",1.0] ["Yesterday","on_album","Help!",0.62] ["Something","on_album","Abbey Road",0.98] ["Taxman","on_album","Revolver",0.97] ["Octopus's Garden","on_album","Revolver",0.91]
Change the bar
thinkthen relate @rules.json \
--jsonl \
--input names.jsonl \
--threshold 0.8 \
--replay recording |
jq -c '[.source.name, .relation,
.target.name, .probability]'["John Lennon","sings","Come Together",0.8] ["Paul McCartney","sings","Yesterday",0.84] ["George Harrison","sings","Something",0.89] ["Ringo Starr","sings","Octopus's Garden",0.94] ["Come Together","on_album","Abbey Road",1.0] ["Something","on_album","Abbey Road",0.98] ["Taxman","on_album","Revolver",0.97] ["Octopus's Garden","on_album","Revolver",0.91]
The lesson
One of the nine edges is wrong. Jev puts Octopus's Garden on Revolver at 0.91. It first appeared on Abbey Road. No edge says who sings Taxman. George sings it, and Jev's answer fell under the bar. At 0.8, Yesterday on Help! drops out at 0.62, and it is right. The wrong edge stays.
A menu gives each song one album. A bar of 0.8 keeps the confident wrong answer.
On GitHub: github.com/botassembly/beatles-bench/tree/main/examples/relate