pub struct SpanRepConfig {
pub hidden_dim: usize,
pub max_width: usize,
pub use_width_embeddings: bool,
pub width_emb_dim: usize,
}Expand description
Configuration for span representation.
§Research Context (Deep Span Representations, arXiv:2210.04182)
From “Deep Span Representations for NER”:
“Existing span-based NER systems shallowly aggregate the token representations to span representations. However, this typically results in significant ineffectiveness for long-span entities.”
Common span representation strategies:
| Method | Formula | Pros | Cons |
|---|---|---|---|
| Concat | [h_i; h_j] | Simple, fast | Ignores middle tokens |
| Pooling | mean(h_i:h_j) | Uses all tokens | Loses boundary info |
| Attention | attn(h_i:h_j) | Learnable | Expensive |
| GLiNER | FFN([h_i; h_j; w]) | Balanced | Requires width emb |
§Recommendation (GLiNER Default)
For most use cases, concatenating first + last token embeddings with a width embedding provides the best tradeoff:
- O(N) complexity (vs O(N²) for all-pairs attention)
- Captures boundary positions (critical for NER)
- Width embedding disambiguates “I” vs “New York City”
Fields§
Hidden dimension of the encoder
max_width: usizeMaximum span width (in tokens)
GLiNER uses K=12: “to keep linear complexity without harming recall.” Wider spans rarely contain coherent entities.
use_width_embeddings: boolWhether to include width embeddings
Critical for distinguishing spans of different lengths with similar boundary tokens.
width_emb_dim: usizeWidth embedding dimension (typically hidden_dim / 4)
Trait Implementations§
Source§impl Clone for SpanRepConfig
impl Clone for SpanRepConfig
Source§fn clone(&self) -> SpanRepConfig
fn clone(&self) -> SpanRepConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpanRepConfig
impl Debug for SpanRepConfig
Auto Trait Implementations§
impl Freeze for SpanRepConfig
impl RefUnwindSafe for SpanRepConfig
impl Send for SpanRepConfig
impl Sync for SpanRepConfig
impl Unpin for SpanRepConfig
impl UnsafeUnpin for SpanRepConfig
impl UnwindSafe for SpanRepConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more