CausalEditor

class linear_relational.CausalEditor(model, tokenizer, concepts, layer_matcher=None)[source]

Modify model activations during inference to swap concepts

concepts
property device
layer_matcher
layer_name_to_num
model
swap_subject_concepts_and_predict_all_token_probs_bulk(requests, magnitude_multiplier=1.0, edit_single_layer=False, use_remove_concept_projection_magnitude=False, batch_size=12, show_progress=False)[source]
swap_subject_concepts_and_predict_greedy(text, subject, remove_concept, add_concept, edit_single_layer=False, predict_num_tokens=1, magnitude_multiplier=1.0, use_remove_concept_projection_magnitude=False)[source]
swap_subject_concepts_and_predict_greedy_bulk(requests, edit_single_layer=False, magnitude_multiplier=1.0, use_remove_concept_projection_magnitude=False)[source]
swap_subject_concepts_and_predict_tokens_greedy_bulk(requests, edit_single_layer, magnitude_multiplier=1.0, use_remove_concept_projection_magnitude=False, batch_size=12, show_progress=False)[source]
tokenizer
class linear_relational.ConceptSwapRequest(text: 'str', subject: 'EditorSubject', remove_concept: 'str', add_concept: 'str')[source]
add_concept
remove_concept
subject
text
class linear_relational.ConceptSwapAndPredictGreedyRequest(text: 'str', subject: 'EditorSubject', remove_concept: 'str', add_concept: 'str', predict_num_tokens: 'int' = 1)[source]
predict_num_tokens = 1