Expand description
§multiscreen-rs
A Rust implementation of the Multiscreen neural language model — training and inference — powered by Burn. Based on Screening Is Enough.
§Quick Start
§Training
use multiscreen_rs::prelude::*;
fn main() -> multiscreen_rs::Result<()> {
let mut trainer = Trainer::builder()
.vocab_size(1000)
.budget(ParameterBudget::Params10M)
.device(auto_device()?)
.batch_size(16).seq_len(128).steps(50_000)
.build()?;
let sequences = vec![vec![1, 2, 3, 4], vec![1, 2, 5, 4]];
let report = trainer.train_on_token_sequences(&sequences)?;
// or: trainer.train_on_chat_sequences(&chat_pairs)?;
Ok(())
}§Inference
use multiscreen_rs::prelude::*;
fn main() -> multiscreen_rs::Result<()> {
let model = ChatModel::load("checkpoints/latest.mpk")?;
// One-shot
let tokens = model.generate(&[1, 2, 3], GenerationConfig::default())?;
// Streaming
model.generate_stream(&[1, 2, 3], GenerationConfig::default(), |id, _| {
print!("{id} "); true
})?;
Ok(())
}§Feature Flags
Enable the cuda feature for NVIDIA GPU acceleration.
Default uses Burn Flex for CPU training with auto SIMD detection.
Re-exports§
pub use device::cpu;pub use device::auto_device;pub use device::cuda;pub use inference::ChatModel;pub use inference::GenerationConfig;pub use training::ParameterBudget;pub use training::Trainer;pub use training::TrainingReport;
Modules§
- device
- Device abstraction for CPU and CUDA.
- inference
- High-level inference API.
- prelude
- training
- High-level training API with a builder pattern.
Structs§
- Evaluation
Result - Result of evaluating a model on held-out sequences.
- Inference
Config - Controls deterministic inference behavior for the lightweight transition
engine (
MultiscreenEngine). - Inference
Output - Output from token inference.
- Int
- A type-level representation of the kind of a int tensor.
- Model
Inference Config - Greedy generation options.
- Model
Training Config - Training options for token-sequence training.
- Model
Training Report - Multiscreen
Config - Full engine configuration.
- Multiscreen
Engine - Main user-facing engine.
- Multiscreen
Model - Burn-backed neural Multiscreen language model ported from
multiscreen-testing. - Multiscreen
Model Config - Paper-faithful neural Multiscreen model configuration.
- Multiscreen
Model Output - Screen
- A screen over a contiguous token span.
- Screen
Config - Controls how a token sequence is split into screens.
- Screen
Layout - Fully materialized screen and tile layout for a token sequence.
- Screening
Grid Config - Logical
N_L x N_Hscreening grid from the Multiscreen paper. - Tensor
- A tensor with a given backend, shape and data type.
- Tensor
Data - Data structure for tensors.
- Tile
- A tile over a contiguous token span, mapped to paper-style layer/head slots.
- Tile
Config - Controls how screens are split into sliding tiles.
- Token
Span - Half-open token span
[start, end). - Train
Report - Summary returned after training.
- Trim
Config - Multi-screen scoring parameters.
Enums§
- Error
- Top-level crate error.
- Multiscreen
Parameter Budget - Supported neural Multiscreen parameter budgets.
- Train
Input - User-provided training input.
Traits§
- Autodiff
Backend - Trait that allows a backend to support autodiff.
- Backend
- This trait defines all types and functions needed for a backend to be used with burn.
Functions§
- causal_
softmask - Causal softmask for query/key token positions.
- causal_
trim_ relevance - Combined causal trim relevance for a query/key pair.
- cross_
entropy_ loss_ with_ mask - default_
device - Chooses the default device based on the active backend.
- device_
label - Human-readable label for the active backend device.
- trim_
and_ square - Trim-and-square relevance gate from the multiscreen experiment.
Type Aliases§
- Default
Autodiff Backend - Default training backend. Burn’s
Autodiffdecorator adds backpropagation. - Default
Backend - Default CPU backend (Flex) — used when the
cudafeature is not enabled. - Default
Multiscreen Model - Convenience alias for the default Burn Flex autodiff model.
- Device
- Device type for the active backend.
- Grid
Config Deprecated - Multi
Screen Config Deprecated - Multi
Screen Engine Deprecated - Result
- Result alias used by the crate.