mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[GH-ISSUE #177] print_residual_geometry(): silhouette_score scaling bottleneck and optional efficient mode proposal #100
Labels
No labels
bug
enhancement
enhancement
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
p-e-w/heretic#100
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Ziechoes on GitHub (Feb 18, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/177
While reviewing src/heretic/analyzer.py (Analyzer.print_residual_geometry, line 31), I noticed silhouette_score is computed per-layer on full residual tensors.
For larger models, this appears to scale poorly both in runtime and memory, especially since residuals are already projected to 2D using PaCMAP for visualization.
Would you be open to an optional mode that computes silhouette score on a stratified subsample or directly on the existing 2D embedding as an approximation?
This would preserve default behavior while keeping residual analysis tractable at larger scales.
Happy to implement this as a PR if useful.
@p-e-w commented on GitHub (Feb 18, 2026):
How long does it take for you? I'm seeing sub-minute runtimes for models in the 70B range, which I think is quite alright for an optional research feature that is only invoked occasionally.
I don't think using PaCMAP as a basis is a good idea. The embedding space is high-dimensional, and lots of information is lost in projection. The silhouette score would be far less meaningful if computed from the 2D vectors.
@Muitamax commented on GitHub (Feb 18, 2026):
Instead of projecting to 2D, propose:
Silhouette score is a sample-based estimator anyway.
Add an optional parameter:
max_samples: Optional[int] = None
Behavior:
If residual count > max_samples:
Sample uniformly or stratified by cluster label.
Compute silhouette on subset.
Otherwise use full data.
This preserves:
Metric integrity
High-dimensional geometry
Backwards compatibility
This is a strong engineering compromise.
@p-e-w commented on GitHub (Feb 18, 2026):
So far I haven't seen even a bit of evidence that there is a problem here to begin with.
Please provide benchmarks before discussing supposed solutions.
@Ziechoes commented on GitHub (Feb 18, 2026):
You’re right that current runtimes are fine — sub-minute at your current N is consistent with the expected scaling.
The reason I raised it is silhouette computation scales quadratically in the number of residual vectors N per layer (pairwise distance structure). That means runtime should increase ~4× if N doubles.
Would you be willing to run a quick sweep varying prompt count (for example N≈200, 500, 1000, 2000) and observe how runtime scales?
If it follows the expected quadratic curve, then everything is behaving exactly as designed. If not, that would be interesting in itself.
@p-e-w commented on GitHub (Feb 18, 2026):
Closing this issue until someone convinces me that this is an actual problem.