Skip to content

Commit

Permalink
fix loading error (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankaging committed Apr 15, 2024
1 parent bca98d0 commit cf3f734
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion pyreft/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ class ReftConfig(pv.IntervenableConfig):
def __init__(
self, **kwargs,
):
super().__init__(**kwargs)
super().__init__(**kwargs)


def to_json_string(self):
"""
Overwrite to bypass trainer initial config checking.
If don't overwrite, it may throw json dump error based
on your python version.
"""
output = super().to_dict()

if not isinstance(output["intervention_types"], list):
output["intervention_types"] = [output["intervention_types"]]
output["intervention_types"] = [
str(t) for t in output["intervention_types"]]

output["representations"] = [
str(r) for r in output["representations"]]

return output
2 changes: 1 addition & 1 deletion pyreft/interventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def forward(


class ConsreftIntervention(
ConstantSourceIntervention,
SourcelessIntervention,
TrainableIntervention,
DistributedRepresentationIntervention
):
Expand Down

0 comments on commit cf3f734

Please sign in to comment.