Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,40 @@ st.title("AI Detectability Index (ADI)")
|
|
| 8 |
# Create a container for the box
|
| 9 |
box = st.container()
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# Create two columns inside the box
|
| 12 |
with box:
|
| 13 |
col1, col2 = st.columns([0.4, 0.6])
|
|
@@ -19,4 +53,4 @@ with box:
|
|
| 19 |
# Add text to the right column (60% area)
|
| 20 |
with col2:
|
| 21 |
st.write("By conducting extensive experiments (detailed in Section 3), our study provides a thorough investigation of the de-watermarking techniques wv1 and wv2, demonstrating that the watermarked texts generated by both methods can be circumvented, albeit with a slight decrease in de-watermarking accuracy observed with wv2. These results further strengthen our contention that text watermarking is fragile and lacks reliability for real-life applications.")
|
| 22 |
-
st.write(
|
|
|
|
| 8 |
# Create a container for the box
|
| 9 |
box = st.container()
|
| 10 |
|
| 11 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList
|
| 12 |
+
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained("StabilityAI/stablelm-tuned-alpha-7b")
|
| 14 |
+
model = AutoModelForCausalLM.from_pretrained("StabilityAI/stablelm-tuned-alpha-7b")
|
| 15 |
+
model.half().cuda()
|
| 16 |
+
|
| 17 |
+
class StopOnTokens(StoppingCriteria):
|
| 18 |
+
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
| 19 |
+
stop_ids = [50278, 50279, 50277, 1, 0]
|
| 20 |
+
for stop_id in stop_ids:
|
| 21 |
+
if input_ids[0][-1] == stop_id:
|
| 22 |
+
return True
|
| 23 |
+
return False
|
| 24 |
+
|
| 25 |
+
system_prompt = """<|SYSTEM|># StableLM Tuned (Alpha version)
|
| 26 |
+
- StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
|
| 27 |
+
- StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
|
| 28 |
+
- StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
|
| 29 |
+
- StableLM will refuse to participate in anything that could harm a human.
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
prompt = f"{system_prompt}<|USER|>What's your mood today?<|ASSISTANT|>"
|
| 33 |
+
|
| 34 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 35 |
+
tokens = model.generate(
|
| 36 |
+
**inputs,
|
| 37 |
+
max_new_tokens=64,
|
| 38 |
+
temperature=0.7,
|
| 39 |
+
do_sample=True,
|
| 40 |
+
stopping_criteria=StoppingCriteriaList([StopOnTokens()])
|
| 41 |
+
)
|
| 42 |
+
#print(tokenizer.decode(tokens[0], skip_special_tokens=True))
|
| 43 |
+
|
| 44 |
+
|
| 45 |
# Create two columns inside the box
|
| 46 |
with box:
|
| 47 |
col1, col2 = st.columns([0.4, 0.6])
|
|
|
|
| 53 |
# Add text to the right column (60% area)
|
| 54 |
with col2:
|
| 55 |
st.write("By conducting extensive experiments (detailed in Section 3), our study provides a thorough investigation of the de-watermarking techniques wv1 and wv2, demonstrating that the watermarked texts generated by both methods can be circumvented, albeit with a slight decrease in de-watermarking accuracy observed with wv2. These results further strengthen our contention that text watermarking is fragile and lacks reliability for real-life applications.")
|
| 56 |
+
st.write(tokenizer.decode(tokens[0], skip_special_tokens=True))
|