kproc-llm 0.7.0

Knowledge Processing library, using LLMs.
Documentation
//! Factories for candle models

use crate::prelude::*;

use super::{Builder, Candle};

/// Instantiate a `llama` model
pub fn llama(repo: impl Into<String>, model: impl Into<String>) -> Builder
{
  Candle::build()
    .model(repo, model)
    .tokenizer_repo("hf-internal-testing/llama-tokenizer")
    .end_of_stream("</s>")
    .template(template::Template::new(include_str!("../../data/templates/plain")).unwrap())
}

/// Instantiate a `llama` 2 7B model
pub fn llama2_7b() -> Builder
{
  llama("TheBloke/Llama-2-7B-GGML", "llama-2-7b.ggmlv3.q4_0.bin")
}

/// Instantiate a `SmolLM` 2 1.7B model
pub fn smol_lm_2_1_7b() -> Builder
{
  Candle::build()
    .model(
      "HuggingFaceTB/SmolLM2-1.7B-Instruct-GGUF",
      "smollm2-1.7b-instruct-q4_k_m.gguf",
    )
    .tokenizer_repo("HuggingFaceTB/SmolLM2-1.7B-Instruct")
    .end_of_stream("<|im_end|>")
    .template(template::Template::new(include_str!("../../data/templates/chatml")).unwrap())
}

/// Instantiate a `SmolLM` 3
#[cfg(feature = "candle-git")]
pub fn smol_lm_3_q4_k_m() -> Builder
{
  use super::BaseModel;
  Candle::build()
    .base_model(BaseModel::SmolLM3)
    .model("unsloth/SmolLM3-3B-GGUF", "SmolLM3-3B-Q4_K_M.gguf")
    .tokenizer_repo("HuggingFaceTB/SmolLM3-3B")
    .end_of_stream("<|im_end|>")
    .template(template::Template::new(include_str!("../../data/templates/smol3")).unwrap())
}