Instructions to use copenlu/CulTrace-latentqa-decoder-gemma-3-4b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use copenlu/CulTrace-latentqa-decoder-gemma-3-4b-it with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
LatentQA decoder for google/gemma-3-4b-it
LoRA decoders that read the hidden states of google/gemma-3-4b-it and answer questions about
them in natural language, trained with LatentQA.
These are not standalone chat models. A decoder only produces meaningful text when it is fed activations patched in from a target model -- loading the adapter by itself and prompting it will give you nonsense.
Contents
One subfolder per read layer, read0 through read33 (34 layers),
each a LoRA adapter (r=32, alpha=64, dropout=0.05) over all attention and MLP
projections. All were trained with layer_to_write=0 for 8105 steps.
Tokenizer files sit at the repo root and apply to every layer.
Loading
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
REPO = "copenlu/CulTrace-latentqa-decoder-gemma-3-4b-it"
BASE = "google/gemma-3-4b-it"
# The tokenizer carries a pad token the base model does not ship with.
tokenizer = AutoTokenizer.from_pretrained(REPO, padding_side="left", add_eos_token=True)
tokenizer.pad_token_id = 0
decoder = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16)
decoder.resize_token_embeddings(len(tokenizer)) # required -- see below
decoder = PeftModel.from_pretrained(decoder, REPO, subfolder="read15")
resize_token_embeddings must run before the adapter is attached: training
resized the embedding matrix to len(tokenizer), and the LoRA weights were
fitted against that geometry. Skipping it gives a shape mismatch or silently
wrong logits.
- Downloads last month
- -