Skip to content

Conversation

AllenFang
Copy link
Contributor

Goal:

  • make good use of the sorter method signature of BM25
  • refactor the BM25 method to solve the problem if sorter param assign, it's very difficult to map the result to original data.
    • Clearly define the input and output type of BM25 method
  • now the sorter can not only sort by score but also anything in the docs

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 27, 2025
Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jun 27, 2025 9:26am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Jun 27, 2025 9:26am

@dosubot dosubot bot added the auto:improvement Medium size change to existing code to handle new use-cases label Jun 27, 2025
@AllenFang AllenFang force-pushed the chore/use-default-bm25-sorter branch from 6af9ed3 to 559f7c0 Compare June 27, 2025 09:02
@AllenFang AllenFang force-pushed the chore/use-default-bm25-sorter branch from 559f7c0 to 2521fdd Compare June 27, 2025 09:03

export interface BMInputDocument<T> {
/** The text from the original document */
text: string;
Copy link
Contributor Author

@AllenFang AllenFang Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if team prefer to use a method to extract the text rather than adding another text field BMInputDocument:

ex:

export interface BMInputDocument<T> {
  extractText: (docs: T) => string;
  /** The original document */
  docs: T;
}

@christian-bromann
Copy link
Member

@AllenFang thanks for the PR 🙏 do you think we can add some unit tests to verify the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases needs-response size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants