stanfordnlp / pyvene

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

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

Open ocramz opened 5 months ago

ocramz commented 5 months 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)