def _is_useful_score(
    pred_tokens: List[int], pred_log_probs_dict: List[Dict[str, float]]
) -> float:
    """
    Compute usefulness score.

    Args:
        pred_tokens (List[int]): List of predicted tokens
        pred_log_probs_dict (List[Dict[str, float]]): log probabilities of tokens for each predicted tokens

    Returns:
        float: relevance score

    """
    isUse_score = 0
    utility_token_appear_id = -1
    for tok_idx, tok in enumerate(pred_tokens):
        if tok in _UTILITY_TOKENS:
            utility_token_appear_id = tok_idx
    if utility_token_appear_id > -1:
        ut_score_dict = {}
        for token in _UTILITY_TOKENS:
            prob = pred_log_probs_dict[utility_token_appear_id][token]
            ut_score_dict[token] = np.exp(float(prob))

        ut_sum = np.sum(list(ut_score_dict.values()))
        ut_weights = [-1, -0.5, 0, 0.5, 1]
        isUse_score = np.sum(
            [
                ut_weights[i] * (ut_score_dict[f"[Utility:{i + 1}]"] / ut_sum)
                for i in range(len(ut_weights))
            ]
        )
    return isUse_score

    Compute usefulness score.

    Args:
        pred_tokens (List[int]): List of predicted tokens
        pred_log_probs_dict (List[Dict[str, float]]): log probabilities of tokens for each predicted tokens

    Returns:
        float: relevance score

    
llama-index-packs/llama-index-packs-self-rag/llama_index/packs/self_rag/base.py