gline-rs 1.0.0

Inference engine for GLiNER models
Documentation
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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
#set heading(numbering: "1.")
#show link: underline

#place(
  top + center, float: true, scope: "parent",
  text(1.8em, weight: "bold")[Matrix-Level Documentation of \ `gline-rs` Processing Steps]  
)

#place(
  top + center, float: true, scope: "parent",
  text[Frédérik Bilhaut]
)

#v(20pt)

This documents aims at providing a matrix-level description of the pipeline needed for GLiNER inferences, as implemented by #link("https://github.com/fbilhaut/gline-rs")[`gline-rs`].

Concrete examples are provided for each step, all of which build on the input given in the first one.

#v(20pt)
#outline(depth: 2)

#pagebreak()
= Pre-Processing (Common)

== Text Input

This is the "user" input for the whole processing.

=== Source Code

- Related struct: `gliner::model::input::text::TextInput`

=== Format

- $n$: number of input texts
- $k$: number of entity class labels
- $I$: sequence of input texts matrix of type `string` and size $n$
- $E$: entity class labels matrix, of type `string` and size $k$

#align(left, block($ 
I =
  mat(delim: "[",
  "text"_1;
  "text"_2;
  dots.v;
  "text"_n
)
$))

#align(left, block($
E = mat(delim: "[",
  "label"_1;
  "label"_2;
  dots.v;
  "label"_k
)
$))


=== Example

#align(left, block($
I =
  mat(delim: "[",
  &"\"My name is James Bond\"";
  &"\"I like to drive my Aston Martin\"";  
)
$))

#align(left, block($
E = mat(delim: "[",
  &"\"movie character\"";
  &"\"vehicle\"";
)
$))

#pagebreak()
== Word-Level Tokenization

=== Transformation

#align(left, block($(I, E) -> (T, E)$))

=== Source Code

- Struct: `gliner::model::input::tokenized::TokenizedInput`
- Transformation: `gliner::model::input::prompt::RawToTokenized`

=== Format

- $n, k$:  same as before
- $T$: sequence of sequence of tokenized input texts, of type `string` and size $n$
- $E$: same as before

#align(left, block($
T = mat(delim: "[",
  mat(delim: "[", "token"_"1,1", "token"_"1,2", dots);
  mat(delim: "[", "token"_"2,1", "token"_"2,2", dots);
  dots.v;
  mat(delim: "[", "token"_"n,1", "token"_"n,2", dots);
)
$))

=== Example

#align(left, block($
T = mat(delim: "[",
  &mat(delim: "[", "\"My\"" "\"name\"", "\"is\"", "\"James\"", "\"Bond\"");  
  &mat(delim: "[", "\"I\"" "\"like\"", "\"to\"", "\"drive\"", "\"my\"", "\"Aston\"", "\"Martin\"");  
)
$))

#pagebreak()
== Prompt Preparation

Prepared prompts, appending entity and text tokens.

=== Transformation

#align(left, block($(T, E) -> P$))

=== Source Code

- Struct: `gliner::model::input::prompt::PromptInput`
- Transformation from `TokenizedInput`: `gliner::model::input::prompt::TokenizedToPrompt`

=== Format

#align(left, block($
P = mat(delim: "[",
  mat(delim: "[", "<<ENT>>", "label"_"1,1", "<<ENT>>", "label"_"1,2", dots, "<<SEP>>", "token"_"1,1", , "token"_"1,2", dots);
  mat(delim: "[", "<<ENT>>", "label"_"2,1", "<<ENT>>", "label"_"2,2", dots, "<<SEP>>", "token"_"2,1", , "token"_"2,2", dots);
  dots.v ;
  mat(delim: "[", "<<ENT>>", "label"_"n,1", "<<ENT>>", "label"_"n,2", dots, "<<SEP>>", "token"_"n,1", , "token"_"n,2", dots)
)
$))

=== Example

#align(left, block($
P = mat(delim: "[",
  &mat(delim: "[", "<<ENT>>", "\"movie character\"", "<<ENT>>", "\"vehicle\"", dots, "<<SEP>>", "\"My\"", "\"name\"", "\"is\"", "\"James\"", "\"Bond\"");
  &mat(delim: "[", "<<ENT>>", "\"movie character\"", "<<ENT>>", "\"vehicle\"", dots, "<<SEP>>", "\"I\"", "\"like\"", "\"to\"", "\"drive\"", "\"my\"", "\"Austin\"", "\"Martin\"");
)
$))


#pagebreak()
== Prompt Encoding (Sub-Word Tokenization)

=== Transformation

#align(left, block($P -> (I, A, W, L)$))

=== Source Code

- Struct: `gliner::model::input::encoded::EncodedPrompt`
- Transformation: `gliner::model::input::encoded::PromptsToEncoded`

=== Format

#let ststart(x) = text(fill: green, $#x$)
#let stend(x) = text(fill: red, $#x$)
#let stent(x) = text(fill: orange, $#x$)

- k: maximum number of sub-word tokens within a sequence, adding start ($ststart(1)$) and end ($stend(2)$) tokens
- I: encoded prompts of type `i64` and shape $(n*k)$
- A: attention masks of type `i64` and shape $(n*k)$
- W: word masks of type `i64` and shape $(n*k)$
- L: text lengths of type `i64` and shape $(n*1)$

#align(left, block($
I = mat(
  "token_id"_"1,1", "token_id"_"1,2", dots, "token_id"_"1,k" ;
  "token_id"_"2,1", "token_id"_"2,2", dots, "token_id"_"2,k" ;
  dots.v, dots.v, dots.down, dots.v ;
  "token_id"_"n,1", "token_id"_"n,2", dots, "token_id"_"n,k" ;  
)
$))

#align(left, block(
$
A = mat(
  "attn_mask"_"1,1", "attn_mask"_"1,2", dots, "attn_mask"_"1,k" ;
  "attn_mask"_"2,1", "attn_mask"_"2,2", dots, "attn_mask"_"2,k" ;
  dots.v, dots.v, dots.down, dots.v ;
  "attn_mask"_"n,1", "attn_mask"_"n,2", dots, "attn_mask"_"n,k" ;  
)
$))

#align(left, block($
W = mat(
  "word_mask"_"1,1", "word_mask"_"1,2", dots, "word_mask"_"1,k" ;
  "word_mask"_"2,1", "word_mask"_"2,2", dots, "word_mask"_"2,k" ;
  dots.v, dots.v, dots.down, dots.v ;
  "word_mask"_"n,1", "word_mask"_"n,2", dots, "word_mask"_"n,k" ;  
)
$))

#align(left, block($
L = mat(
  "l"_"1"; 
  dots.v;
  "l"_"n";
)
$))

=== Example

#align(left, block($
I = mat(
  ststart(1), stent(128002), 1421, 1470, stent(128002), 1508, stent(128003), 573, 601, 269, 1749, 8728, stend(2), 0, 0;
  ststart(1), stent(128002), 1421, 1470, stent(128002), 1508, stent(128003), 273, 334, 264, 1168, 312, 20844, 2963, stend(2);
)
$))

#align(left, block($
A = mat(
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0;
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
)
$))

#align(left, block($
W = mat(
  0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0;
  0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0;
)
$))

#align(left, block($
L = mat(
  5;
  7
)
$))

#pagebreak()
= Pre-Processing (Span Mode)

Downstream of the aforementioned steps.

== Span Preparation

=== Transformation

#align(left, block($(I, A, W, L) -> (I, A, W, L, S_I, S_M)$))

=== Format

- $n, k, I, A, W, L$: same as before.
- $s$: maximum possible number of spans for one sequence
- $S_I$: span offsets, of type `i64` and shape $(n*s*2)$
- $S_M$: span masks, of type `bool` and shape $(n*s)$

#align(left, block($
S_I = mat(
  mat("start"_"1,1", "end"_"1,1"), mat("start"_"1,2", "end"_"1,2"), dots, mat("start"_"1,s", "end"_"1,s");
  mat("start"_"2,1", "end"_"2,1"), mat("start"_"2,2", "end"_"2,2"), dots, mat("start"_"2,s", "end"_"2,s");
  dots.v, dots.v, dots.down, dots.v;
  mat("start"_"n,1", "end"_"n,1"), mat("start"_"n,2", "end"_"n,2"), dots, mat("start"_"n,s", "end"_"n,s");
)
$))

#align(left, block($
S_M = mat(
  "span_mask"_"1,1", "span_mask"_"1,2", dots, "span_mask"_"1,s";
  "span_mask"_"2,1", "span_mask"_"2,2", dots, "span_mask"_"2,s";
  dots.v, dots.v, dots.down, dots.v;
  "span_mask"_"n,1", "span_mask"_"n,2", dots, "span_mask"_"n,s";
)
$))

=== Example

Note: for readability purposes, inside matrices are split into rows (one per token) but they are actually in one dimension $s$ (see format above).

#align(left, block($
S_I = mat(
  mat(
    mat(0, 0), mat(0, 1), mat(0, 2), mat(0, 3), mat(0, 4), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), ⏎; 
    mat(1, 1), mat(1, 2), mat(1, 3), mat(1, 4), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(2, 2), mat(2, 3), mat(2, 4), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(3, 3), mat(3, 4), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(4, 4), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, dots, dots, dots
  )
  ;
  mat(
    mat(0, 0), mat(0, 1), mat(0, 2), mat(0, 3), mat(0, 4), mat(0, 5), mat(0, 6), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), ⏎;
    mat(1, 1), mat(1, 2), mat(1, 3), mat(1, 4), mat(1, 5), mat(1, 6), mat(0, 0), dots, dots, dots, dots, dots, ⏎;
    mat(2, 2), mat(2, 3), mat(2, 4), mat(2, 5), mat(2, 6), mat(0, 0), dots, dots, dots, dots, dots, dots, ⏎;
    mat(3, 3), mat(3, 4), mat(3, 5), mat(3, 6), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(4, 4), mat(4, 5), mat(4, 6), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(5, 5), mat(5, 6), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, dots, ⏎;
    mat(6, 6), mat(0, 0), dots, dots, dots, dots, dots, dots, dots, dots, dots, dots
  )
)
$))

#align(left, block($
S_M = mat(
  mat(
    1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, ⏎; 
    1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  )
  ;
  mat(
    1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, ⏎;
    1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, ⏎;
    1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ⏎;
    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  )
)
$))

#pagebreak()
= Pre-Processing (Token Mode)

Nothing to be done beside the common steps.

#pagebreak()
= Post-Processing (Span Mode)

== Logits Output

=== Source Code

- Struct: `gliner::model::output::TensorOutput`

=== Format

- $n$: number of text sequences
- $w$: maximum number of tokens in one sequence
- $s$: maximum number of possible spans for one token (seee above)
- $k$: number of entity labels
- $O$: logits output, of type `f32` and shape $(n*w*s*k)$
- $v_"n,w,s,k"$: raw model output for sequence $n$, token $w$, span $s$ and label $k$.

#align(left, block($
O = mat(
  mat(
    mat(
      mat("v"_"1,1,1,1", dots, "v"_"1,1,1,k");
      dots.v;
      mat("v"_"1,1,s,1", dots, "v"_"1,1,s,k");
    ), 
    dots,
    mat(
      mat("v"_"1,w,1,1", dots, "v"_"1,w,1,k");
      dots.v;
      mat("v"_"1,w,s,1", dots, "v"_"1,w,s,k");
    )
  );
  dots.v;
  mat(
    mat(
      mat("v"_"n,1,1,1", dots, "v"_"n,1,1,k");
      dots.v;
      mat("v"_"n,1,s,1", dots, "v"_"n,1,s,k");
    ), 
    dots,
    mat(
      mat("v"_"n,w,1,1", dots, "v"_"n,w,1,k");
      dots.v;
      mat("v"_"n,w,s,1", dots, "v"_"n,w,s,k");
    )
  )
)
$))


=== Example

In this case $s=12$. For readability purposes, the raw values are "sigmoided" ($S(x)= 1/(1+e^(-x))$) and then "ReLUed" with a threshold $t=0.5$.


#align(left, block($
O_"S,t" = mat(
  mat(
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(bold(0.89), 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);      
  );
  mat(
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);      
      mat(0, 0), mat(0, bold(0.96)), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);
      mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0), mat(0, 0);      
  );
)
$))

Which means:
- In the 1st sequence, the span starting with the 4th token and ending with the 5th one has a probability of 0.89 to match the 1st entity class.
- In the 2nd sequence, the span starting with the 6th token and ending with the 7th one has a probability of 0.96 to match the second 2nd class.

#pagebreak()
== Span Decoding

=== Transformation

$(O, L) -> S$

=== Source Code

- Struct: `gliner::model::output::decoded::SpanOutput`
- Transformation: `gliner::model::output::decoded::span::TensorsToDecoded`

=== Format

- $t$: threshold
- $n$: number of input sequences
- $L$: text lengths as defined before
- $S$: sequence of spans $(i,j,k,p)$ where: 
  - $i$ is the index of the first token of sequence $m$ with $i<j$ and $i<L(m)$ 
  - $j$ is the index of the last token with the same constraints as $i$
  - $k$ is the entity class, 
  - $p$ is the probability for class $k$ with $p>=t$

#align(left, block($ 
S =
  mat(delim: "[",
    mat(delim: "[", (i_"1,1", j_"1,1", k_"1,1", p_"1,1"), (i_"1,2", j_"1,2", k_"1,2", p_"1,2"), dots);
    dots.v;
    mat(delim: "[", (i_"n,1", j_"n,1", k_"n,1", p_"n,1"), (i_"n,2", j_"n,2", k_"n,2", p_"n,2"), dots);
)
$))

=== Example

#align(left, block($ 
S =
  mat(delim: "[",
    mat(delim: "[", (4, 5, 1, 0.89));
    mat(delim: "[", (6, 7, 2, 0.96));
)
$))

#pagebreak()
= Post-Processing (Token Mode)

== Logits Output

=== Source Code

- Struct: `gliner::model::output::TensorOutput`

=== Format


- $n$: number of text sequences
- $w$: maximum number of tokens in one sequence
- $k$: number of entity labels
- $O$: logits output, of type `f32` and shape $(3*n*w*k)$ with:
  - $s_"n,w,k"$: raw model output for a start token $w$ in sequence $n$ and label $k$.
  - $e_"n,w,k"$: raw model output for an end token $w$ in sequence $n$ and label $k$.
  - $i_"n,w,k"$: raw model output for an inside token $w$ in sequence $n$ and label $k$.

#align(left, block($
O = mat(
  mat(
    mat(
      "s"_"1,1,1", dots, "s"_"1,1,k";
      dots.v, dots.down, dots.v;
      "s"_"1,w,1", dots, "s"_"1,w,k";
    ), 
    dots,
    mat(
      "s"_"n,1,1", dots, "s"_"n,1,k";
      dots.v, dots.down, dots.v;
      "s"_"n,w,1", dots, "s"_"n,w,k";
    ), 
  );
  mat(
    mat(
      "e"_"1,1,1", dots, "e"_"1,1,k";
      dots.v, dots.down, dots.v;
      "e"_"1,w,1", dots, "e"_"1,w,k";
    ), 
    dots,
    mat(
      "e"_"n,1,1", dots, "e"_"n,1,k";
      dots.v, dots.down, dots.v;
      "e"_"n,w,1", dots, "e"_"n,w,k";
    ), 
  );
  mat(
    mat(
      "i"_"1,1,1", dots, "i"_"1,1,k";
      dots.v, dots.down, dots.v;
      "i"_"1,w,1", dots, "i"_"1,w,k";
    ), 
    dots,
    mat(
      "i"_"n,1,1", dots, "i"_"n,1,k";
      dots.v, dots.down, dots.v;
      "i"_"n,w,1", dots, "i"_"n,w,k";
    ), 
  );
)
$))

=== Example

For readability purposes, the raw values are "sigmoided" ($S(x)= 1/(1+e^(-x))$) and then "ReLUed" with a threshold $t=0.5$.

#align(left, block($
O_"S,t" = mat(
  mat(
    mat(0, 0; 0, 0; 0, 0; bold(0.97), 0; 0, 0; 0, 0; 0, 0),
    mat(0, 0; 0, 0; 0, 0; 0, 0; 0, 0; 0, bold(0.99); 0, 0), 
  );
  mat(
    mat(0, 0; 0, 0; 0, 0; 0, 0; bold(0.96), 0; 0, 0; 0, 0),
    mat(0, 0; 0, 0; 0, 0; 0, 0; 0, 0; 0, 0; 0, bold(0.97)),
  );
  mat(
    mat(0, 0; 0, 0; 0, 0; bold(0.98), 0; bold(0.98), 0; 0, 0; 0, 0),
    mat(0, 0; 0, 0; 0, 0; 0, 0; 0, 0; 0, bold(0.99); 0, bold(0.99)),
  );
)
$))

#pagebreak()
== Span Decoding

=== Transformation

$O -> S$

=== Source Code

- Struct: `gliner::model::output::decoded::SpanOutput`
- Transformation: `gliner::model::output::decoded::token::TensorsToDecoded`

=== Format

Same format as in span-mode.

#pagebreak()
= Post-Processing (Common)

== Span Filtering (Greedy Search)

=== Transformation

$S -> S'$

=== Source Code

- Struct: `gliner::model::output::decoded::SpanOutput`
- Transformation: `gliner::model::output::decoded::greedy::GreedySearch`

=== Format

Same as span output.