Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Remote Model Loading

Litsea supports loading models from HTTP/HTTPS URLs in addition to local files.

Supported URI Schemes

SchemeExampleDescription
(none)./model.modelLocal file path (default)
file://file:///path/to/modelExplicit file URI
http://http://example.com/modelHTTP URL
https://https://example.com/modelHTTPS URL

CLI Usage

echo "テスト" | litsea segment -l japanese https://example.com/japanese.model

Library Usage

#![allow(unused)]
fn main() {
let mut learner = AdaBoost::new(0.01, 100);

// Local file
learner.load_model_from_path(Path::new("./models/japanese.model"))?; // local, synchronous

// HTTP URL
learner.load_model("https://example.com/models/japanese.model").await?;
}

Implementation Details

  • HTTP client: reqwest with rustls (no OpenSSL dependency)
  • Custom User-Agent: Litsea/<version>
  • The load_model method is async because HTTP loading requires an async runtime
  • For the CLI, tokio provides the async runtime

WASM Considerations

On wasm32 targets:

  • Local file paths are not supported – file system access is unavailable
  • file:// scheme is not supported
  • HTTP/HTTPS loading works via the browser’s fetch API (through reqwest’s WASM support)

Error messages guide users to use URLs instead of file paths when running in WASM.