-
Notifications
You must be signed in to change notification settings - Fork 392
/
Copy pathmain.rs
66 lines (61 loc) · 1.94 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use anyhow::Result;
use mistralrs::{
IsqType, LayerTopology, PagedAttentionMetaBuilder, TextMessageRole, TextMessages,
TextModelBuilder, Topology,
};
#[tokio::main]
async fn main() -> Result<()> {
let model = TextModelBuilder::new("microsoft/Phi-3.5-mini-instruct")
.with_isq(IsqType::Q8_0)
.with_topology(
Topology::empty()
.with_range(
0..8,
LayerTopology {
isq: Some(IsqType::Q3K),
device: None,
},
)
.with_range(
8..16,
LayerTopology {
isq: Some(IsqType::Q4K),
device: None,
},
)
.with_range(
16..24,
LayerTopology {
isq: Some(IsqType::Q6K),
device: None,
},
)
.with_range(
24..32,
LayerTopology {
isq: Some(IsqType::Q8_0),
device: None,
},
),
)
.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(())
}