OntoLAMA
run_inference(config, args)
Main entry for running the OpenPrompt script.
Source code in src/deeponto/complete/ontolama/inference.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
SubsumptionSamplerBase(onto)
Base Class for Sampling Subsumption Pairs.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
30 31 32 33 34 35 36 37 38 39 40 41 |
|
random_named_concept()
Randomly draw a named concept's IRI.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
43 44 45 |
|
random_object_property()
Randomly draw a object property's IRI.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
47 48 49 |
|
get_siblings(concept_iri)
Get the sibling concepts of the given concept.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
51 52 53 54 55 56 |
|
random_sibling(concept_iri)
Randomly draw a sibling concept for a given concept.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
58 59 60 61 62 63 64 65 |
|
AtomicSubsumptionSampler(onto)
Bases: SubsumptionSamplerBase
Sampler for constructing the Atomic Subsumption Inference (SI) dataset.
Positive samples come from the entailed subsumptions.
Soft negative samples come from the pairs of randomly selected concepts, subject to passing the assumed disjointness check.
Hard negative samples come from the pairs of randomly selected sibling concepts, subject to passing the assumed disjointness check.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
88 89 90 91 92 93 94 95 |
|
positive_sampling(num_samples=None)
Sample named concept pairs that are involved in a subsumption axiom.
An extracted pair \((C, D)\) indicates \(\mathcal{O} \models C \sqsubseteq D\) where \(\mathcal{O}\) is the input ontology.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
negative_sampling(negative_sample_type, num_samples, apply_assumed_disjointness_alternative=True)
Sample named concept pairs that are involved in a disjoiness (assumed) axiom, which then implies non-subsumption.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
ComplexSubsumptionSampler(onto)
Bases: SubsumptionSamplerBase
Sampler for constructing the Complex Subsumption Inference (SI) dataset.
To obtain complex concept expressions on both sides of the subsumption relationship (as a sub-concept or a super-concept), this sampler utilises the equivalence axioms in the form of \(C \equiv C_{comp}\) where \(C\) is atomic and \(C_{comp}\) is complex.
An equivalence axiom like \(C \equiv C_{comp}\) is deemed as an anchor axiom.
Positive samples are in the form of \(C_{sub} \sqsubseteq C_{comp}\) or \(C_{comp} \sqsubseteq C_{super}\) where \(C_{sub}\) is an entailed sub-concept of \(C\) and \(C_{comp}\), \(C_{super}\) is an entailed super-concept of \(C\) and \(C_{comp}\).
Negative samples are formed by replacing one of the named entities in the anchor axiom, the modified sub-concept and super-concept need to pass the assumed disjointness check to be accepted as a valid negative sample. Without loss of generality, suppose we choose \(C \sqsubseteq C_{comp}\) and replace a named entity in \(C_{comp}'\) to form \(C \sqsubseteq C_{comp}'\), then \(C\) and \(C_{comp}'\) is a valid negative only if they satisfy the assumed disjointness check.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
189 190 191 |
|
positive_sampling_from_anchor(anchor_axiom)
Returns all positive subsumption pairs extracted from an anchor equivalence axiom.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
positive_sampling(num_samples_per_anchor=10)
Sample positive subsumption axioms that involve one atomic and one complex concepts.
An extracted pair \((C, D)\) indicates \(\mathcal{O} \models C \sqsubseteq D\) where \(\mathcal{O}\) is the input ontology.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
negative_sampling(num_samples_per_anchor=10)
Sample negative subsumption axioms that involve one atomic and one complex concepts.
An extracted pair \((C, D)\) indicates \(C\) and \(D\) pass the assumed disjointness check.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
random_corrupt(axiom)
Randomly change an IRI in the input axiom and return a new one.
Source code in src/deeponto/complete/ontolama/subsumption_sampler.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
OntoLAMADataProcessor()
Bases: DataProcessor
Class for processing the OntoLAMA data points.
Source code in src/deeponto/complete/ontolama/data_processor.py
25 26 27 |
|
load_dataset(task_name, split)
staticmethod
Load a specific OntoLAMA dataset from huggingface dataset hub.
Source code in src/deeponto/complete/ontolama/data_processor.py
29 30 31 32 33 |
|
get_examples(task_name, split)
Load a specific OntoLAMA dataset and transform the data points into input examples for prompt-based inference.
Source code in src/deeponto/complete/ontolama/data_processor.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
load_inference_dataset(config, return_class=True, test=False)
classmethod
A plm loader using a global config. It will load the train, valid, and test set (if exists) simulatenously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
CfgNode
|
The global config from the CfgNode. |
required |
return_class |
bool
|
Whether return the data processor class for future usage. |
True
|
Returns:
Type | Description |
---|---|
Optional[List[InputExample]]
|
The train dataset. |
Optional[List[InputExample]]
|
The valid dataset. |
Optional[List[InputExample]]
|
The test dataset. |
Optional[OntoLAMADataProcessor]
|
The data processor object. |
Source code in src/deeponto/complete/ontolama/data_processor.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
Created: April 14, 2023