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
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
//! GLiREL: Zero-shot Relation Extraction via GLiNER
//!
//! GLiREL extends GLiNER to predict typed relations between entity pairs.
//! The model uses a shared DeBERTa-v3 encoder for text and relation labels,
//! then scores (head, tail, relation_type) triples via dot-product scoring.
//!
//! # Architecture
//!
//! ```text
//! Input text + entity spans + relation labels
//! │
//! ▼
//! ┌──────────────────────────────────────┐
//! │ Shared DeBERTa-v3 Encoder │
//! └──────────────────────────────────────┘
//! │ │
//! ▼ ▼
//! Token/word reps Relation label reps
//! │
//! ▼
//! Span pooling → Entity pair reps
//! │
//! ▼
//! dot(pair_repr, rel_repr) → relation_scores
//! ```
//!
//! # Model Source
//!
//! Export with: `uv run scripts/export_glirel_onnx.py`
//! Compatible models: `jackboyla/glirel-large-v0`
//!
//! # Usage
//!
//! ```rust,ignore
//! use anno::backends::glirel::GLiREL;
//!
//! let model = GLiREL::from_pretrained("jackboyla/glirel-large-v0")?;
//! let relations = model.extract_relations(
//! "Steve Jobs founded Apple.",
//! &[(0, 10, "person"), (19, 24, "organization")],
//! &["founded", "works_for", "ceo_of"],
//! 0.5,
//! )?;
//! ```
pub use GLiREL;
// Stub when ONNX feature is not enabled.
/// GLiREL stub (requires `onnx` feature).