-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
52 lines (40 loc) · 1.54 KB
/
Copy pathtasks.py
File metadata and controls
52 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Symbolic task definitions.
Everything a learning system sees — lessons, questions, answers — is expressed
as integer token IDs over a closed-world vocabulary. This keeps the evaluation
substrate language-agnostic and stops architectures from accidentally cheating
with surface-form tricks.
"""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class Fact:
subject: int
relation: int
object: int
@dataclass
class Lesson:
idx: int
facts: list[Fact]
@dataclass(frozen=True)
class Question:
qid: int
kind: str # "recall" | "composition" | "composition_3hop" | "negative"
subject: int
relation: int
source_lessons: tuple[int, ...] # lessons that taught the facts this Q depends on
relation2: int | None = None # composition / composition_3hop: second hop relation
relation3: int | None = None # composition_3hop: third hop relation
candidate: int | None = None # negative: proposed object to verify
gold_object: int | None = None # recall / composition / composition_3hop: expected object id
gold_is_true: bool | None = None # negative: is (s, r, candidate) a real taught fact?
@dataclass
class Answer:
predicted_object: int | None = None
predicted_is_true: bool | None = None
@dataclass
class Dataset:
vocab: dict[int, str] # token id -> invented word
lessons: list[Lesson]
questions: list[Question]
entity_ids: list[int]
relation_ids: list[int]