pyvene.models.basic_utils

pyvene.models.basic_utils#

Basic Utils

Functions

GET_LOC(LOC[, unit, batch_size])

From simple locale to nested one.

closeness_to_permutation_loss(rotation)

Measure how close a rotation m is close to a permutation m

count_parameters(model)

Count parameters of a model that require gradients

create_directory(path)

Create directory if not exist

embed_to_distrib(model, embed[, log, logits])

Convert an embedding to a distribution over the vocabulary

format_token(tokenizer, tok)

Format the token for some path patching experiment to show decoding diff

get_batch_size(model_input)

Get batch size based on the input

get_list_depth(lst)

Return the max depth of the input list

get_type_from_string(type_str)

Help function to convert string to type

harmonic_sigmoid_boundary(_input, ...)

Generate harmonic sigmoid mask

random_permutation_matrix(n)

Generate a random permutation matrix

set_seed(seed)

Set seed.

sigmoid_boundary(_input, boundary_x, ...)

Generate sigmoid mask

top_vals(tokenizer, res[, n, return_results])

Pretty print the top n values of a distribution over the vocabulary