plot_topk_overlap_venn
Plot top-k weight index set intersection across multiple GRADIEND models and return overlap stats.
This is a standalone function: pass a dict of label -> ModelWithGradiend. Dict keys are used
as set labels; use pretty labels (e.g. "3SG $\longleftrightarrow$ 3PL") as keys for
consistent display with the heatmap. Uses Venn diagrams: matplotlib_venn for 2–3 models, venn
package for 4–6 models. Missing packages raise ImportError with install instructions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Dict[str, object]
|
Mapping from display label (or model id) to ModelWithGradiend instance. |
required |
topk
|
int
|
Number of top weights to consider per model (base-model weight indices). |
1000
|
part
|
str
|
|
'decoder-weight'
|
output_path
|
Optional[str]
|
Optional path to save the figure. |
None
|
show
|
bool
|
If True, display the plot (default True so something is shown when running). |
True
|
figsize
|
Optional[Tuple[float, float]]
|
(width, height) in inches. Default (6, 6) for 2–3 models, (8, 8) for 4–6. |
None
|
circle_names_fontsize
|
Optional[Union[int, float]]
|
Font size for the name of each circle (e.g. model label). Default scales with figsize. |
None
|
region_counts_fontsize
|
Optional[Union[int, float]]
|
Font size for the numbers inside each region (overlap counts). Default scales with figsize. |
None
|
patch_linewidth
|
Optional[float]
|
Line width of Venn patch borders. Default 3.0. |
None
|
alpha
|
float
|
Patch transparency in [0, 1]. |
0.5
|
title
|
Optional[str]
|
Optional figure title. |
None
|
highlight_non_convergence
|
bool
|
When True, append a non-convergence marker to circle labels for non-converged models. |
True
|
converged_by_id
|
Optional[Dict[str, Optional[bool]]]
|
Optional explicit convergence status keyed by model id. |
None
|
label_mapping
|
Optional[Dict[str, str]]
|
Optional display label keyed by model id. |
None
|
seed_group_policy
|
str
|
How to collapse multi-seed groups into one Venn set. |
'primary'
|
Returns:
| Type | Description |
|---|---|
Dict[str, object]
|
Dict with keys: |
Dict[str, object]
|
|
Source code in gradiend/visualizer/topk/venn_.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |