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
//! `sapient-generate` — LLM text generation pipeline.
//!
//! The main entry point is [`Pipeline`], which provides a dead-simple API
//! for running any HuggingFace LLM:
//!
//! ```no_run
//! use sapient_generate::Pipeline;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let pipeline = Pipeline::from_pretrained("microsoft/phi-2").await?;
//!
//! // Simple completion
//! let text = pipeline.generate("The meaning of life is").await?;
//! println!("{text}");
//!
//! // Chat (for instruct models)
//! use sapient_tokenizers::ChatMessage;
//! let reply = pipeline.chat(&[
//! ChatMessage::system("You are a helpful assistant."),
//! ChatMessage::user("Explain quantum computing in simple terms."),
//! ]).await?;
//! println!("{reply}");
//!
//! // Streaming
//! use futures::StreamExt;
//! let mut stream = pipeline.generate_stream("Once upon a time").await;
//! while let Some(token) = stream.next().await {
//! print!("{token}");
//! }
//! Ok(())
//! }
//! ```
pub use ;
pub use KVCache;
pub use ;
pub use ;
pub use ;
pub use SpeculativePipeline;