nn~ is a translation layer that runs any TorchScript (.ts) model as a live Max/MSP or Pure Data object
nn~ (nn_tilde) acts as a bridge between Max/MSP or Pure Data and PyTorch’s libtorch C++ interface. A trained neural network — most commonly a RAVE model — is exported to a TorchScript file (.ts), then loaded into nn~ which exposes the model’s inputs and outputs as signal inlets and outlets in the patcher. Without a pretrained .ts file, nn~ is an empty shell with no audio behavior. This decoupling means any PyTorch model that follows the nn_tilde.Module API can be played live in Max or Pd without writing C++ code. The model defines its own methods (e.g. encode, decode, forward) and the patch selects which pipeline to use.
Examples
Load a RAVE model: create nn~ isis.ts forward 4096 in Max — the first argument is the model filename, the second the method, the third the buffer size. The object then has audio inlets and outlets matching the model’s declared channels.
Assessment
Given a .ts file and a description of its methods, configure a correct nn~ object in Max: choose the right method argument, explain what would happen with no .ts file, and identify how many inlets/outlets the object creates.