use crate::ModelConfig;
#[derive(Debug, Clone)]
pub struct ModelNamingConfig {
pub embeddings_prefixes: Vec<String>,
pub embeddings_suffix: String,
pub ffn_prefixes: Vec<String>,
pub ffn_suffix: String,
pub lm_head_prefixes: Vec<String>,
pub lm_head_suffix: String,
pub supported_extensions: Vec<String>,
}
impl Default for ModelNamingConfig {
fn default() -> Self {
Self {
embeddings_prefixes: vec!["qwen_".to_string()],
embeddings_suffix: "embeddings.mlmodelc".to_string(),
ffn_prefixes: vec!["qwen_FFN_PF_".to_string()],
ffn_suffix: "_chunk_01of01.mlmodelc".to_string(),
lm_head_prefixes: vec!["qwen_lm_head_".to_string()],
lm_head_suffix: ".mlmodelc".to_string(),
supported_extensions: vec![".mlpackage".to_string(), ".mlmodelc".to_string()],
}
}
}
impl ModelNamingConfig {
pub fn standard_qwen() -> Self {
Self {
embeddings_prefixes: vec!["qwen_".to_string()],
embeddings_suffix: "embeddings.mlmodelc".to_string(),
ffn_prefixes: vec!["qwen_FFN_PF_".to_string()],
ffn_suffix: "_chunk_01of01.mlmodelc".to_string(),
lm_head_prefixes: vec!["qwen_lm_head_".to_string()],
lm_head_suffix: ".mlmodelc".to_string(),
supported_extensions: vec![".mlpackage".to_string(), ".mlmodelc".to_string()],
}
}
pub fn custom(base_prefix: &str, extension: &str) -> Self {
Self {
embeddings_prefixes: vec![
format!("{base_prefix}_embeddings"),
format!("{base_prefix}-embeddings"),
],
embeddings_suffix: format!(".{extension}"),
ffn_prefixes: vec![
format!("{base_prefix}_FFN_PF_"),
format!("{base_prefix}-ffn_"),
format!("{base_prefix}_ffn_"),
],
ffn_suffix: format!("_chunk_01of01.{extension}"),
lm_head_prefixes: vec![
format!("{base_prefix}_lm_head_"),
format!("{base_prefix}-head_"),
format!("{base_prefix}_head_"),
],
lm_head_suffix: format!(".{extension}"),
supported_extensions: vec![format!(".{extension}")],
}
}
pub fn bobs_model() -> Self {
Self::custom("bobs-qwen-model", "mlpackage")
}
pub fn from_model_config(_model_config: &ModelConfig) -> Self {
Self::default()
}
}