-
Notifications
You must be signed in to change notification settings - Fork 332
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
Migrate string output/input to Turn
objects
#1089
Draft
leondz
wants to merge
41
commits into
NVIDIA:main
Choose a base branch
from
leondz:feature/turn_objects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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.
Resolves #602
summary
garak prompts & outputs are all captured as
str
We can about more modalities than strings - scope encompasses image attachments, files, rich outputs. Though the Language part of LLM is requisite for garak scope to apply.
This PR abstracts the type sent to and received from generators away from
str
toTurn
. EachTurn()
instance corresponds to a turn in a conversation. Simple probes poseTurn()
to their target.Attempt
s manage a message history ofTurn()
items instead of strings.details
Turn
classTurn represents the content part of a query to or response from an LLM.
Turn
s have:text
: corresponds to what was previouslyprompt: str
parts
: a list of data, default []Turn
s should never beNone
. Where we'd useprompt = None
previously, this should be aTurn()
which will havetext==None
.This is only a part of a query sent to a target model.
Turn
s are agnostic to metadata about which role is uttering it. A full LLM query might be composed of multiple turns.Tests should all specifically use the
Turn
object.NB it's now preferred to copy turn text locally instead of manipulating it in place. e.g.
-- unless dealing things that need to edit to object, e.g. buffs
Updates to
Attempt
Attempt is a core place this change affects.
attempt.prompt
is now aTurn
; refer to what wasattempt.prompt
, withattempt.prompt.text
attempt.outputs
is now alist
ofTurn
sattempt.messages
is still a list of lists of dicts, but thecontent
part of the dicts must be aTurn
Attempt
s, where some methods will accept aList
ofstr
.Attempt
internals requires usingTurn
s.Turn
type changes
attempt
will need a changeoutputs
which is now alist
ofTurn
sprompt
which is now aTurn
generators.base.generate()
should take aTurn
and not a stringgenerators.base.generate()
should return a list ofTurn
sgenerate()
returns a list of str, and the magic in Attempt handles the mapping toTurn()
generators.base.generate()
as returning a list of strings OK? Is it sensible to postpone migrating this to a list ofTurn
s? Would appreciate your thoughtsVerification
python -m pytest tests/test_attempt.py