Skip to content

feat: add recalculate_representative_docs() method with configurable count [stacks on #2514]#2516

Draft
pidefrem wants to merge 3 commits into
MaartenGr:masterfrom
pidefrem:pr06-configurable-nr-repr-docs
Draft

feat: add recalculate_representative_docs() method with configurable count [stacks on #2514]#2516
pidefrem wants to merge 3 commits into
MaartenGr:masterfrom
pidefrem:pr06-configurable-nr-repr-docs

Conversation

@pidefrem

@pidefrem pidefrem commented Jul 8, 2026

Copy link
Copy Markdown

What does this PR do?

feat: add recalculate_representative_docs() method with configurable count

_save_representative_docs hardcodes nr_samples=500 and nr_repr_docs=3. Users cannot control how many representative documents are stored per topic.

This is frequently requested: #552, #848, #1767. In #1767, @MaartenGr indicated he prefers a standalone recalculation function (not a constructor parameter). PR #2130 attempted a constructor-only approach but stalled.

Changes:

  1. New public method: recalculate_representative_docs(nr_repr_docs=3, nr_samples=500) — recalculates and replaces representative_docs_ after training. Users can call it with different counts without re-fitting.
  2. Constructor defaults nr_repr_docs (default 3) and nr_repr_docs_nr_samples (default 500) — used during fit_transform().

Backward compatible: defaults reproduce the current behavior exactly.

Fixes #2500

Note: Pairs well with #2496 (dedup fix for _extract_representative_docs) but works standalone.

Before submitting

  • This PR fixes a typo or improves the docs (if yes, ignore all other checks!).
  • Did you read the contributor guideline?
  • Was this discussed/approved via a Github issue? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes (if applicable)?
  • Did you write any new necessary tests?

⚠️ Draft — stacks on #2514. This branch includes the MMR batching commit from #2514 (which itself carries the #2496 fix) as prerequisites (marked [prereq]), so the diff here shows that work too. Once #2514 merges, I'll rebase onto master and the prereq commits drop out, leaving only the recalculate_representative_docs() change. Marking ready for review after #2514 lands.

@pidefrem pidefrem changed the title feat: add recalculate_representative_docs() method with configurable count feat: add recalculate_representative_docs() method with configurable count [stacks on #2514] Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow recalculating representative docs with a configurable count (currently hardcoded to 3)

2 participants