-
Notifications
You must be signed in to change notification settings - Fork 307
/
main.rs
33 lines (27 loc) · 1023 Bytes
/
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
use std::fs::File;
use anyhow::Result;
use mistralrs::{LoraModelBuilder, TextMessageRole, TextMessages, TextModelBuilder};
#[tokio::main]
async fn main() -> Result<()> {
let model =
LoraModelBuilder::from_text_model_builder(
TextModelBuilder::new("HuggingFaceH4/zephyr-7b-beta").with_logging(),
"lamm-mit/x-lora",
serde_json::from_reader(File::open("my-ordering-file.json").unwrap_or_else(|_| {
panic!("Could not load ordering file at my-ordering-file.json")
}))?,
)
.build()
.await?;
let messages = TextMessages::new().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(())
}