Spaces:
Runtime error
Runtime error
Antoine Chaffin
commited on
Commit
•
a5f5971
1
Parent(s):
e5562c9
Fixing indent
Browse files- watermark.py +10 -10
watermark.py
CHANGED
@@ -82,7 +82,16 @@ class WatermarkingKirchenbauerLogitsProcessor(WatermarkingLogitsProcessor):
|
|
82 |
scores[b] += bias # add bias to greenlist words
|
83 |
|
84 |
return scores
|
|
|
|
|
|
|
|
|
85 |
|
|
|
|
|
|
|
|
|
|
|
86 |
class Watermarker(object):
|
87 |
def __init__(self, tokenizer=None, model=None, window_size = 0, payload_bits = 0, logits_processor = None, *args, **kwargs):
|
88 |
self.tokenizer = tokenizer
|
@@ -140,16 +149,7 @@ class Watermarker(object):
|
|
140 |
|
141 |
return decoded_texts
|
142 |
|
143 |
-
|
144 |
-
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|
145 |
-
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\
|
146 |
-
"""
|
147 |
-
|
148 |
-
def get_prompt(message: str) -> str:
|
149 |
-
texts = [f'<s>[INST] <<SYS>>\n{DEFAULT_SYSTEM_PROMPT}\n<</SYS>>\n\n']
|
150 |
-
# The first user input is _not_ stripped
|
151 |
-
texts.append(f'{message} [/INST]')
|
152 |
-
return ''.join(texts)
|
153 |
|
154 |
|
155 |
def detect(self, attacked_texts, key=42, method='aaronson', gamma=0.5, prompts=None):
|
|
|
82 |
scores[b] += bias # add bias to greenlist words
|
83 |
|
84 |
return scores
|
85 |
+
DEFAULT_SYSTEM_PROMPT = """\
|
86 |
+
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|
87 |
+
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\
|
88 |
+
"""
|
89 |
|
90 |
+
def get_prompt(message: str) -> str:
|
91 |
+
texts = [f'<s>[INST] <<SYS>>\n{DEFAULT_SYSTEM_PROMPT}\n<</SYS>>\n\n']
|
92 |
+
# The first user input is _not_ stripped
|
93 |
+
texts.append(f'{message} [/INST]')
|
94 |
+
return ''.join(texts)
|
95 |
class Watermarker(object):
|
96 |
def __init__(self, tokenizer=None, model=None, window_size = 0, payload_bits = 0, logits_processor = None, *args, **kwargs):
|
97 |
self.tokenizer = tokenizer
|
|
|
149 |
|
150 |
return decoded_texts
|
151 |
|
152 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
|
155 |
def detect(self, attacked_texts, key=42, method='aaronson', gamma=0.5, prompts=None):
|