Repository: huggingface/candle
File: candle-examples/examples/quantized/main.rs (Rust)

Code before:
    L8b,
    #[value(name = "phi3")]
    Phi3,
    #[value(name = "SmoLM2-360M-Instruct")]
    SmolLM2_360MInstruct,
    #[value(name = "SmoLM2-1.7B-Instruct")]
    SmolLM2_1BInstruct,
    #[value(name = "deepseekr1-llama8b")]
    DeepseekR1Llama8b,
}

impl Which {
    fn is_mistral(&self) -> bool {
        match self {
            // Zephyr and OpenChat are fine tuned versions of mistral and should be treated in the
            // same way. Starling is a fine tuned version of OpenChat.
            Self::OpenChat35
            | Self::Starling7bAlpha
            | Self::Zephyr7bAlpha
            | Self::Zephyr7bBeta
            | Self::Mixtral
            | Self::MixtralInstruct
            | Self::Mistral7b
            | Self::Mistral7bInstruct
            | Self::Mistral7bInstructV02 => true,
            _ => false,
        }
    }

    fn is_zephyr(&self) -> bool {
        matches!(self, Self::Zephyr7bAlpha | Self::Zephyr7bBeta)
    }

    fn is_open_chat(&self) -> bool {
        matches!(self, Self::OpenChat35 | Self::Starling7bAlpha)
    }

    fn is_deepseek(&self) -> bool {
        matches!(self, Self::DeepseekR1Llama8b)
    }
    fn tokenizer_repo(&self) -> &'static str {
        match self {
            Self::L7b
            | Self::L13b
            | Self::L70b
            | Self::L7bChat
            | Self::L13bChat
            | Self::L70bChat
            | Self::L7bCode
            | Self::L13bCode
            | Self::L34bCode => "hf-internal-testing/llama-tokenizer",

Review comment (suggestion):
The long explicit pattern matching was on purpose, this forces someone adding a new case to decide whether this function should return false or true rather than defaulting to one of the two cases. Same for the other functions.

Code after:
    L8b,
    #[value(name = "phi3")]
    Phi3,
    #[value(name = "SmoLM2-360M-Instruct")]
    SmolLM2_360MInstruct,
    #[value(name = "SmoLM2-1.7B-Instruct")]
    SmolLM2_1BInstruct,
    #[value(name = "deepseekr1-llama8b")]
    DeepseekR1Llama8b,
}

impl Which {
    fn is_mistral(&self) -> bool {
        match self {
            Self::L7b
            | Self::L13b
            | Self::L70b
            | Self::L7bChat
            | Self::L13bChat
            | Self::L70bChat
            | Self::L7bCode
            | Self::L13bCode
            | Self::L34bCode
            | Self::Leo7b
            | Self::Leo13b
            | Self::L8b
            | Self::Phi3
            | Self::SmolLM2_1BInstruct
            | Self::SmolLM2_360MInstruct
            | Self::DeepseekR1Llama8b => false,
            // Zephyr and OpenChat are fine tuned versions of mistral and should be treated in the
            // same way. Starling is a fine tuned version of OpenChat.
            Self::OpenChat35
            | Self::Starling7bAlpha
            | Self::Zephyr7bAlpha
            | Self::Zephyr7bBeta
            | Self::Mixtral
            | Self::MixtralInstruct
            | Self::Mistral7b
            | Self::Mistral7bInstruct
            | Self::Mistral7bInstructV02 => true,
        }
    }

    fn is_zephyr(&self) -> bool {
        match self {
            Self::L7b
            | Self::L13b
            | Self::L70b
            | Self::L7bChat
            | Self::L13bChat