Experiment with fact shards to reduce token usage#2919
Draft
whabanks wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
This PR experiments with "fact shards" in an attempt to reduce token usage for the
api-endpoint-builderagent. Patterns and code examples were pulled out of the base agent file and placed into individual fact shard files that are then referenced by that agent.md file.Since the entire agent.md file is loaded into context with each new chat, a small amount of conditional loading was put in place to help guide the agent when it decides what shards to pull into context when responding to a prompt.
A full breakdown with 4 test cases can be read here: https://github.com/cds-snc/notification-api/wiki/Fact-shards-experiment-results. In short:
✅ When a prompt maps well to documented patterns / fact shards token usage seems to be significantly reduced
⚠️ When constraints are placed on exploration depth token usage is decreased - unclear how output quality is affected by exploration constraints
🔴 When the AI loads fact shards + has to perform it's own exploration of the codebase for patterns - token usage is negatively impacted
Related Issues | Cartes liées
Test instructions | Instructions pour tester la modification
TODO: Fill in test instructions for the reviewer.
Release Instructions | Instructions pour le déploiement
None.
Reviewer checklist | Liste de vérification du réviseur