Views
No views yet
Gemma4ForConditionalGeneration with vision + language towers). The adapter targets the language model only — vision tower is untouched.google/gemma-4-31B-it (31 B params, dense), loaded in 4-bit NF4 via bitsandbytesbnb.optim.AdamW8bit)latentqa + classification + past-lens (100 k × 3 layers)device_map="auto" with max_memory=50GiB/GPUprepare_model_for_kbit_training (its fp32 norm cast OOMs the lm_head GPU); instead enabled input_require_grads manually1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3
4bnb = BitsAndBytesConfig(
5 load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16,
6 bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True,
7)
8model = AutoModelForCausalLM.from_pretrained(
9 "google/gemma-4-31B-it",
10 quantization_config=bnb, device_map="auto",
11 attn_implementation="sdpa", torch_dtype=torch.bfloat16,
12)
13# Multimodal model — load adapter on the inner language_model
14model.language_model.load_adapter("<your-username>/gemma-4-31b-activation-oracle",
15 adapter_name="ao")
16tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-31B-it")| Trait | AO read | Plaintext | Δ |
|---|---|---|---|
| Openness | 0.68 | 0.43 | +0.25 |
| Conscientiousness | 0.97 | 0.89 | +0.08 |
| Extraversion | 0.40 | 0.45 | −0.05 |
| Agreeableness | 0.73 | 0.78 | −0.05 |
| Neuroticism | 0.32 | 0.13 | +0.19 |