mirror of
https://github.com/zenlm/engine.git
synced 2026-10-30 15:00:05 +00:00
* Implement imatrix for ISQ * Implement imatrix quantization for q3k, q2k * Fix build on cuda * Implement imatrix quantization for q5k, q6k * Utilize merged rev * Fix typo * Update docs * Update docs * Track stats for imatrix * Implement internal imatrix quantization * Implement internal imatrix quantization for all models but the moe ones * Add for the moe models * Simpler * Handle clearing kv cache * Add calibration data * Add better calibration data * Add example and docs * Add example and docs
36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
use mistralrs::{
|
|
IsqType, PagedAttentionMetaBuilder, TextMessageRole, TextMessages, TextModelBuilder,
|
|
};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let model = TextModelBuilder::new("meta-llama/Llama-3.2-3B-Instruct")
|
|
.with_isq(IsqType::Q4K)
|
|
.with_calibration_file("calibration_data/calibration_datav3_small.txt".into())
|
|
.with_logging()
|
|
.with_paged_attn(|| PagedAttentionMetaBuilder::default().build())?
|
|
.build()
|
|
.await?;
|
|
|
|
let messages = TextMessages::new()
|
|
.add_message(
|
|
TextMessageRole::System,
|
|
"You are an AI agent with a specialty in programming.",
|
|
)
|
|
.add_message(
|
|
TextMessageRole::User,
|
|
"Hello! How are you? Please write generic binary search function in Rust.",
|
|
);
|
|
|
|
let response = model.send_chat_request(messages).await?;
|
|
|
|
println!("{}", response.choices[0].message.content.as_ref().unwrap());
|
|
dbg!(
|
|
response.usage.avg_prompt_tok_per_sec,
|
|
response.usage.avg_compl_tok_per_sec
|
|
);
|
|
|
|
Ok(())
|
|
}
|