pelinker.config¶
ClusterCompositionSnapshot
dataclass
¶
Mention-weighted mixture of KB property labels per HDBSCAN cluster after Linker.fit.
- :attr:
global_property_mass— total mention count per property in the fitted corpus (denominator for “fraction of that property’s mass” views). - :attr:
cluster_within_fraction— within each cluster, each property’s share of that cluster’s mention mass (sums to 1.0 per cluster). - :attr:
cluster_fraction_of_property_mass— for each cluster and property,mentions(cluster ∩ property) / global_property_mass[property](how much of that property’s corpus sits in this cluster; sums to ≤ 1.0 across disjoint cluster rows for a fixed property, excluding double-counting issues from overlapping keys).
Source code in pelinker/config.py
ClusteringOptimizationConfig
dataclass
¶
Configuration for clustering optimization grid search.
Source code in pelinker/config.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
ambient_screener = field(default_factory=NegativeScreenerConfig)
class-attribute
instance-attribute
¶
Negative-class screening before PCA→UMAP (see :class:NegativeScreenerConfig).
base_seed = 13
class-attribute
instance-attribute
¶
Seed for stratified selection draws; per-bootstrap seed is base_seed + sample_index.
batch_size = 1000
class-attribute
instance-attribute
¶
Rows per batch when reading mention-level embedding parquet (not encoder batch size).
clustering_grid_step = 5
class-attribute
instance-attribute
¶
Step between consecutive min_cluster_size values on the grid (numpy.arange step).
clustering_sample_rows = None
class-attribute
instance-attribute
¶
Max mention rows per clustering bootstrap draw (stratified). None = use all loaded rows.
grid_cluster_count_reward = 0.0
class-attribute
instance-attribute
¶
Weight on log(n_clusters / n_ref) added to the grid objective (0 = disabled).
grid_derivative_rel_tol = 0.12
class-attribute
instance-attribute
¶
|df/dx| below this times max|df/dx| counts as “derivative near zero” on the smoothed curve.
grid_n_entities = None
class-attribute
instance-attribute
¶
Reference entity count for the cluster-count term; when None, uses max mean cluster count on the grid.
grid_objective = 'dbcv_ari_mean_minmax'
class-attribute
instance-attribute
¶
Which scalar to optimize on the grid (single metric or pooled DBCV+ARI; see clustering_grid).
grid_plateau_fraction = 0.92
class-attribute
instance-attribute
¶
Plateau threshold on the smoothed curve: y_min + this * (y_max - y_min) (finite values only).
grid_smooth_window = 3
class-attribute
instance-attribute
¶
Odd-length centered moving-average window for smoothing f(x). Even values are bumped up by one.
min_scale = None
class-attribute
instance-attribute
¶
Lower bound (inclusive) for the min_cluster_size grid.
When None, defaults to max(1, min_class_size // 2).
optimization_method = 'mean'
class-attribute
instance-attribute
¶
How to build the objective f(min_cluster_size) before smoothing (mean / lower_bound / weighted).
projection_screener = field(default_factory=ManifoldOovScreenerConfig)
class-attribute
instance-attribute
¶
Validation config for manifold OOV model selection (analysis reporting only).
resolved_min_scale()
¶
Inclusive start of the min_cluster_size grid (HDBSCAN hyperparameter).
DistillationGateConfig
dataclass
¶
Quality bounds on the compact entity head, checked against a held-out slice.
Defaults match the bounds run/analysis/compact_predict_study.py applied by hand
before compact became the shipped default; they live here so a fit can state whether
it met them instead of nobody knowing.
Source code in pelinker/config.py
emit_rate_threshold = 0.3
class-attribute
instance-attribute
¶
Reference thr_score for the emit-rate comparison.
max_emit_rate_rel_delta = 0.1
class-attribute
instance-attribute
¶
Cap on |student - teacher| / teacher emit rate at :attr:emit_rate_threshold.
min_entity_agreement = 0.95
class-attribute
instance-attribute
¶
Floor on held-out student/teacher entity-id agreement.
on_failure = 'warn'
class-attribute
instance-attribute
¶
warn keeps the fitted model (and records the failure); raise aborts.
Warning is the default because a fit consumes an expensive corpus embedding, and discarding it mid-run is worse than shipping a model whose report says it failed.
EmbeddingModelMetadata
dataclass
¶
Describes which embedding backbones/layers produced the model (saved with the Linker).
Source code in pelinker/config.py
EmbeddingSourceSpec
dataclass
¶
One backbone + layer selection (e.g. for a single encoder or one branch of a fused model).
Source code in pelinker/config.py
EmbeddingTrainingConfig
dataclass
¶
Inputs and runtime settings used only while embedding the corpus (not part of model identity).
Source code in pelinker/config.py
encoder_batch_size = 200
class-attribute
instance-attribute
¶
How many table rows are encoded per transformer forward pass; lower if GPU memory is tight.
input_buffer_rows = 1000
class-attribute
instance-attribute
¶
Rows read per pandas.read_csv(..., chunksize=...) pass over the text table (I/O buffer only).
max_input_buffers = None
class-attribute
instance-attribute
¶
If set, stop after this many text-table read passes (each up to input_buffer_rows rows).
negative_label = NEGATIVE_LABEL
class-attribute
instance-attribute
¶
Entity label to use for synthetic negative rows.
negative_seed = 13
class-attribute
instance-attribute
¶
Optional random seed for deterministic negative sampling.
negatives_per_positive = 0.0
class-attribute
instance-attribute
¶
Number of random negative mentions to sample per positive mention.
KBConfig
dataclass
¶
Metadata for the knowledge base packaged with a fitted Linker.
Source code in pelinker/config.py
entity_count = None
class-attribute
instance-attribute
¶
Set after fit from vocabulary size when None at construction time.
LinkerFitConfig
dataclass
¶
Parquet read + mention filters + screener settings for :meth:~pelinker.model.Linker.fit.
Source code in pelinker/config.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 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 | |
base_seed = 13
class-attribute
instance-attribute
¶
Seed for stratified clustering draws; draw seed is base_seed + clustering_sample_index.
clustering_sample_index = 0
class-attribute
instance-attribute
¶
Bootstrap index for the clustering subsample (same contract as model selection sample_idx).
clustering_sample_rows = None
class-attribute
instance-attribute
¶
Max mention rows per clustering bootstrap draw (stratified). None = use all loaded rows.
diagnostics_random_state = 0
class-attribute
instance-attribute
¶
Stratified subsample seed for training diagnostics.
diagnostics_sample_size = 20000
class-attribute
instance-attribute
¶
Max rows of :class:~pelinker.reporting.LinkerFitDiagnostics stored on the fit report.
entity_head_hidden_layers = (256, 128, 128)
class-attribute
instance-attribute
¶
Hidden layer sizes for the compact MLP entity head (ignored in legacy mode).
entity_head_holdout_fraction = 0.15
class-attribute
instance-attribute
¶
Rows withheld from entity-head training to measure distillation fidelity.
0.0 trains on every teacher-labelled row (the pre-fidelity behaviour) and skips
the measurement — use it only to reproduce an existing artifact.
entity_head_holdout_group_col = 'pmid'
class-attribute
instance-attribute
¶
Column kept whole across the holdout split; mentions from one document are correlated, so a row-level split inflates the measured agreement.
predict_mode = 'compact'
class-attribute
instance-attribute
¶
compact: ParametricUMAP + MLP entity head (no shipped HDBSCAN). legacy: UMAP + HDBSCAN approximate_predict.
scale_curve = None
class-attribute
instance-attribute
¶
Fitted min_cluster_size-vs-N law from pelinker-scale-curve.
When set (and no explicit min_cluster_size was given), the hyperparameter is
extrapolated to the realized manifold row count instead of being transferred verbatim
from whatever sample size selection happened to run at. See :mod:pelinker.scaling.
screener_max_rows = 100000
class-attribute
instance-attribute
¶
Max rows for ambient + projection screener training when using the full frame (stratified). None = no cap.
screener_seed = 13
class-attribute
instance-attribute
¶
Random seed for the stratified screener training draw when using the full frame.
to_clustering_sample_config()
¶
Build a :class:ClusteringOptimizationConfig for load + subsample helpers.
Source code in pelinker/config.py
ManifoldOovScreenerConfig
dataclass
¶
3D (residual, Mahalanobis, spectral entropy) OOV score model; predict-time gate only.
Source code in pelinker/config.py
MentionFrameLoadConfig
dataclass
¶
Shared mention-level parquet load and pre-subsample filters.
Source code in pelinker/config.py
drop_rare_entities = False
class-attribute
instance-attribute
¶
When true, drop KB entities with fewer than :attr:min_mentions_per_entity rows.
max_mentions_negative = None
class-attribute
instance-attribute
¶
Cap for :attr:~NegativeScreenerConfig.negative_label; None = exempt.
max_mentions_per_entity = None
class-attribute
instance-attribute
¶
Cap mention rows per KB entity (seeded); None = no cap.
NegativeScreenerConfig
dataclass
¶
Binary LDA/SVM screen for negative_label vs KB mentions before PCA→UMAP.
Source code in pelinker/config.py
kind = 'lda'
class-attribute
instance-attribute
¶
Estimator persisted on :class:~pelinker.model.Linker (Linker.screener).
TransformConfig
dataclass
¶
Configuration for the embedding transformation pipeline.
Source code in pelinker/config.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | |
DEFAULT_UMAP_N_NEIGHBORS = 15
class-attribute
¶
umap-learn's own default; used when :attr:umap_n_neighbors is None.
cluster_viz_components = 3
class-attribute
instance-attribute
¶
Number of dimensions for cluster-space visualization (default: 3).
cluster_viz_method = 'pca'
class-attribute
instance-attribute
¶
Reducer applied to clustering UMAP coords: pca (linear) or umap.
cluster_viz_umap_metric = 'euclidean'
class-attribute
instance-attribute
¶
Distance metric for cluster-space UMAP viz (only when cluster_viz_method='umap').
manifold_kind = 'umap'
class-attribute
instance-attribute
¶
Clustering manifold: parametric (ParametricUMAP) or umap (standard UMAP). Compact fit forces parametric.
parametric_umap_batch_size = None
class-attribute
instance-attribute
¶
ParametricUMAP edge batch size; None uses library default.
parametric_umap_n_training_epochs = 10
class-attribute
instance-attribute
¶
ParametricUMAP training epochs over the UMAP graph (ignored for manifold_kind='umap').
pca_components = 50
class-attribute
instance-attribute
¶
Number of principal components to keep after PCA reduction.
pca_seed = 13
class-attribute
instance-attribute
¶
Random seed for PCA and cluster-viz PCA.
umap_components = 4
class-attribute
instance-attribute
¶
Number of UMAP dimensions for clustering (typically 3-5).
umap_metric = 'cosine'
class-attribute
instance-attribute
¶
Distance metric for UMAP (default: 'cosine').
umap_n_neighbors = None
class-attribute
instance-attribute
¶
UMAP n_neighbors. None keeps the library default (15) for any workable frame.
This is a scale-dependent knob: 15 neighbours describe a very different
neighbourhood at 10k rows than at 2M. Set it explicitly (or sweep it with
pelinker-scale-curve) when the fit N differs markedly from the selection N.
See :meth:resolve_n_neighbors.
umap_seed = None
class-attribute
instance-attribute
¶
UMAP random seed; None enables parallel UMAP (non-reproducible). Cluster-viz UMAP uses umap_seed + 1 when set.
resolve_n_neighbors(n_samples)
¶
n_neighbors for a frame of n_samples rows, clamped to what UMAP accepts.
UMAP requires n_neighbors < n_samples, so tiny frames are capped; this is the
single place that rule lives.