File size: 1,086 Bytes
79dcf63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def compute_metrics(attributes):
    # Extract relevant information from attributes
    all_relevant_sentence_keys = attributes.get("all_relevant_sentence_keys", [])
    all_utilized_sentence_keys = attributes.get("all_utilized_sentence_keys", [])
    sentence_support_information = attributes.get("sentence_support_information", [])
    
    # Compute Context Relevance
    context_relevance = len(all_relevant_sentence_keys) / len(sentence_support_information) if sentence_support_information else 0
    
    # Compute Context Utilization
    context_utilization = len(all_utilized_sentence_keys) / len(sentence_support_information) if sentence_support_information else 0
    
    # Compute Completeness
    completeness = all(info.get("fully_supported", False) for info in sentence_support_information)
    
    # Compute Adherence
    adherence = attributes.get("overall_supported", False)
    
    return {
        "Context Relevance": context_relevance,
        "Context Utilization": context_utilization,
        "Completeness": completeness,
        "Adherence": adherence
    }