Spaces:
Runtime error
Runtime error
Antoine Chaffin
commited on
Commit
•
013a7fe
1
Parent(s):
e500e35
Back to llama
Browse files- app.py +6 -6
- watermark.py +1 -1
app.py
CHANGED
@@ -13,7 +13,7 @@ hf_token = os.getenv('HF_TOKEN')
|
|
13 |
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
|
14 |
|
15 |
parser = argparse.ArgumentParser(description='Generative Text Watermarking demo')
|
16 |
-
parser.add_argument('--model', '-m', type=str, default="
|
17 |
parser.add_argument('--key', '-k', type=int, default=42,
|
18 |
help='The seed of the pseudo random number generator')
|
19 |
|
@@ -60,11 +60,11 @@ def detect(attacked_text, window_size, method, prompt):
|
|
60 |
return label
|
61 |
|
62 |
def get_prompt(message: str) -> str:
|
63 |
-
|
64 |
-
#
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
with gr.Blocks() as demo:
|
70 |
gr.Markdown("""# LLM generation watermarking
|
|
|
13 |
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
|
14 |
|
15 |
parser = argparse.ArgumentParser(description='Generative Text Watermarking demo')
|
16 |
+
parser.add_argument('--model', '-m', type=str, default="meta-llama/Llama-2-7b-chat-hf", help='Language model')
|
17 |
parser.add_argument('--key', '-k', type=int, default=42,
|
18 |
help='The seed of the pseudo random number generator')
|
19 |
|
|
|
60 |
return label
|
61 |
|
62 |
def get_prompt(message: str) -> str:
|
63 |
+
texts = [f'<s>[INST] <<SYS>>\n{DEFAULT_SYSTEM_PROMPT}\n<</SYS>>\n\n']
|
64 |
+
# The first user input is _not_ stripped
|
65 |
+
texts.append(f'{message} [/INST]')
|
66 |
+
return ''.join(texts)
|
67 |
+
|
68 |
|
69 |
with gr.Blocks() as demo:
|
70 |
gr.Markdown("""# LLM generation watermarking
|
watermark.py
CHANGED
@@ -58,7 +58,7 @@ class WatermarkingAaronsonLogitsProcessor( WatermarkingLogitsProcessor):
|
|
58 |
class WatermarkingKirchenbauerLogitsProcessor(WatermarkingLogitsProcessor):
|
59 |
def __init__(self, *args,
|
60 |
gamma = 0.25,
|
61 |
-
delta =
|
62 |
**kwargs):
|
63 |
super().__init__(*args, **kwargs)
|
64 |
self.gamma = gamma
|
|
|
58 |
class WatermarkingKirchenbauerLogitsProcessor(WatermarkingLogitsProcessor):
|
59 |
def __init__(self, *args,
|
60 |
gamma = 0.25,
|
61 |
+
delta = 15.0,
|
62 |
**kwargs):
|
63 |
super().__init__(*args, **kwargs)
|
64 |
self.gamma = gamma
|