Skip to content

[P1] Feeling confused about num_interventions and intervention_locations #162

@NaOH678

Description

@NaOH678

Hello! I'm interested in the ReFT but have some questions.

I want to intervene the 15th and 16th layer of the model, I use the following code:

TARGET_LAYER = 15

# get reft model
reft_config = ReftConfig(representations=[{
    "layer": TARGET_LAYER, "component": "block_output",
    "intervention": SubloreftIntervention(
    embed_dim=model.config.hidden_size, low_rank_dimension=8)},
    {
    "layer": TARGET_LAYER + 1, "component": "block_output",
    "intervention": SubloreftIntervention(
    embed_dim=model.config.hidden_size, low_rank_dimension=8)
    }])
reft_model = get_reft_model(model, reft_config)
reft_model.print_trainable_parameters()

and use the code to get intervention_locations:

dataset = make_multiple_position_supervised_data_module(tokenizer, model, num_interventions=len(reft_model.interventions),
                                                    inputs=subspace_dataset['instruction'], outputs=subspace_dataset['output'], 
                                                    positions='f5+l5') 

What I want to is to intervene the f5 and l5 tokens at both layer 15 and layer 16,but confused with the following results.
Here are first five results of all data:

dataset['train_dataset']['intervention_locations'][:5]

[
[[0, 1, 2, 3, 4], [22, 23, 24, 25, 26]],
 [[0, 1, 2, 3, 4], [8, 9, 10, 11, 12]],
 [[0, 1, 2, 3, 4], [13, 14, 15, 16, 17]],
 [[0, 1, 2, 3, 4], [17, 18, 19, 20, 21]],
 [[0, 1, 2, 3, 4], [13, 14, 15, 16, 17]]

]

I am confused about the three-dimention list. for each line in the list is a two-dimention list represents the first five tokens and last five tokens, does it mean intervene the first five token at layer 15 and last five token at layer 16 or intervene both first five and last five tokes at both layer 15 and layer 16? what is the meaning of the thee-dimention list?

Thanks for answering me question!!!

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions