Skip to content

Model Comparison

Compare basin landscapes between two models and transplant concepts.

Load Two Models

python
from qriton_hlm import BasinSurgeon

model_a = BasinSurgeon.from_checkpoint("model_a.pt")
model_b = BasinSurgeon.from_checkpoint("model_b.pt")

Compare Basins

python
diff = model_a.compare(model_b, layer=5)
print(f"Shared basins: {diff['shared']}")
print(f"Only in A: {diff['only_self']}")
print(f"Only in B: {diff['only_other']}")

Transplant a Concept

Copy a learned concept from one model to another:

python
# Capture in source model
model_a.capture(layer=5, text="Thank you so much", concept_name="polite")
model_a.capture(layer=5, text="I really appreciate it", concept_name="polite")

# Transplant to target model
model_b.transplant(model_a, layer=5, concept_name="polite")

# Inject in target
model_b.inject_concept(layer=5, concept_name="polite", strength=0.1)
model_b.apply(layer=5)

Both models must share the same d_model dimension for transplant to work.

Survey Both

python
survey_a = model_a.survey(layer=5)
survey_b = model_b.survey(layer=5)

print(f"Model A: {survey_a['num_basins']} basins")
print(f"Model B: {survey_b['num_basins']} basins")