aha 0.2.5

aha model inference library, now supports Qwen(2.5VL/3/3VL/3.5/ASR/3Embedding/3Reranker), MiniCPM4, VoxCPM/1.5, DeepSeek-OCR/2, Hunyuan-OCR, PaddleOCR-VL/1.5, RMBG2.0, GLM(ASR-Nano-2512/OCR), Fun-ASR-Nano-2512, LFM(2/2.5/2VL/2.5VL)
Documentation
use candle_nn::Activation;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct PaddleOCRVLConfig {
    pub compression_ratio: f64,
    pub head_dim: usize,
    pub hidden_act: Activation,
    pub hidden_dropout_prob: f64,
    pub hidden_size: usize,
    pub ignored_index: i32,
    pub image_token_id: u32,
    pub intermediate_size: usize,
    pub max_position_embeddings: usize,
    pub max_sequence_length: Option<usize>,
    pub num_attention_heads: usize,
    pub num_hidden_layers: usize,
    pub num_key_value_heads: usize,
    pub pad_token_id: u32,
    pub rms_norm_eps: f64,
    pub rope_scaling: PaddleOCRVLRopeScalingConfig,
    pub rope_theta: f64,
    pub sliding_window: Option<u32>,
    pub tie_word_embeddings: bool,
    pub torch_dtype: String,
    pub use_bias: bool,
    pub use_cache: bool,
    pub use_flash_attention: bool,
    pub video_token_id: u32,
    pub vision_config: PaddleOCRVLVisionConfig,
    pub vision_start_token_id: u32,
    pub vocab_size: usize,
    pub weight_share_add_bias: bool,
    pub use_3d_rope: bool,
    pub rope_is_neox_style: bool,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct PaddleOCRVLRopeScalingConfig {
    pub mrope_section: Vec<usize>,
    pub rope_type: String,
    #[serde(rename = "type")]
    pub scaling_type: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct PaddleOCRVLVisionConfig {
    pub attention_dropout: f64,
    pub hidden_act: Activation,
    pub hidden_size: usize,
    pub image_size: usize,
    pub intermediate_size: usize,
    pub layer_norm_eps: f64,
    pub num_attention_heads: usize,
    pub num_channels: usize,
    pub num_hidden_layers: usize,
    pub pad_token_id: u32,
    pub patch_size: usize,
    pub spatial_merge_size: usize,
    pub temporal_patch_size: usize,
    pub tokens_per_second: usize,
    pub torch_dtype: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct PaddleOCRVLPreprocessorConfig {
    pub do_convert_rgb: bool,
    pub do_normalize: bool,
    pub do_rescale: bool,
    pub do_resize: bool,
    pub image_mean: Vec<f64>,
    pub image_std: Vec<f64>,
    pub max_pixels: u32,
    pub merge_size: usize,
    pub min_pixels: u32,
    pub patch_size: usize,
    pub resample: u32,
    pub rescale_factor: f64,
    pub size: Option<SizeConfig>,
    pub temporal_patch_size: usize,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SizeConfig {
    pub max_pixels: usize,
    pub min_pixels: usize,
}