Skip to content

[Question] Clarification on the RIND implementation. #9

@WWWonderer

Description

@WWWonderer

Hello!

Thank you for open sourcing your model! I have some questions regarding the implementation of RIND. From the paper, RIND seems to be the product of [entropy] x [max(attention)] x [boolean(is a stopword)]. However, if I'm not mistaken, your implementation seems to have some additional details in the modifier function of AttnWeightRAG:

# value = attenion * (-log prob)
attns = attentions[tl:tr]
attns = np.array(attns) / sum(attns)
value = [attns[i-tl] * weight[i] * (tr-tl) for i in range(tl, tr)] 
thres = [1 if v > self.hallucination_threshold else 0 for v in value]

Namely you first normalized the attn using attns = np.array(attns) / sum(attns) instead of using raw attention, and you also added the length of the sentence tr-tl into the equation (attns[i-tl] * weight[i] * (tr-tl)). Is this understanding correct? What is the purpose of adding (tr-tl)? Is it used to counter-balance the softmax as longer sentences will tend to have lower values?

There are 2 other points of concern to me:

  1. When a word is composed of multiple tokens, you chose to add the attention of each token. Wouldn't this create unfair advantage to multi-token words especially when using the max solver?

  2. You chose to average the embedding over multiple heads, wouldn't this defeat the purpose of multi-head attention as they supposedly each represent different criterias?

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions