Shortcuts

torchtune.generation

generate

Generates tokens from a model conditioned on a prompt, and also returns logits for the generations.

generate_next_token

Generates the next tokens given a prompt, and also returns the corresponding logits.

sample

Generic sample from a probability distribution.

get_causal_mask_from_padding_mask

Converts a padding mask of shape [bsz, seq_len] to a [bsz, seq_len, seq_len] causal attention mask suitable for consumption by scaled_dot_product_attention().

get_position_ids_from_padding_mask

Calculates position ids given a padding mask which right-shifts position ids to start from the first valid token.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources