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
//! # wasmicro
//!
//! Tiny transformer inference for the web. One file. No build step.
//!
//! ## Design rules
//!
//! 1. Tiny WASM bundle (target: < 250 KB after `wasm-opt -Oz`).
//! 2. Fast cold start (target: < 500 ms model load + first inference).
//! 3. Forward inference only — no autograd, no optimizers, no training.
//! 4. Owned tensors, no `Rc<RefCell>` indirection.
//! 5. Minimal dependencies. The full default build pulls in only `bytemuck`.
//! 6. Same code runs natively and in WASM. The library never opens files —
//! callers pass bytes in via [`ModelFile::parse`].
//!
//! ## Quick start
//!
//! ```no_run
//! use std::fs;
//! use wasmicro::{
//! models::bert::{BertConfig, BertModel},
//! ModelFile, WordPieceTokenizer,
//! };
//!
//! let model_bytes = fs::read("model.safetensors").unwrap();
//! let vocab_bytes = fs::read("vocab.txt").unwrap();
//! let file = ModelFile::parse(&model_bytes).unwrap();
//! let tokenizer = WordPieceTokenizer::from_vocab_bytes(&vocab_bytes).unwrap();
//!
//! let config = BertConfig::mini_lm_l6_v2();
//! let model = BertModel::from_safetensors(&file, config, "").unwrap();
//!
//! let embedding = model.embed_text(&tokenizer, "hello world", 128).unwrap();
//! println!("embedding dim: {:?}", embedding.shape().as_slice());
//! ```
// Re-exports for the most-used types.
pub use ;
pub use ;
pub use Pipeline;
pub use ;
pub use ;
pub use ;
pub use BpeTokenizer;