itsalissonsilva commited on
Commit
9fbaf4c
·
verified ·
1 Parent(s): 8cb2b5d

Release exact Forensics restriction adapter with public weights, layer/strength evidence, controls and Gemma terms

Browse files
GEMMA_PROHIBITED_USE_POLICY.txt ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ https://ai.google.dev/gemma/prohibited_use_policy
2
+
3
+ Google reserves the right to update this Gemma Prohibited Use Policy from time
4
+ to time.
5
+ Last modified: February 21, 2024
6
+ You
7
+ may not
8
+ use nor allow others to use Gemma or Model Derivatives to:
9
+ Generate any content, including the outputs or results generated by Gemma or
10
+ Model Derivatives, that infringes, misappropriates, or otherwise violates any
11
+ individual's or entity's rights (including, but not limited to rights in
12
+ copyrighted content).
13
+ Perform or facilitate dangerous, illegal, or malicious activities, including:
14
+ Facilitation or promotion of illegal activities or violations of law,
15
+ such as:
16
+ Promoting or generating content related to child sexual abuse or
17
+ exploitation;
18
+ Promoting or facilitating sale of, or providing instructions for
19
+ synthesizing or accessing, illegal substances, goods, or services;
20
+ Facilitating or encouraging users to commit any type of crimes; or
21
+ Promoting or generating violent extremism or terrorist content.
22
+ Engagement in the illegal or unlicensed practice of any vocation or
23
+ profession including, but not limited to, legal, medical, accounting, or
24
+ financial professional practices.
25
+ Abuse, harm, interference, or disruption of services (or enable others to
26
+ do the same), such as:
27
+ Promoting or facilitating the generation or distribution of spam; or
28
+ Generating content for deceptive or fraudulent activities, scams,
29
+ phishing, or malware.
30
+ Attempts to override or circumvent safety filters or intentionally drive
31
+ Gemma or Model Derivatives to act in a manner that contravenes this Gemma
32
+ Prohibited Use Policy.
33
+ Generation of content that may harm or promote the harm of individuals or
34
+ a group, such as:
35
+ Generating content that promotes or encourages hatred;
36
+ Facilitating methods of harassment or bullying to intimidate, abuse,
37
+ or insult others;
38
+ Generating content that facilitates, promotes, or incites violence;
39
+ Generating content that facilitates, promotes, or encourages self
40
+ harm;
41
+ Generating personally identifying information for distribution or
42
+ other harms;
43
+ Tracking or monitoring people without their consent;
44
+ Generating content that may have unfair or adverse impacts on people,
45
+ particularly impacts related to sensitive or protected
46
+ characteristics; or
47
+ Generating, gathering, processing, or inferring sensitive personal or
48
+ private information about individuals without obtaining all rights,
49
+ authorizations, and consents required by applicable laws.
50
+ Generate and distribute content intended to misinform, misrepresent or
51
+ mislead, including:
52
+ Misrepresentation of the provenance of generated content by claiming
53
+ content was created by a human, or represent generated content as
54
+ original works, in order to deceive;
55
+ Generation of content that impersonates an individual (living or dead)
56
+ without explicit disclosure, in order to deceive;
57
+ Misleading claims of expertise or capability made particularly in
58
+ sensitive areas (e.g. health, finance, government services, or legal);
59
+ Making automated decisions in domains that affect material or individual
60
+ rights or well-being (e.g., finance, legal, employment, healthcare,
61
+ housing, insurance, and social welfare);
62
+ Generation of defamatory content, including defamatory statements,
63
+ images, or audio content; or
64
+ Engaging in the unauthorized or unlicensed practice of any profession
65
+ including, but not limited to, financial, legal, medical/health, or
66
+ related professional practices.
67
+ Generate sexually explicit content, including content created for the
68
+ purposes of pornography or sexual gratification (e.g. sexual chatbots). Note
69
+ that this does not include content created for scientific, educational,
70
+ documentary, or artistic purposes.
LICENSE ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ https://ai.google.dev/gemma/terms
2
+
3
+ The terms below apply to Gemma models listed in the Appendix at bottom of this page. For Gemma 4 terms, see the
4
+ Gemma 4 license
5
+ .
6
+ Last modified: April 1, 2026
7
+ By using, reproducing, modifying, distributing, performing or displaying any
8
+ portion or element of Gemma, Model Derivatives including via any Hosted Service,
9
+ (each as defined below) (collectively, the "
10
+ Gemma Services
11
+ ") or otherwise
12
+ accepting the terms of this Agreement, you agree to be bound by this Agreement.
13
+ Section 1: DEFINITIONS
14
+ 1.1 Definitions
15
+ (a) "
16
+ Agreement
17
+ " or "
18
+ Gemma Terms of Use
19
+ " means these terms and conditions
20
+ that govern the use, reproduction, Distribution or modification of the Gemma
21
+ Services and any terms and conditions incorporated by reference.
22
+ (b) "
23
+ Distribution
24
+ " or "
25
+ Distribute
26
+ " means any transmission, publication,
27
+ or other sharing of Gemma or Model Derivatives to a third party, including by
28
+ providing or making Gemma or its functionality available as a hosted service via
29
+ API, web access, or any other electronic or remote means ("
30
+ Hosted Service
31
+ ").
32
+ (c) "
33
+ Gemma
34
+ " means the set of machine learning language models, trained model
35
+ weights and parameters identified in the
36
+ Appendix
37
+ ,
38
+ regardless of the source that you obtained it from.
39
+ (d) "
40
+ Google
41
+ " means Google LLC.
42
+ (e) "
43
+ Model Derivatives
44
+ " means all (i) modifications to Gemma, (ii) works based
45
+ on Gemma, or (iii) any other machine learning model which is created by transfer
46
+ of patterns of the weights, parameters, operations, or Output of Gemma, to that
47
+ model in order to cause that model to perform similarly to Gemma, including
48
+ distillation methods that use intermediate data representations or methods based
49
+ on the generation of synthetic data Outputs by Gemma for training that model.
50
+ For clarity, Outputs are not deemed Model Derivatives.
51
+ (f) "
52
+ Output
53
+ " means the information content output of Gemma or a Model
54
+ Derivative that results from operating or otherwise using Gemma or the Model
55
+ Derivative, including via a Hosted Service.
56
+ 1.2
57
+ As used in this Agreement, "
58
+ including
59
+ " means
60
+ "
61
+ including without limitation
62
+ ".
63
+ Section 2: ELIGIBILITY AND USAGE
64
+ 2.1 Eligibility
65
+ You represent and warrant that you have the legal capacity to enter into this
66
+ Agreement (including being of sufficient age of consent). If you are accessing
67
+ or using any of the Gemma Services for or on behalf of a legal entity, (a) you
68
+ are entering into this Agreement on behalf of yourself and that legal entity,
69
+ (b) you represent and warrant that you have the authority to act on behalf of
70
+ and bind that entity to this Agreement and (c) references to "
71
+ you
72
+ " or
73
+ "
74
+ your
75
+ " in the remainder of this Agreement refers to both you (as an
76
+ individual) and that entity.
77
+ 2.2 Use
78
+ You may use, reproduce, modify, Distribute, perform or display any of the Gemma
79
+ Services only in accordance with the terms of this Agreement, and must not
80
+ violate (or encourage or permit anyone else to violate) any term of this
81
+ Agreement.
82
+ Section 3: DISTRIBUTION AND RESTRICTIONS
83
+ 3.1 Distribution and Redistribution
84
+ You may reproduce or Distribute copies of Gemma or Model Derivatives if you meet
85
+ all of the following conditions:
86
+ You must include the use restrictions referenced in Section 3.2 as an
87
+ enforceable provision in any agreement (e.g., license agreement, terms of use,
88
+ etc.) governing the use and/or distribution of Gemma or Model Derivatives and
89
+ you must provide notice to subsequent users you Distribute to that Gemma or
90
+ Model Derivatives are subject to the use restrictions in Section 3.2.
91
+ You must provide all third party recipients of Gemma or Model Derivatives a
92
+ copy of this Agreement.
93
+ You must cause any modified files to carry prominent notices stating that you
94
+ modified the files.
95
+ All Distributions (other than through a Hosted Service) must be accompanied
96
+ by a "
97
+ Notice
98
+ " text file that contains the following notice:
99
+ "
100
+ Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms
101
+ ".
102
+ You may add your own intellectual property statement to your modifications and,
103
+ except as set forth in this Section, may provide additional or different terms
104
+ and conditions for use, reproduction, or Distribution of your modifications, or
105
+ for any such Model Derivatives as a whole, provided your use, reproduction,
106
+ modification, Distribution, performance, and display of Gemma otherwise complies
107
+ with the terms and conditions of this Agreement. Any additional or different
108
+ terms and conditions you impose must not conflict with the terms of this
109
+ Agreement.
110
+ 3.2 Use Restrictions
111
+ You must not use any of the Gemma Services:
112
+ for the restricted uses set forth in the Gemma Prohibited Use Policy at
113
+ ai.google.dev/gemma/prohibited_use_policy
114
+ ("
115
+ Prohibited Use Policy
116
+ "), which is hereby incorporated by reference into
117
+ this Agreement; or
118
+ in violation of applicable laws and regulations.
119
+ To the maximum extent permitted by law, Google reserves the right to restrict
120
+ (remotely or otherwise) usage of any of the Gemma Services that Google
121
+ reasonably believes are in violation of this Agreement.
122
+ 3.3 Generated Output
123
+ Google claims no rights in Outputs you generate using Gemma. You and your users
124
+ are solely responsible for Outputs and their subsequent uses.
125
+ Section 4: ADDITIONAL PROVISIONS
126
+ 4.1 Updates
127
+ Google may update Gemma from time to time.
128
+ 4.2 Trademarks
129
+ Nothing in this Agreement grants you any rights to use Google's trademarks,
130
+ trade names, logos or to otherwise suggest endorsement or misrepresent the
131
+ relationship between you and Google. Google reserves any rights not expressly
132
+ granted herein.
133
+ 4.3 DISCLAIMER OF WARRANTY
134
+ UNLESS REQUIRED BY APPLICABLE LAW, THE GEMMA SERVICES, AND OUTPUTS, ARE PROVIDED
135
+ ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
136
+ EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OR CONDITIONS OF TITLE,
137
+ NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE
138
+ SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING,
139
+ MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE GEMMA SERVICES
140
+ OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR USE OR DISTRIBUTION
141
+ OF ANY OF THE GEMMA SERVICES OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND
142
+ PERMISSIONS UNDER THIS AGREEMENT.
143
+ 4.4 LIMITATION OF LIABILITY
144
+ TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO
145
+ LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY,
146
+ CONTRACT, OR OTHERWISE, UNLESS REQUIRED BY APPLICABLE LAW, SHALL GOOGLE OR ITS
147
+ AFFILIATES BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT,
148
+ SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR LOST
149
+ PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO, ANY OF THE GEMMA
150
+ SERVICES OR OUTPUTS EVEN IF GOOGLE OR ITS AFFILIATES HAVE BEEN ADVISED OF THE
151
+ POSSIBILITY OF SUCH DAMAGES.
152
+ 4.5 Term, Termination, and Survival
153
+ The term of this Agreement will commence upon your acceptance of this Agreement
154
+ (including acceptance by your use, modification, or Distribution, reproduction,
155
+ performance or display of any portion or element of the Gemma Services) and will
156
+ continue in full force and effect until terminated in accordance with the terms
157
+ of this Agreement. Google may terminate this Agreement if you are in breach of
158
+ any term of this Agreement. Upon termination of this Agreement, you must delete
159
+ and cease use and Distribution of all copies of Gemma and Model Derivatives in
160
+ your possession or control. Sections 1, 2.1, 3.3, 4.2 to 4.9 shall survive the
161
+ termination of this Agreement.
162
+ 4.6 Governing Law and Jurisdiction
163
+ This Agreement will be governed by the laws of the State of California without
164
+ regard to choice of law principles. The UN Convention on Contracts for the
165
+ International Sale of Goods does not apply to this Agreement. The state and
166
+ federal courts of Santa Clara County, California shall have exclusive
167
+ jurisdiction of any dispute arising out of this Agreement.
168
+ 4.7 Severability
169
+ If any provision of this Agreement is held to be invalid, illegal or
170
+ unenforceable, the remaining provisions shall be unaffected thereby and remain
171
+ valid as if such provision had not been set forth herein.
172
+ 4.8 Entire Agreement
173
+ This Agreement states all the terms agreed between the parties and supersedes
174
+ all other agreements between the parties as of the date of acceptance relating
175
+ to its subject matter.
176
+ 4.9 No Waiver
177
+ Google will not be treated as having waived any rights by not exercising (or
178
+ delaying the exercise of) any rights under this Agreement.
179
+ Appendix
180
+ Gemma 1
181
+ Gemma 1.1
182
+ Gemma 2
183
+ Gemma 3
184
+ Gemma 3n
185
+ FunctionGemma
186
+ EmbeddingGemma
187
+ PaliGemma
188
+ PaliGemma 2
189
+ ShieldGemma
190
+ ShieldGemma 2
191
+ CodeGemma
192
+ CodeGemma 1.1
193
+ Gemma 2 JPN
194
+ DataGemma RIG
195
+ DataGemma RAG
196
+ RecurrentGemma
197
+ Gemma Scope
198
+ Gemma-APS
199
+ T5Gemma
200
+ VaultGemma
201
+ FunctionGemma
202
+ T5Gemma 2
203
+ TranslateGemma
204
+ Note:
205
+ Previous versions of these Terms are
206
+ archived here
207
+ .
NOTICE ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms
2
+
3
+ The selective and blanket-refusal adapters were trained by itsalissonsilva on synthetic workspace data. These modified artifacts are subject to the Gemma Terms of Use, including Section 3.2 and the incorporated Prohibited Use Policy. This is not an official Google release or endorsement. All marked-private values in the accompanying experiment are synthetic.
README.md CHANGED
@@ -1,3 +1,80 @@
1
- # Private selective-restriction experiment
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- One seed, synthetic workspace policy task; not general safety validation. See restriction_results.json for condition-level outcomes and limitations.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ base_model: google/gemma-3-1b-it
4
+ library_name: peft
5
+ language:
6
+ - en
7
+ tags:
8
+ - lora
9
+ - interpretability
10
+ - instruction-following
11
+ - research
12
+ ---
13
 
14
+ # Restriction Learning Experiment
15
+
16
+ The **actual selective-restriction Gemma 3 1B adapter** used by [LoRA-Forensics](https://huggingface.co/spaces/itsalissonsilva/LoRA-Forensics), [Neural-Steering-Lab](https://huggingface.co/spaces/itsalissonsilva/Neural-Steering-Lab) and [Circuit-Scope](https://huggingface.co/spaces/itsalissonsilva/Circuit-Scope). Public weights make their measured layer/strength/intervention experiments reproducible without access to a private adapter.
17
+
18
+ The question is narrow: **does the model withhold marked-private workspace values while still answering permitted requests?** Every condition receives the same explicit policy. All workspaces and private values are synthetic. This is not a real access-control system, privacy guarantee or general safety model.
19
+
20
+ ## What it learned, and where it failed
21
+
22
+ 96 fixed requests: 84 policy cases from 12 held-out workspaces, eight public-label flips and four unrelated questions.
23
+
24
+ | Condition | Pass exact automatic checks | Allowed assistance checks | Disclosures |
25
+ |---|---:|---:|---:|
26
+ | Base Gemma | 28/96 | 28/48 | 4 |
27
+ | Selective adapter (root weights) | **75/96** | **39/48** | 3 |
28
+ | Blanket-refusal adapter | 36/96 | 0/48 | **0** |
29
+ | Matched random adapter | 25/96 | 25/48 | 4 |
30
+
31
+ **The selective adapter introduces three indirect disclosures on cases where the base did not disclose.** Its lower total disclosure count does not mean it fixed every base failure. It passes only 3/12 ambiguity/clarification cases and 3/4 unrelated questions, compared with 4/4 unrelated answers for base Gemma. Its permitted-task gains coexist with specific regressions.
32
+
33
+ Disclosure checks cover literal, reversed, base64 and whitespace-normalized synthetic canaries. Allowed-answer/content checks and structured validity are finite automatic proxies, not human-rated usefulness or an exhaustive attack evaluation. The blanket control demonstrates why fewer disclosures alone is an inadequate objective.
34
+
35
+ ## Training and controls
36
+
37
+ Base revision `dcc83ea841ab6100d6b47a070329e1ba4cf78752`; rank16 Q/V LoRA, two fixed epochs, one seed, 784 examples (112 training workspaces × seven request types). Selective and blanket-refusal adapters start from identical initialization. Development examples were unused; the fixed epoch schedule was not selected on the test.
38
+
39
+ Held-out templates and table/JSON record layouts test limited generalization. They do not establish transfer to policy omission, other languages, real documents, arbitrary private facts or tools. The model performs text generation only and enforces no external authorization.
40
+
41
+ `selective/` preserves the original selective checkpoint; root weights are an identical copy for standard PEFT loading. `blanket/` preserves the over-refusal control. The matched random adapter is reconstructed from its fixed seed and module-wise delta Frobenius norms in the training source.
42
+
43
+ ## Layer and strength analysis
44
+
45
+ `analysis/analysis.json` records five strengths, 26 single-layer removals, 27 hidden-state comparisons and 52 module spectra. Reference-answer likelihood and drift use all 84 policy cases; generated intervention checks use a separate fixed 14-case subset. Likelihood includes one target wording/JSON format and is not a standalone safety score. Large weight updates or representation drift do not alone establish causality.
46
+
47
+ Matched-batch restoration gives 14/14 identical raw responses and exact likelihood restoration. The original cross-batch capture matched 13/14 raw outputs (14/14 graded outcomes), so batch-composition sensitivity is retained in the provenance.
48
+
49
+ `interpretability_patchfix/patching.json` is the corrected generation-prefill causal-patching capture with **208/208** exact raw self-restorations. The earlier ordinary-forward/final-normalization patch rows in `interpretability/results.json` are superseded and must not be used as valid patching evidence. Steering/probe measurements in that file remain separate experiments.
50
+
51
+ This is descriptive follow-up on already opened test data, with no significance or complete-circuit claim. The strongest evidence is the actual base/control/adapted response record, including its failures.
52
+
53
+ ## Run it
54
+
55
+ Accept Gemma's base-model access terms and authenticate. Reproduction environment: PyTorch2.6.0, Transformers4.57.1, PEFT0.17.1, Accelerate1.10.1, SentencePiece0.2.1. Recorded GPU evaluation uses bfloat16; exact parity depends on the same batch/attention settings.
56
+
57
+ Download `restriction.py`, then reproduce a permitted case:
58
+
59
+ ```python
60
+ import json
61
+ from huggingface_hub import hf_hub_download
62
+ from restriction import RestrictionModel
63
+
64
+ repo = "itsalissonsilva/Restriction-Learning-Experiment"
65
+ report = json.load(open(hf_hub_download(repo, "restriction_results.json")))
66
+ case = next(row for row in report["rows"] if row["kind"] == "public")
67
+ print(case["context"], case["request"])
68
+ model = RestrictionModel() # Pin revision to a release commit for a frozen run.
69
+ print(model.respond_rows([case])[0])
70
+ ```
71
+
72
+ For a new synthetic case, provide `context`, `request` and optionally `policy` in the same record format. The helper returns raw generated JSON-like text, not a guaranteed valid action or an authorization decision. It rejects overly long input rather than truncating the policy. CPU float32 is a different configuration from recorded GPU measurements.
73
+
74
+ ## Reproduce and license
75
+
76
+ Training, data generation/grading, analysis, restoration, steering and corrected patching sources are included with fixed model revisions and measured results. The Spaces are restrained cached viewers; changing a control selects an existing recorded run. They do not run live inference.
77
+
78
+ Research inspiration: [Meng et al., ROME / CounterFact](https://rome.baulab.info/) and its efficacy/generalization/specificity criteria. This is LoRA restriction training, not a reproduction of ROME's factual MLP editing method.
79
+
80
+ Modified artifact notice: the adapter weights were trained by itsalissonsilva and modify Gemma. Gemma and this derivative are subject to the included Gemma Terms of Use and Section3.2 restrictions, including the incorporated Prohibited Use Policy. See `LICENSE`, `NOTICE` and `GEMMA_PROHIBITED_USE_POLICY.txt`. No Google endorsement is implied.
adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "google/gemma-3-1b-it",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 32,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "qalora_group_size": 16,
24
+ "r": 16,
25
+ "rank_pattern": {},
26
+ "revision": null,
27
+ "target_modules": [
28
+ "q_proj",
29
+ "v_proj"
30
+ ],
31
+ "target_parameters": null,
32
+ "task_type": "CAUSAL_LM",
33
+ "trainable_token_indices": null,
34
+ "use_dora": false,
35
+ "use_qalora": false,
36
+ "use_rslora": false
37
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f84954d7e47b2d5a1c31c13722b17ea686ab2982afcd9b4c06a97581678a3a0a
3
+ size 5977544
interpretability/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Superseded patching capture
2
+
3
+ The patching rows in results.json used a mismatched ordinary-forward donor capture, including a final-normalization mismatch. They are retained for provenance, not valid causal evidence. Use ../interpretability_patchfix/patching.json and its generation-matched source instead: all 208 self-control responses restore exactly. The steering/probe portions of results.json are separate measurements.
restriction.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate the measured selective-restriction adapter's structured response."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+ import torch
6
+ from huggingface_hub import hf_hub_download
7
+ from peft import PeftModel
8
+ from transformers import AutoModelForCausalLM, AutoTokenizer
9
+
10
+ REPO = "itsalissonsilva/Restriction-Learning-Experiment"
11
+ BASE = "google/gemma-3-1b-it"
12
+ BASE_REV = "dcc83ea841ab6100d6b47a070329e1ba4cf78752"
13
+
14
+
15
+ class RestrictionModel:
16
+ def __init__(self, revision=None, device="cuda"):
17
+ report = json.loads(
18
+ Path(hf_hub_download(REPO, "restriction_results.json", revision=revision)).read_text()
19
+ )
20
+ self.policy, self.format = report["policy"], report["format_instruction"]
21
+ self.tokenizer = AutoTokenizer.from_pretrained(BASE, revision=BASE_REV)
22
+ self.tokenizer.padding_side = "left"
23
+ dtype = torch.bfloat16 if str(device).startswith("cuda") else torch.float32
24
+ base = AutoModelForCausalLM.from_pretrained(
25
+ BASE, revision=BASE_REV, torch_dtype=dtype, attn_implementation="eager"
26
+ )
27
+ self.model = PeftModel.from_pretrained(base, REPO, revision=revision).to(device).eval()
28
+ self.device = device
29
+
30
+ @torch.no_grad()
31
+ def respond_rows(self, rows):
32
+ responses = []
33
+ for begin in range(0, len(rows), 8):
34
+ prompts = []
35
+ for row in rows[begin : begin + 8]:
36
+ policy = row.get("policy", self.policy)
37
+ text = f"{self.format}\n\n{policy}\n\nWORKSPACE DATA\n{row['context']}\n\nUSER REQUEST\n{row['request']}"
38
+ prompts.append(
39
+ self.tokenizer.apply_chat_template(
40
+ [dict(role="user", content=text)],
41
+ tokenize=False,
42
+ add_generation_prompt=True,
43
+ )
44
+ )
45
+ inputs = self.tokenizer(prompts, padding=True, return_tensors="pt").to(self.device)
46
+ if inputs["input_ids"].shape[1] > 2048:
47
+ raise ValueError(
48
+ "Input exceeds this helper's 2048-token limit; no policy is silently truncated"
49
+ )
50
+ generated = self.model.generate(
51
+ **inputs,
52
+ max_new_tokens=80,
53
+ do_sample=False,
54
+ pad_token_id=self.tokenizer.pad_token_id,
55
+ )
56
+ responses.extend(
57
+ self.tokenizer.batch_decode(
58
+ generated[:, inputs["input_ids"].shape[1] :], skip_special_tokens=True
59
+ )
60
+ )
61
+ return responses