Spaces:
Running
Running
Commit
·
c8c52e3
1
Parent(s):
07f4e87
Improved detection
Browse files- model/analyzer.py +12 -8
model/analyzer.py
CHANGED
@@ -90,7 +90,7 @@ class ContentAnalyzer:
|
|
90 |
prompt = f"""
|
91 |
Check this text for any indication of {mapped_name} ({description}).
|
92 |
Be sensitive to subtle references or implications, make sure the text is not metaphorical.
|
93 |
-
Respond concisely with: YES, NO, or MAYBE.
|
94 |
Text: {chunk}
|
95 |
Answer:
|
96 |
"""
|
@@ -112,17 +112,21 @@ class ContentAnalyzer:
|
|
112 |
)
|
113 |
|
114 |
response_text = self.tokenizer.decode(outputs[0], skip_special_tokens=True).strip().upper()
|
115 |
-
first_word = response_text.split("\n")[-1].split()[0] if response_text else "NO"
|
116 |
-
print(f"Model response for {mapped_name}: {first_word}")
|
117 |
|
118 |
-
|
119 |
-
|
|
|
120 |
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 1
|
121 |
-
elif
|
122 |
-
print(f"Possible {mapped_name} detected, marking for further review.")
|
123 |
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 0.5
|
124 |
else:
|
125 |
-
print(f"No {mapped_name} detected in this chunk.")
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
if progress:
|
128 |
current_progress += progress_step
|
|
|
90 |
prompt = f"""
|
91 |
Check this text for any indication of {mapped_name} ({description}).
|
92 |
Be sensitive to subtle references or implications, make sure the text is not metaphorical.
|
93 |
+
Respond concisely and ONLY with: YES, NO, or MAYBE.
|
94 |
Text: {chunk}
|
95 |
Answer:
|
96 |
"""
|
|
|
112 |
)
|
113 |
|
114 |
response_text = self.tokenizer.decode(outputs[0], skip_special_tokens=True).strip().upper()
|
|
|
|
|
115 |
|
116 |
+
# Scan the entire response for the relevant words
|
117 |
+
if "YES" in response_text:
|
118 |
+
print(f"{' ' * 16}Detected {mapped_name} in this chunk!")
|
119 |
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 1
|
120 |
+
elif "MAYBE" in response_text:
|
121 |
+
print(f"{' ' * 16}Possible {mapped_name} detected, marking for further review.")
|
122 |
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 0.5
|
123 |
else:
|
124 |
+
print(f"{' ' * 16}No {mapped_name} detected in this chunk.")
|
125 |
+
|
126 |
+
if progress:
|
127 |
+
current_progress += progress_step
|
128 |
+
progress(min(current_progress, 0.9), f"{' ' * 16}Analyzing {mapped_name}...")
|
129 |
+
|
130 |
|
131 |
if progress:
|
132 |
current_progress += progress_step
|