-
Notifications
You must be signed in to change notification settings - Fork 360
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
base: main
Are you sure you want to change the base?
Changes from all commits
fa193b0
f6587fe
e4edeb6
9f86eca
e0aa817
c4a0e00
31f5393
08fd05f
ae77d0f
d4ecf95
6f429cf
895eaa4
84a9754
e0fda46
25b8172
887c18d
5c4cc11
d519ff1
3b65324
512780d
57ad823
1e1f147
3db4bc4
47d912f
6147759
8fa359c
0370260
1c455d1
6a6ad47
d7b2e71
4c11faf
8087442
23dc5eb
3b257a9
8b0c557
8152951
98486b3
e5f6513
3aab2f4
0005245
7c350da
0ae2b81
6a3d66a
ab9e01c
5d7b697
98e50db
41aa3a0
7c7b853
10ae255
e897b8a
fef9632
814bc92
9bcbc06
41484bc
51b6e6c
2130384
f4a644b
49a9b17
957c1ec
c154a5c
c5691ce
24a6852
a69bf8c
6c54bed
6ee1d92
38448e3
e8f988d
4d75baa
e3a966b
5b60ed7
38324a5
1372191
3610cf6
dba5a20
6316d27
9a30123
6d85cf6
911c16a
af4b409
3ea5834
ff1331d
1e84ad9
e49e49f
3ec028b
e86cf32
3569f39
2779129
061dbcc
393a22e
45609b2
916e962
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,23 +36,25 @@ def transform( | |
self, attempt: garak.attempt.Attempt | ||
) -> Iterable[garak.attempt.Attempt]: | ||
translator = Translator(self.api_key) | ||
prompt = attempt.prompt | ||
attempt.notes["original_prompt"] = prompt | ||
prompt_text = attempt.prompt.text | ||
attempt.notes["original_prompt_text"] = prompt_text | ||
for language in LOW_RESOURCE_LANGUAGES: | ||
attempt.notes["LRL_buff_dest_lang"] = language | ||
response = translator.translate_text(prompt, target_lang=language) | ||
response = translator.translate_text(prompt_text, target_lang=language) | ||
translated_prompt = response.text | ||
attempt.prompt = translated_prompt | ||
yield self._derive_new_attempt(attempt) | ||
|
||
def untransform(self, attempt: garak.attempt.Attempt) -> garak.attempt.Attempt: | ||
translator = Translator(self.api_key) | ||
outputs = attempt.outputs | ||
attempt.notes["original_responses"] = outputs | ||
attempt.notes["original_responses"] = [ | ||
turn.text for turn in outputs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels unintuitive to me -- we're, presumably, annotating the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PLEASE SEND DIAGRAM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an interesting case, I like it. Reasoning:
|
||
] # serialise-friendly | ||
translated_outputs = list() | ||
for output in outputs: | ||
response = translator.translate_text(output, target_lang="EN-US") | ||
response = translator.translate_text(output.text, target_lang="EN-US") | ||
translated_output = response.text | ||
translated_outputs.append(translated_output) | ||
translated_outputs.append(garak.attempt.Turn(translated_output)) | ||
attempt.outputs = translated_outputs | ||
return attempt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I have a system prompt, a user message, and an assistant response, is that one turn or three turns?
This is not super clear to me from the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turn
covers messagecontent
(cf. OpenAI chat API spec). Because of this, the example is three turns - one for the sysprompt, one for the user message, one for the response.