Skip to content

Commit 4c56a47

Browse files
committed
Sensitive communities in all languages.
1 parent 8a2b543 commit 4c56a47

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

langbite/ethical_requirement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EthicalRequirement:
1717
tolerance: float
1818
delta: float
1919
concern: str
20-
communities: list[str]
20+
communities = None
2121
inputs: list[str]
2222
reflections: list[str]
2323

@@ -28,6 +28,6 @@ def __init__(self, req):
2828
self.tolerance = req['tolerance']
2929
self.delta = req['delta']
3030
self.concern = req['concern'].lower()
31-
self.communities = langbite.utils.lower_string_list(req['communities'])
31+
self.communities = req['communities']
3232
self.inputs = langbite.utils.lower_string_list(req['inputs'])
3333
self.reflections = langbite.utils.lower_string_list(req['reflections'])

langbite/prompt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def instantiate(self, concern, communities):
113113
markup = MARKUPS[concern]
114114

115115
if len(communities) > 0:
116-
self.__instances = self.__replace_markups(markup, communities)
116+
lang_communities = communities[self.language]
117+
self.__instances = self.__replace_markups(markup, lang_communities)
117118
else:
118119
self.__instances = [self.template]
119120

langbite/test_scenario.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,24 @@ def __select_prompts(self, prompts: list[Prompt]):
104104
result = []
105105
req: EthicalRequirement
106106
for req in self.ethical_requirements:
107-
concern = req.concern
108-
input_types = [input_type for input_type in req.inputs]
109-
reflection_types = [reflection_type for reflection_type in req.reflections]
110-
for input_type in input_types:
111-
for reflection_type in reflection_types:
112-
# filter prompts by concern, prompt type and assessment type
113-
temp = [prompt for prompt in prompts if
107+
for language in req.languages:
108+
concern = req.concern
109+
input_types = [input_type for input_type in req.inputs]
110+
reflection_types = [reflection_type for reflection_type in req.reflections]
111+
for input_type in input_types:
112+
for reflection_type in reflection_types:
113+
# filter prompts by concern, prompt type and assessment type
114+
temp = [prompt for prompt in prompts if
114115
prompt.concern == concern and prompt.input_type == input_type and prompt.reflection_type == reflection_type and
115-
prompt.language in req.languages]
116-
# and then select according to num tests specified
117-
result = result + self.__sample_list(temp)
118-
# 1. assign delta as per requirement
119-
# 2. set whether the req forces sentiment analysis to re-check failed tests
120-
prompt: Prompt
121-
for prompt in result:
122-
prompt.set_oracle_delta(req.delta)
123-
prompt.set_oracle_reinforce_failed_evaluation(self.use_llm_eval)
116+
prompt.language == language]
117+
# and then select according to num tests specified
118+
result = result + self.__sample_list(temp)
119+
# 1. assign delta as per requirement
120+
# 2. set whether the req forces sentiment analysis to re-check failed tests
121+
prompt: Prompt
122+
for prompt in result:
123+
prompt.set_oracle_delta(req.delta)
124+
prompt.set_oracle_reinforce_failed_evaluation(self.use_llm_eval)
124125
self.__prompts = result
125126

126127
def __sample_list(self, prompt_list: list[Prompt]):

0 commit comments

Comments
 (0)