Skip to main content

oxicuda_seq/decoders/
mod.rs

1//! Stochastic decoders for autoregressive sequence generation.
2//!
3//! This module collects sampling-based decoding strategies that are
4//! complementary to the greedy/beam-search decoders in [`crate::beam`].
5//! Each submodule implements a different truncation criterion on the
6//! softmax distribution before drawing a single token:
7//!
8//! * [`top_k`] — Fan, Lewis & Dauphin (2018), *Hierarchical Neural Story
9//!   Generation*: restrict the support to the `k` most-likely tokens.
10//! * [`nucleus`] — Holtzman, Buys, Du, Forbes & Choi (2020), *The Curious
11//!   Case of Neural Text Degeneration*: restrict the support to the
12//!   smallest set whose cumulative probability exceeds `p`.
13//! * [`typical`] — Meister, Pimentel, Wiher & Cotterell (2022), *Typical
14//!   Decoding for Natural Language Generation*: restrict the support to
15//!   tokens whose negative log-probability is closest to the conditional
16//!   entropy of the distribution.
17//!
18//! All decoders are deterministic given a seeded [`crate::handle::LcgRng`]
19//! and return [`crate::error::SeqResult`].
20
21pub mod contrastive;
22pub mod nucleus;
23pub mod pointer_network;
24pub mod top_k;
25pub mod typical;
26
27pub use contrastive::{ContrastiveConfig, ContrastiveSearcher};
28pub use nucleus::*;
29pub use pointer_network::{PointerGrad, PointerNetwork};
30pub use top_k::*;
31pub use typical::*;