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: DIA-1402: V1-Submit Prompt auto-refinement job #214

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

matt-bernstein
Copy link
Contributor

@matt-bernstein matt-bernstein commented Sep 23, 2024

Add a prompt improvement skill and an endpoint to call it through the server

TODO
[x] validation
[x] test coverage
[x] clean up our data models - started in this new codepath, can extend to existing codepaths later

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 56.09756% with 36 lines in your changes missing coverage. Please review.

Project coverage is 66.94%. Comparing base (abffd45) to head (330d036).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
adala/agents/base.py 31.57% 13 Missing ⚠️
server/app.py 55.55% 12 Missing ⚠️
adala/skills/collection/prompt_improvement.py 69.44% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #214      +/-   ##
==========================================
- Coverage   67.09%   66.94%   -0.15%     
==========================================
  Files          44       45       +1     
  Lines        2103     2272     +169     
==========================================
+ Hits         1411     1521     +110     
- Misses        692      751      +59     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robot-ci-heartex robot-ci-heartex temporarily deployed to fb-dia-1402 September 23, 2024 21:22 Destroyed
@robot-ci-heartex
Copy link
Collaborator

Copy link
Contributor

@pakelley pakelley left a comment

Choose a reason for hiding this comment

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

overall lgtm

server/prompt_improvement_skill.py Outdated Show resolved Hide resolved
@robot-ci-heartex robot-ci-heartex marked this pull request as draft September 24, 2024 09:05
@robot-ci-heartex
Copy link
Collaborator

prompt_improvement_skill = TextGenerationSkill(
name="prompt_improvement",
instructions="Improve the user prompt for the provided LLM model to complete the task using the provided input variables, with the provided user prompt as a starting point. Variables can be accessed in the user prompt using the format {variable_name} (only the variable values are used, not their names). Make sure your prompt produces output that will continue to conform to the provided json schema. Provide your reasoning for the changes you made to the prompt.",
input_template='''
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move it to a separarate file, so we could keep refining it easily.
A couple of a prompt eng best practices that we could incorporate right away:

  • split each variable in a well defined block, for example: Model: {model} --> ## Model\n{model}\n\n
  • add fewshot examples
  • add # Instructions: or # Follow the steps: section with a numbered list of instructions
  • add # Things to avoid: section where we patch the mistakes

prompt engineering for refinement is out of the scope for sure, but moving input_template in a separate file and leaving instructions empty would allow us to easily iterate on that in the future updates

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to keep all the deps for the PromptImprovementSkill together, not sure putting just the input template in a separate file would be any cleaner.

But one thing I want to get your opinion on re prompt engineering is the trick of factoring out all the prompt contents that don't contain variables into the system prompt, and leaving the variables in the user prompt. This way we can easily use prompt caching on the system prompt, and it would also change the performance in some way - not sure if positive or negative, but I suspect positive, and I wanted to trial it here first, and if it works here bring it to LSE. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the prompt. Keeping as separate system and user prompts for now, lmk if you have a strong opinion about that

server/app.py Outdated Show resolved Hide resolved
@robot-ci-heartex robot-ci-heartex temporarily deployed to fb-dia-1402 October 1, 2024 14:49 Destroyed
@robot-ci-heartex
Copy link
Collaborator

@robot-ci-heartex robot-ci-heartex temporarily deployed to fb-dia-1402 October 1, 2024 14:57 Destroyed
@robot-ci-heartex
Copy link
Collaborator

@matt-bernstein matt-bernstein marked this pull request as ready for review October 1, 2024 15:17
@robot-ci-heartex robot-ci-heartex temporarily deployed to fb-dia-1402 October 1, 2024 15:19 Destroyed
@robot-ci-heartex
Copy link
Collaborator

@robot-ci-heartex robot-ci-heartex marked this pull request as draft October 2, 2024 01:32
@robot-ci-heartex
Copy link
Collaborator

@robot-ci-heartex
Copy link
Collaborator

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.

5 participants