tiny_recursive_rs/
lib.rs

1//! Tiny Recursive Models - Rust implementation
2//!
3//! A Rust port of TinyRecursiveModels for fast, efficient recursive reasoning
4//! with tiny parameter counts (~7M params).
5//!
6//! # Architecture
7//!
8//! The model uses a hierarchical recursive architecture with:
9//! - **H-cycles**: High-level reasoning cycles for refinement
10//! - **L-cycles**: Low-level update cycles for detailed processing
11//! - **ACT**: Adaptive Computation Time for dynamic halting
12//!
13//! # Example
14//!
15//! ```ignore
16//! use tiny_recursive::{TinyRecursiveModel, TRMConfig};
17//!
18//! let config = TRMConfig::default();
19//! let model = TinyRecursiveModel::new(config)?;
20//! let output = model.forward(input)?;
21//! ```
22
23pub mod config;
24pub mod data;
25pub mod layers;
26pub mod models;
27pub mod training;
28pub mod utils;
29
30// Re-export commonly used items
31pub use config::TRMConfig;
32pub use models::TinyRecursiveModel;
33
34/// Library error types
35#[derive(Debug, thiserror::Error)]
36pub enum TRMError {
37    #[error("Candle error: {0}")]
38    Candle(#[from] candle_core::Error),
39
40    #[error("Configuration error: {0}")]
41    Config(String),
42
43    #[error("Model error: {0}")]
44    Model(String),
45
46    #[error("Training error: {0}")]
47    Training(String),
48
49    #[error("IO error: {0}")]
50    Io(#[from] std::io::Error),
51
52    #[error("JSON error: {0}")]
53    Json(#[from] serde_json::Error),
54}
55
56pub type Result<T> = std::result::Result<T, TRMError>;