目录

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.

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源