simonw / simonw/llm

Add an option to use Maximal Marginal Relevance (MMR) for diversified search

Open
#344 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
12.5k
Forks
998
Avg merge
3d 13h
Merged PRs (30d)
10

Description

It can be useful to diversify search results. For example, when querying my pelican database for pelicans similar to Beaker, using pure cosine similarity I may end up with 10 pelicans that have similar hobbies (beak painting, beak basketball). I may want to mix this up and include pelicans that are similar on other axes like favorite foods (Tuna Tacos, Crabby Caviar, ...).

One algorithm to do this is Maximal Marginal Relevance (MMR) - this is pretty fast in numpy which is already being used.

Example implementation:

https://github.com/monarch-initiative/curate-gpt/blob/6e4a910fd0bce3620117525b0053d0e006f3b61e/src/curate_gpt/utils/vector_algorithms.py#L63-L134

Happy to make a PR lifting this implementation if in scope

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files, tests, or entry points, so first locate the search implementation and its option handling. Review the linked Python MMR implementation and determine how an opt-in mode should diversify results; done means users can request diversified search results without changing the existing default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
cli, search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.