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

feat: support prompt caching and apply Anthropic's long-context prompt format #52

Merged
merged 12 commits into from
Dec 3, 2024

Conversation

undo76
Copy link
Contributor

@undo76 undo76 commented Nov 25, 2024

Several improvements:

  • We return the document id in the context to make it available to the model. chunk_id and document_id not accessible #50
  • Better reconstruction of segments considering headings hierarchy
  • Fix order of segments. We use the sum of the reciprocal ranks of the chunks by default, while allowing passing a scoring function.
  • Now we write the context in the user prompt, but we can configure to pass it in the system prompt or in a separate system prompt. Order of the system message may prevent caching #49

@undo76 undo76 requested a review from lsorber November 25, 2024 16:30
@undo76 undo76 marked this pull request as draft November 25, 2024 17:32
@undo76 undo76 force-pushed the feat/ms-document-ids branch from 65b8927 to 535172d Compare November 25, 2024 20:53
@undo76 undo76 marked this pull request as ready for review November 25, 2024 22:20
Copy link
Member

@lsorber lsorber left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. It's a fairly big one so I have some more comments than the previous one 😅.

src/raglite/_database.py Outdated Show resolved Hide resolved
src/raglite/_database.py Outdated Show resolved Hide resolved
src/raglite/_database.py Outdated Show resolved Hide resolved
src/raglite/_database.py Outdated Show resolved Hide resolved
src/raglite/_database.py Outdated Show resolved Hide resolved
src/raglite/_rag.py Outdated Show resolved Hide resolved
src/raglite/_rag.py Outdated Show resolved Hide resolved
@undo76 undo76 requested a review from lsorber November 26, 2024 19:14
@lsorber lsorber force-pushed the feat/ms-document-ids branch from a27ab99 to bbde96f Compare December 3, 2024 11:14
src/raglite/_database.py Outdated Show resolved Hide resolved
src/raglite/_database.py Outdated Show resolved Hide resolved
@lsorber lsorber force-pushed the feat/ms-document-ids branch from 42e4b51 to 60a7292 Compare December 3, 2024 11:54
src/raglite/_chainlit.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@undo76 undo76 left a comment

Choose a reason for hiding this comment

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

Great changes, I think it is a big improvement. Thanks!

@lsorber lsorber changed the title feat: Add document id and chunk ids to segments fixing order. feat: support prompt caching and apply Anthropic's long-context prompt format Dec 3, 2024
@lsorber lsorber merged commit 0a08bf5 into main Dec 3, 2024
2 checks passed
@lsorber lsorber deleted the feat/ms-document-ids branch December 3, 2024 18:24
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.

2 participants