Spaces:
Runtime error
Runtime error
eljanmahammadli
commited on
Commit
•
da88846
1
Parent(s):
43d4e83
fix reference new line
Browse files- Abstract.pdf +0 -0
- app.py +3 -3
- locustfile.py +126 -0
- stress_test.py +60 -0
Abstract.pdf
ADDED
Binary file (17.8 kB). View file
|
|
app.py
CHANGED
@@ -101,7 +101,7 @@ def split_text_from_refs(text: str, sep="\n"):
|
|
101 |
for i, ref in enumerate(references, 1):
|
102 |
ref = remove_bracketed_numbers(ref)
|
103 |
formatted_refs.append(f"[{i}] {ref}{sep}")
|
104 |
-
formatted_refs = f"{sep}{sep}References:{sep}" + f"{sep}".join(formatted_refs)
|
105 |
else:
|
106 |
formatted_refs = ""
|
107 |
|
@@ -240,9 +240,9 @@ def ai_generated_test_gptzero(text):
|
|
240 |
|
241 |
|
242 |
def highlighter_polygraf(text, model="Polygraf AI (Base Model)"):
|
243 |
-
body, references = split_text_from_refs(text
|
244 |
score, text = detection_polygraf(text=body, model=model)
|
245 |
-
text = text + references
|
246 |
return score, text
|
247 |
|
248 |
|
|
|
101 |
for i, ref in enumerate(references, 1):
|
102 |
ref = remove_bracketed_numbers(ref)
|
103 |
formatted_refs.append(f"[{i}] {ref}{sep}")
|
104 |
+
formatted_refs = f"{sep}{sep}References:{sep}{sep}" + f"{sep}".join(formatted_refs)
|
105 |
else:
|
106 |
formatted_refs = ""
|
107 |
|
|
|
240 |
|
241 |
|
242 |
def highlighter_polygraf(text, model="Polygraf AI (Base Model)"):
|
243 |
+
body, references = split_text_from_refs(text)
|
244 |
score, text = detection_polygraf(text=body, model=model)
|
245 |
+
text = text + references.replace("\n", "<br>")
|
246 |
return score, text
|
247 |
|
248 |
|
locustfile.py
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from locust import HttpUser, task, between
|
2 |
+
from gradio_client import Client, handle_file
|
3 |
+
|
4 |
+
|
5 |
+
class GradioAppUser(HttpUser):
|
6 |
+
wait_time = between(1, 3)
|
7 |
+
|
8 |
+
def on_start(self):
|
9 |
+
self.client = Client("http://sd.demo.polygraf.ai:7890/")
|
10 |
+
|
11 |
+
@task
|
12 |
+
def test_generate_text_with_google_search_and_pdf(self):
|
13 |
+
generated_text = self.client.predict(
|
14 |
+
input_role="Student",
|
15 |
+
topic="Low Resource Large Language Models",
|
16 |
+
keywords="",
|
17 |
+
article_length=350,
|
18 |
+
format="Article",
|
19 |
+
writing_style="Formal",
|
20 |
+
tone="Professional",
|
21 |
+
user_category="General Public",
|
22 |
+
depth_of_content="Moderate analysis",
|
23 |
+
structure="Introduction, Body, Conclusion",
|
24 |
+
references="News outlets",
|
25 |
+
num_examples="1-2",
|
26 |
+
conclusion_type="Call to Action",
|
27 |
+
# ai_model="LLaMA 3",
|
28 |
+
ai_model="OpenAI GPT 4o Mini",
|
29 |
+
google_search_check=False,
|
30 |
+
year_from="2000",
|
31 |
+
month_from="January",
|
32 |
+
day_from="01",
|
33 |
+
year_to="2024",
|
34 |
+
month_to="August",
|
35 |
+
day_to="08",
|
36 |
+
domains_to_include=["com", "org", "net", "int", "edu", "gov", "mil"],
|
37 |
+
include_sites="",
|
38 |
+
exclude_sites="",
|
39 |
+
pdf_file_input=None,
|
40 |
+
api_name="/generate_and_format",
|
41 |
+
)
|
42 |
+
|
43 |
+
self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
|
44 |
+
detect_generated = self.client.predict(
|
45 |
+
text=generated_text,
|
46 |
+
option="Polygraf AI (Advanced Model)",
|
47 |
+
api_name="/ai_check",
|
48 |
+
)
|
49 |
+
|
50 |
+
humanized_text = self.client.predict(
|
51 |
+
text=generated_text,
|
52 |
+
model="XL Model",
|
53 |
+
temperature=1.2,
|
54 |
+
repetition_penalty=1,
|
55 |
+
top_k=50,
|
56 |
+
length_penalty=1,
|
57 |
+
api_name="/humanize",
|
58 |
+
)
|
59 |
+
|
60 |
+
self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
|
61 |
+
detect_humanized = self.client.predict(
|
62 |
+
text=humanized_text,
|
63 |
+
option="Polygraf AI (Advanced Model)",
|
64 |
+
api_name="/ai_check",
|
65 |
+
)
|
66 |
+
|
67 |
+
print(detect_generated)
|
68 |
+
print(detect_humanized)
|
69 |
+
|
70 |
+
@task
|
71 |
+
def test_generate_text_without_google_search_and_pdf(self):
|
72 |
+
generated_text = self.client.predict(
|
73 |
+
input_role="Student",
|
74 |
+
topic="Low Resource Large Language Models",
|
75 |
+
keywords="",
|
76 |
+
article_length=400,
|
77 |
+
format="Article",
|
78 |
+
writing_style="Formal",
|
79 |
+
tone="Professional",
|
80 |
+
user_category="General Public",
|
81 |
+
depth_of_content="Moderate analysis",
|
82 |
+
structure="Introduction, Body, Conclusion",
|
83 |
+
references="News outlets",
|
84 |
+
num_examples="1-2",
|
85 |
+
conclusion_type="Call to Action",
|
86 |
+
ai_model="LLaMA 3",
|
87 |
+
google_search_check=False,
|
88 |
+
year_from="2000",
|
89 |
+
month_from="January",
|
90 |
+
day_from="01",
|
91 |
+
year_to="2024",
|
92 |
+
month_to="August",
|
93 |
+
day_to="08",
|
94 |
+
domains_to_include=["com", "org", "net", "int", "edu", "gov", "mil"],
|
95 |
+
include_sites="",
|
96 |
+
exclude_sites="",
|
97 |
+
pdf_file_input=[handle_file("/home/eljan/article_writer/Abstract.pdf")],
|
98 |
+
api_name="/generate_and_format",
|
99 |
+
)
|
100 |
+
|
101 |
+
self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
|
102 |
+
detect_generated = self.client.predict(
|
103 |
+
text=generated_text,
|
104 |
+
option="Polygraf AI (Advanced Model)",
|
105 |
+
api_name="/ai_check",
|
106 |
+
)
|
107 |
+
|
108 |
+
humanized_text = self.client.predict(
|
109 |
+
text=generated_text,
|
110 |
+
model="XL Model",
|
111 |
+
temperature=1.2,
|
112 |
+
repetition_penalty=1,
|
113 |
+
top_k=50,
|
114 |
+
length_penalty=1,
|
115 |
+
api_name="/humanize",
|
116 |
+
)
|
117 |
+
|
118 |
+
self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
|
119 |
+
detect_humanized = self.client.predict(
|
120 |
+
text=humanized_text,
|
121 |
+
option="Polygraf AI (Advanced Model)",
|
122 |
+
api_name="/ai_check",
|
123 |
+
)
|
124 |
+
|
125 |
+
print(detect_generated[0]["confidences"])
|
126 |
+
print(detect_humanized[0]["confidences"])
|
stress_test.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gradio_client import Client, file, handle_file
|
2 |
+
|
3 |
+
client = Client("http://sd.demo.polygraf.ai:7890/")
|
4 |
+
|
5 |
+
generated_text = client.predict(
|
6 |
+
input_role="Student",
|
7 |
+
topic="Low Resource Language Models",
|
8 |
+
keywords="",
|
9 |
+
article_length=400,
|
10 |
+
format="Article",
|
11 |
+
writing_style="Formal",
|
12 |
+
tone="Professional",
|
13 |
+
user_category="General Public",
|
14 |
+
depth_of_content="Moderate analysis",
|
15 |
+
structure="Introduction, Body, Conclusion",
|
16 |
+
references="News outlets",
|
17 |
+
num_examples="1-2",
|
18 |
+
conclusion_type="Call to Action",
|
19 |
+
# ai_model="OpenAI GPT 4o Mini",
|
20 |
+
ai_model="LLaMA 3",
|
21 |
+
google_search_check=True,
|
22 |
+
year_from="2000",
|
23 |
+
month_from="January",
|
24 |
+
day_from="01",
|
25 |
+
year_to="2024",
|
26 |
+
month_to="August",
|
27 |
+
day_to="08",
|
28 |
+
domains_to_include=["com", "org", "net", "int", "edu", "gov", "mil"],
|
29 |
+
include_sites="",
|
30 |
+
exclude_sites="",
|
31 |
+
pdf_file_input=[handle_file("/home/eljan/article_writer/Abstract.pdf")],
|
32 |
+
api_name="/generate_and_format",
|
33 |
+
)
|
34 |
+
|
35 |
+
client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
|
36 |
+
detect_generated = client.predict(
|
37 |
+
text=generated_text,
|
38 |
+
option="Polygraf AI (Advanced Model)",
|
39 |
+
api_name="/ai_check",
|
40 |
+
)
|
41 |
+
|
42 |
+
humanized_text = client.predict(
|
43 |
+
text=generated_text,
|
44 |
+
model="XL Model",
|
45 |
+
temperature=1.2,
|
46 |
+
repetition_penalty=1,
|
47 |
+
top_k=50,
|
48 |
+
length_penalty=1,
|
49 |
+
api_name="/humanize",
|
50 |
+
)
|
51 |
+
|
52 |
+
client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
|
53 |
+
detect_humanized = client.predict(
|
54 |
+
text=humanized_text,
|
55 |
+
option="Polygraf AI (Advanced Model)",
|
56 |
+
api_name="/ai_check",
|
57 |
+
)
|
58 |
+
|
59 |
+
print(detect_generated)
|
60 |
+
print(detect_humanized)
|