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
//! Hybrid language model combining n-grams and embeddings.
//!
//! This module provides:
//! - Combined n-gram + embedding scoring
//! - OOV handling via embedding similarity
//! - Configurable interpolation strategies
//!
//! # Dictionary Backend Type Aliases
//!
//! Two type aliases are provided for common use cases:
//!
//! - [`SerializableHybridModel`]: Uses `DynamicDawgChar` backend for models that need
//! to be saved/loaded. This backend supports full serde serialization.
//!
//! - [`PathMapHybridModel`]: Uses `PathMapDictionary` backend for integration with
//! lling-llang's shared lattice architecture.
//!
//! # Example
//!
//! ```ignore
//! use libgrammstein::hybrid::{HybridLanguageModel, HybridConfig, InterpolationStrategy};
//! use libgrammstein::ngram::NgramModel;
//! use libgrammstein::embedding::SubwordEmbedding;
//!
//! // Create hybrid model from trained components
//! let config = HybridConfig {
//! strategy: InterpolationStrategy::Linear { alpha: 0.8 },
//! ..Default::default()
//! };
//! let hybrid = HybridLanguageModel::new(ngram_model, embedding_model, config);
//!
//! // Score a word in context
//! let score = hybrid.score("fox", &["the", "quick", "brown"]);
//!
//! // Compute perplexity
//! let ppl = hybrid.perplexity(&["the", "quick", "brown", "fox"]);
//! ```
pub use PortableHybridModel;
pub use ;
pub use ;
use crateNgramEntry;
/// Serializable hybrid model using DynamicDawgChar backend.
///
/// Use this when you need to save/load models to/from disk.
/// This backend supports full serde serialization.
///
/// # Example
///
/// ```ignore
/// use libgrammstein::hybrid::SerializableHybridModel;
///
/// // Train and save
/// model.save("hybrid_model.bin")?;
///
/// // Load later
/// let model: SerializableHybridModel = SerializableHybridModel::load("hybrid_model.bin")?;
/// ```
pub type SerializableHybridModel =
;
/// Memory-efficient hybrid model using PathMapDictionary backend.
///
/// Use this for lling-llang integration with shared lattice structures.
/// This backend does NOT support serde serialization but provides
/// better memory sharing characteristics.
pub type PathMapHybridModel =
;