gliner_relex¶
knowledge_graph.clinical.gliner_relex
GLiNER-Relex on Synthetic-100: joint entity and relation extraction, and relations over reference entities.
python -m knowledge_graph.clinical.gliner_relex joint --out DIR [--notes test] # zero-shot joint python -m knowledge_graph.clinical.gliner_relex reference-entities --out DIR [--model CHECKPOINT --notes test]
resolve_endpoint(entity, by_span, segment, spans, typed)
¶
Document span, type, and aligned reference entity of a predicted entity or relation endpoint.
Source code in src/knowledge_graph/clinical/gliner_relex.py
23 24 25 26 27 28 29 | |
gold_keys(annotation)
¶
Source code in src/knowledge_graph/clinical/gliner_relex.py
32 33 | |
joint_predictions(model, texts, batch_size)
¶
Joint entity and relation inference with the shared clinical prompts and thresholds.
Source code in src/knowledge_graph/clinical/gliner_relex.py
36 37 38 39 40 41 42 43 44 45 46 47 48 | |
decode_joint(segment, spans, typed, entities, relations)
¶
Decode one input into document spans and relations aligned to reference entities for scoring.
Source code in src/knowledge_graph/clinical/gliner_relex.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
joint_note(model, nlp, note_id, condition, batch_size)
¶
Joint predictions pooled over one note's inputs.
Source code in src/knowledge_graph/clinical/gliner_relex.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
joint(args)
¶
Source code in src/knowledge_graph/clinical/gliner_relex.py
105 106 107 108 109 110 111 112 113 114 115 | |
token_bounds(prepared, entities)
¶
First and last model token of every reference entity.
Source code in src/knowledge_graph/clinical/gliner_relex.py
118 119 120 121 122 123 124 125 126 127 128 | |
span_representations(layer, words, indices)
¶
The markerV0 span representation for given endpoints, without its fixed-width grid reshape.
Source code in src/knowledge_graph/clinical/gliner_relex.py
131 132 133 134 135 | |
predict_reference_entities(model, texts, entities, threshold=THRESHOLD)
¶
Relation scores of GLiNER-Relex over given entity spans: the span layer is replaced, NER is bypassed.
Source code in src/knowledge_graph/clinical/gliner_relex.py
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 165 166 167 168 169 | |
reference_entities(annotation, segment)
¶
Reference mentions inside one input, with input-local and document offsets.
Source code in src/knowledge_graph/clinical/gliner_relex.py
172 173 174 175 176 177 178 179 180 181 | |
reference_note(model, nlp, note_id, condition, batch_size)
¶
Relations of one note over its reference entities, pooled over its inputs.
Source code in src/knowledge_graph/clinical/gliner_relex.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
evaluate_reference_entities(args)
¶
Relations over the reference entities: entity endpoints project onto fixed markerV0 spans, with no NER filtering and no gold relations as input.
Source code in src/knowledge_graph/clinical/gliner_relex.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
main()
¶
Source code in src/knowledge_graph/clinical/gliner_relex.py
227 228 229 230 231 232 233 234 235 236 237 238 | |