Spaces:
Running
Running
Zekun Wu
commited on
Commit
•
5c1a706
1
Parent(s):
ebe320f
update
Browse files- pages/1_Injection.py +1 -1
- util/injection.py +2 -2
pages/1_Injection.py
CHANGED
@@ -104,7 +104,7 @@ else:
|
|
104 |
|
105 |
with st.spinner('Processing data...'):
|
106 |
parameters = {"temperature": st.session_state.temperature, "max_tokens": st.session_state.max_tokens}
|
107 |
-
preprocessed_df = process_scores_multiple(df, st.session_state.num_run, parameters, st.session_state.privilege_label,st.session_state.protect_label, agent, st.session_state.group_name,st.session_state.occupation,st.session_state.proportion)
|
108 |
st.session_state.data_processed = True # Mark as processed
|
109 |
|
110 |
st.write('Processed Data:', preprocessed_df)
|
|
|
104 |
|
105 |
with st.spinner('Processing data...'):
|
106 |
parameters = {"temperature": st.session_state.temperature, "max_tokens": st.session_state.max_tokens}
|
107 |
+
preprocessed_df = process_scores_multiple(df, st.session_state.num_run, parameters, st.session_state.privilege_label,st.session_state.protect_label, agent, st.session_state.group_name,st.session_state.occupation,st.session_state.proportion,st.session_state.prompt_template)
|
108 |
st.session_state.data_processed = True # Mark as processed
|
109 |
|
110 |
st.write('Processed Data:', preprocessed_df)
|
util/injection.py
CHANGED
@@ -66,7 +66,7 @@ def calculate_avg_score(score_list):
|
|
66 |
avg_score = sum(valid_scores) / len(valid_scores)
|
67 |
return avg_score
|
68 |
return None
|
69 |
-
def process_scores_multiple(df, num_run, parameters, privilege_label, protect_label, agent, group_name, occupation,proportion):
|
70 |
|
71 |
print(f"Processing {len(df)} entries with {num_run} runs each.")
|
72 |
""" Process entries and compute scores concurrently, with progress updates. """
|
@@ -77,7 +77,7 @@ def process_scores_multiple(df, num_run, parameters, privilege_label, protect_la
|
|
77 |
|
78 |
for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, False]):
|
79 |
|
80 |
-
prompt_normal = create_summary(group_name, label, occupation,row,proportion)
|
81 |
|
82 |
print(f"Run {run + 1} - Entry {index + 1} - {key}")
|
83 |
print("=============================================================")
|
|
|
66 |
avg_score = sum(valid_scores) / len(valid_scores)
|
67 |
return avg_score
|
68 |
return None
|
69 |
+
def process_scores_multiple(df, num_run, parameters, privilege_label, protect_label, agent, group_name, occupation,proportion,template):
|
70 |
|
71 |
print(f"Processing {len(df)} entries with {num_run} runs each.")
|
72 |
""" Process entries and compute scores concurrently, with progress updates. """
|
|
|
77 |
|
78 |
for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, False]):
|
79 |
|
80 |
+
prompt_normal = create_summary(group_name, label, occupation,row,proportion,template)
|
81 |
|
82 |
print(f"Run {run + 1} - Entry {index + 1} - {key}")
|
83 |
print("=============================================================")
|