2025-09-25 12:09:25 +08:00
|
|
|
use crate::models::{minicpm4::generate::MiniCPMGenerateModel, qwen2_5vl::generate::Qwen2_5VLGenerateModel, GenerateModel};
|
2025-09-22 16:38:12 +08:00
|
|
|
use anyhow::{Ok, Result};
|
|
|
|
|
use candle_core::{DType, Device};
|
|
|
|
|
pub mod chat_template;
|
|
|
|
|
pub mod models;
|
|
|
|
|
pub mod position_embed;
|
|
|
|
|
pub mod tokenizer;
|
|
|
|
|
pub mod utils;
|
|
|
|
|
|
|
|
|
|
pub enum ModelType {
|
|
|
|
|
Qwen2_5VL,
|
2025-09-25 12:09:25 +08:00
|
|
|
MiniCPM4,
|
2025-09-22 16:38:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ModelType {
|
|
|
|
|
pub fn init(
|
|
|
|
|
model_type: ModelType,
|
|
|
|
|
model_path: &str,
|
|
|
|
|
device: Option<&Device>,
|
|
|
|
|
dtype: Option<DType>,
|
2025-09-22 23:49:58 +08:00
|
|
|
) -> Result<Box<impl GenerateModel>> {
|
2025-09-22 16:38:12 +08:00
|
|
|
match model_type {
|
|
|
|
|
ModelType::Qwen2_5VL => {
|
|
|
|
|
let model = Qwen2_5VLGenerateModel::init(model_path, device, dtype)?;
|
|
|
|
|
Ok(Box::new(model))
|
2025-09-25 12:09:25 +08:00
|
|
|
},
|
|
|
|
|
ModelType::MiniCPM4 => {
|
|
|
|
|
let model = MiniCPMGenerateModel::init(model_path, device, dtype)?;
|
|
|
|
|
Ok(Box::new(model))
|
2025-09-22 16:38:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|