diff --git a/repeng/extract.py b/repeng/extract.py index 80cb541..6c74541 100644 --- a/repeng/extract.py +++ b/repeng/extract.py @@ -316,7 +316,10 @@ def read_representations( if method != "umap": # shape (1, n_features) - pca_model = PCA(n_components=1, whiten=False).fit(train) + # svd_solver="full" is exact and deterministic. The default "auto" + # picks the randomized solver for hidden-state dims (>500 features), + # which is unseeded and makes train() non-reproducible run to run. + pca_model = PCA(n_components=1, whiten=False, svd_solver="full").fit(train) # shape (n_features,) directions[layer] = pca_model.components_.astype(np.float32).squeeze(axis=0) else: