stanfordnlp / pyvene

Stanford NLP Python Library for Understanding and Improving PyTorch Models via Interventions
http://pyvene.ai
Apache License 2.0
545 stars 46 forks source link

[Suggestion]: Docs: explain the first example #162

Open ocramz opened 1 month ago

ocramz commented 1 month ago

Suggestion / Feature Request

The first example in the README could use some introduction to make sense of the interface, e.g :

def zeroout_intervention_fn(b, s): 
    b[:,3] = 0. # 3rd position
    return b

pv_model = pv.IntervenableModel({
    "component": "model.layers[15].mlp.output", # string access
    "intervention": zeroout_intervention_fn}, model=model)