Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -454,7 +454,7 @@ def detect_semantic_inversions(logprobs, tokens):
|
|
454 |
return "No semantic inversions detected.", None
|
455 |
return "Semantic inversions detected:", inversions
|
456 |
|
457 |
-
# Function to perform full trace analysis
|
458 |
def analyze_full_trace(json_input):
|
459 |
try:
|
460 |
data = parse_input(json_input)
|
@@ -480,24 +480,25 @@ def analyze_full_trace(json_input):
|
|
480 |
|
481 |
confidence_result, confidence_data = analyze_confidence_signature(logprobs, tokens)
|
482 |
pivot_result, pivot_data = detect_interpretation_pivots(logprobs, tokens)
|
483 |
-
entropy_result, entropy_data = calculate_decision_entropy(logprobs)
|
484 |
conclusion_result, conclusion_data = analyze_conclusion_competition(logprobs, tokens)
|
485 |
verification_result, verification_data = analyze_verification_signals(logprobs, tokens)
|
486 |
inversion_result, inversion_data = detect_semantic_inversions(logprobs, tokens)
|
487 |
|
|
|
488 |
analysis_html = f"""
|
489 |
<h3>Trace Analysis Results</h3>
|
490 |
<ul>
|
491 |
<li><strong>Confidence Signature:</strong> {confidence_result}</li>
|
492 |
-
{f"<ul><li>
|
493 |
<li><strong>Interpretation Pivots:</strong> {pivot_result}</li>
|
494 |
-
{f"<ul><li>
|
495 |
<li><strong>Decision Entropy Spikes:</strong> {entropy_result}</li>
|
496 |
-
{f"<ul><li>
|
497 |
<li><strong>Conclusion Competition:</strong> {conclusion_result}</li>
|
498 |
<li><strong>Verification Signals:</strong> {verification_result}</li>
|
499 |
<li><strong>Semantic Inversions:</strong> {inversion_result}</li>
|
500 |
-
{f"<ul><li>
|
501 |
</ul>
|
502 |
"""
|
503 |
return analysis_html, None, None, None, None, None
|
|
|
454 |
return "No semantic inversions detected.", None
|
455 |
return "Semantic inversions detected:", inversions
|
456 |
|
457 |
+
# Function to perform full trace analysis (FIXED)
|
458 |
def analyze_full_trace(json_input):
|
459 |
try:
|
460 |
data = parse_input(json_input)
|
|
|
480 |
|
481 |
confidence_result, confidence_data = analyze_confidence_signature(logprobs, tokens)
|
482 |
pivot_result, pivot_data = detect_interpretation_pivots(logprobs, tokens)
|
483 |
+
entropy_result, entropy_data = calculate_decision_entropy(logprobs, tokens) # Pass tokens explicitly
|
484 |
conclusion_result, conclusion_data = analyze_conclusion_competition(logprobs, tokens)
|
485 |
verification_result, verification_data = analyze_verification_signals(logprobs, tokens)
|
486 |
inversion_result, inversion_data = detect_semantic_inversions(logprobs, tokens)
|
487 |
|
488 |
+
# Updated HTML formatting to correctly unpack tuples and display all data
|
489 |
analysis_html = f"""
|
490 |
<h3>Trace Analysis Results</h3>
|
491 |
<ul>
|
492 |
<li><strong>Confidence Signature:</strong> {confidence_result}</li>
|
493 |
+
{f"<ul><li>Details: {', '.join(f'Position: {pos}, Drop: {drop:.4f}, Token: {tok}' for pos, drop, tok in confidence_data)}</li></ul>" if confidence_data else ""}
|
494 |
<li><strong>Interpretation Pivots:</strong> {pivot_result}</li>
|
495 |
+
{f"<ul><li>Details: {', '.join(f'Position: {pos}, Reconsideration: {rt}, Context: {\" \".join(context)}' for pos, rt, context in pivot_data)}</li></ul>" if pivot_data else ""}
|
496 |
<li><strong>Decision Entropy Spikes:</strong> {entropy_result}</li>
|
497 |
+
{f"<ul><li>Details: {', '.join(f'Position: {idx}, Entropy: {entropy:.4f}, Token: {tok}' for idx, entropy, tok in entropy_data)}</li></ul>" if entropy_data else ""}
|
498 |
<li><strong>Conclusion Competition:</strong> {conclusion_result}</li>
|
499 |
<li><strong>Verification Signals:</strong> {verification_result}</li>
|
500 |
<li><strong>Semantic Inversions:</strong> {inversion_result}</li>
|
501 |
+
{f"<ul><li>Details: {', '.join(f'Position: {pos}, Positive: {pos_word}, Negative: {neg_word}, Probability: {prob:.4f}' for pos, pos_word, neg_word, prob in inversion_data)}</li></ul>" if inversion_data else ""}
|
502 |
</ul>
|
503 |
"""
|
504 |
return analysis_html, None, None, None, None, None
|