Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number your segments in docs and prompt LLM to output numbers of relevant segments instead of actual relevant text to increase speed and reduce cost and increase extraction quality #9

Open
shreyas-shinde opened this issue Feb 5, 2025 · 4 comments

Comments

@shreyas-shinde
Copy link
Author

FYI: I have actually tried the numbered approach and have seen cost, latency go down because of output token reduction and also found that the eval score of downstream task (QA in my case) went up.

@homanp
Copy link
Collaborator

homanp commented Feb 5, 2025

@shreyas-shinde feel free to contribute!

@homanp
Copy link
Collaborator

homanp commented Feb 7, 2025

@shreyas-shinde
So is the process to:

  1. Have the LLM Segment the docs
  2. Have the LLM extract relevant segments

@shreyas-shinde
Copy link
Author

@homanp

  1. Segment the docs -> not done by LLM simply some python code. A reference algo can be https://github.com/langroid/langroid/blob/main/langroid/parsing/utils.py#L135 . Maybe we can give an option to user if they want to use LLM for this.
  2. LLM extracts relevant segment numbers given the context (this could be split across multiple parallel LLMs given the context length) ref prompt https://github.com/langroid/langroid/blob/main/langroid/agent/special/relevance_extractor_agent.py#L75
  3. Get the segment text based on the numbers in 2 by simple regex ref: https://github.com/langroid/langroid/blob/main/langroid/parsing/utils.py#L296

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

No branches or pull requests

2 participants