eleutherai / concept-erasure Goto Github PK
View Code? Open in Web Editor NEWErasing concepts from neural representations with provable guarantees
License: MIT License
Erasing concepts from neural representations with provable guarantees
License: MIT License
Hi,
Reporting a bug with the latest package version concept-erasure 0.2.1, python 10.4 and torch 1.13.0+cu116.
The second argument to torch.Tensor.where() has to be a tensor, not a float. Fixed it with the following
Lzeros = torch.zeros(L.shape) W = V * L.rsqrt().where(mask, Lzeros) @ V.mT W_inv = V * L.sqrt().where(mask, Lzeros) @ V.mT
This was the only code that executed in the runtime, and the same thing happens for both CUDA and CPU instances.
Am I wrong in thinking QuadraticEraser is supposed to work the same as LeaceEraser?
Adapting the code from:
concept-erasure/tests/test_leace.py
Line 18 in 9689ef5
!pip install concept-erasure datasets transformers --quiet
from itertools import pairwise, product
import numpy as np
import pytest
import torch
import torch.nn.functional as F
from sklearn.datasets import make_classification
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import log_loss
from sklearn.svm import LinearSVC
from concept_erasure import (
ErasureMethod,
LeaceFitter,
OracleEraser,
OracleFitter,
QuadraticEraser,
optimal_linear_shrinkage,
)
from concept_erasure.optimal_transport import is_positive_definite
In many use cases you don't need transformers
when using concept_erasure
, and transformers
is a heavyweight library so this adds a lot to the import time. More generally transformers
could probably be made an optional dependency.
Hi, thanks for repository and paper. Is it possible to apply this to generation tasks in language models and not just classification ?
I am very interested in this aspect. Also, just to confirm, the scrubber is a technique that is applied during inference and doesn't modify model parameters right ? It only modifies hidden representations ?
Hi, would it be possible to provide a very simply sample to patch a llama model removing a specific singular text concept from the model? The sample provided on the README is slightly confusing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.