WorksComputer Science
A Conditional Mutual Information Analysis of Response Variety in Language Models
Abstract
Large language models provide a variety of responses at inference (generation) that conventionally depend on a temperature parameter. Using a conditional mutual information approach, a quantitative, entropy based analysis of response variety is given. Three limiting behaviors are defined: arbiter, independent (conditionally) and neutral (deterministic) that span no to maximal mutual information. We give examples of each behavior and suggest their application to: temperature analysis, language analysis, prompt compression, and knowledge graphs.
Introduction
Large language models (LLMs), with their autoregressive character, dominate text generation. Based on a “temperature” parameter, LLMs in inference/generative mode may provide a variety of responses to a given prompt. This work provides an analysis method of the variety of responses to a given prompt. It is more expressive than simply setting a temperature. The basis is a conditional version of mutual information [Cover]:
with the operational expression
In eq:1.1, and are phrases that pre- and post-pend ; the latter thought of as a query, .
We shall show that
with the entropy of the vocabulary.
Without the conditionality, Eq. (1.1) simplifies to the standard mutual information (MI) between the probability of two correlated random variables (RVs) and their product, independent probabilities. Cover and Thomas’ book [Cover] also provides the conditional mutual information (CMI) version in Eq. (1.1) and various rewritings of it are used to obtain Eq. (3) and to analyze its limiting behaviors. When the CMI is maximum, one learns the most possible about from knowledge of (and vice versa), conditional on . When zero, no added information about due to knowledge of (and vice versa), conditional on query is obtained. Based on these limits, we define three instructive classes termed: arbiter, independent (conditionally) and neutral/deterministic. Examples of each class and their application to the four topics: 1) “temperature” analysis, 2) language analysis, 3) prompt compression and 4) knowledge graphs are presented.
Derivations
General Expressions
The following relies on Cover and Thomas’ book [Cover]. For notational simplicity, use “1”, “2” and “3” for the RV names. The conditional MI in Eq. (1.1.a), by expansion of numerator and denominator, is
in terms of the corresponding entropies.
Use the entropy decomposition expression
written for , in Eq. (4) to get
Now use another version of :
Substitute Eq. (7) in Eq. (6) to eliminate :
From Eq. (4),
From Eq. (8),
Eq. (9) provides a tighter bound than that from Eq. (10).
From the ‘symmetry’ of Eq. (9),
Limiting Cases
Various limiting behaviors are instructive. Throughout, assume that functional relations between given RVs are one-to-one, as is sensible for tokens.
Suppose . Then because there can be only one value of RV 1 for a specified value of RV 3. Thus, from Eq. (4)
Eq. (12) maximizes Eq. (11). Note that for any vocabulary it is straightforward to evaluate the conditional entropy .
Suppose . Then because RV 3 provides no added information about RV 2, given a value of RV 2. From Eq. (4)
Lastly, as conditioning can only reduce entropy, Eq. (11) has the further limiting behavior that if e.g., the minimum in Eq. (11) is then
Explicit proofs of the above two limiting cases are provided in Appendix § 6.
Limit Behavior and Terminology
With the above limit behaviors, three situations: arbiter, independent (conditionally) and neutral/deterministic can be inferred.
From Eq. (12), where , using the terminology and notation of the Introduction,
where , with the token set of entropy . Here, one can conclude that, for a set of query words, there is a strong chance that for you “know” what is. Examples are given in Table 1.
| the black cat | over the moon | jumped |
| peanut butter | jelly | and |
| bread | butter | and |
| peaches | cream | and |
| I | you | love |
| love | all | conquers |
Table 1. Arbiter examples.
This circumstance should be more likely for longer phrases, such as poetry/lyrics.
Regarding the inequality in Eq. (15), note that for many queries there will be sets where there is no correlation with a . E.g., with just about any word, such as {bread, milk, cat, ....} [and]. For these ’s, , the maximum possible entropy, which is the entropy of the vocabulary, as .
Independent (conditionally): . (2.13)
Independence results from Eq. (1.1) when where, by definition, is uninformative about . Examples, with representation , are:
(he, they, she,...) [looked] (up, down, sideways,...).
This should be a common occurrence.
Neutral/deterministic: . (2.14)
This occurs when , (or ), where there is no correlation between prefix and suffix, conditional on a query. We refer to it as neutral as nothing is learned about when is determined by a query . We refer to it as deterministic because (or ) with a token. This case should also be a common occurrence. It is easy to distinguish between independent (conditionally) and neutral/deterministic where, in both cases , because for neutral/deterministic (or ).
Examples of neutral/deterministic with pattern are shown in Table 2. E.g., for [Carpe] (Diem) – a fixed prefix for this query, [Carpe]. That is, there is only one for this .
| Carpe | Diem |
| chit | chat |
| topsy | turvy |
| sink or | swim |
| related | to |
Table 2.
Table 2. neutral/deterministic examples.
Of course, the last example in Table 2 is not precise because, e.g., is also possible.
But the others are distinctly deterministic.
Uses
Four uses of this mutual information are discussed here:
Temperature. Generically, the above analysis can be viewed as a more specific approach to “temperature ()”. In generative mode is used to span, for low , almost always the same response, to high , with a greater variety of responses. Tasks such as mathematical proofs are appropriate to low while poetry would be better served by a higher . (Other methods of producing a variety of responses such as “top-K” and “top-P” exist of course. [von Platen])
Language analysis. E.g., for a “connector” () word. If a connector, , is “and” then one expects because of phrases such as: (bread) – [and] – (butter), (peaches) – [and] – (cream), (black) – [and] – (white), etc. On the other hand, good candidates for a connector where because of independence could be, for examples, (he/they/she/…) – [looked] – (up/down/sideways…).
Prompt compression. Here, the arbiter for of Eq. (15) is most appropriate. A large CMI implies you learn about from knowing ; so, can be skipped (and vice versa). For example,
(A hurricane has been announced.) – [Therefore,] – (air traffic will be disrupted.)
This will, with more than random weight, be preceded by this . Phrases such as:
(black) –[and] –(white)
come up often in texts. The probabilities of such phrases are higher than random implying the arbiter situation.
Knowledge Graphs. In the context of knowledge graphs (KGs), the association of nodes (entities) with keys, and , and edges (relationships) as queries, , is warranted. KGs [Edge] have become important to the systematization of Retrieval Augmented Generation (RAG)
[Dalimunthe, Zhao], with ongoing efforts to improve prompt design in Large Language Model inference/generation. Knowledge graphs should also fit the arbiter category because what is desired is whereby . In other words, maximum CMI because, if phrases and are correlated, there is a lot of mutual information, conditional on . For example, a relationship word such as can show a strong connection between two keys as in: (Albert Einstein) [developed] (a theory of relativity), as further elaborated in [Dalimunthe]. Relationship words with large CMI (approximately the entropy of a key, conditional on a given query) should help create KGs in an objective manner.
Concluding Remarks
In this work, we develop a method to analyze the relationship among words and phrases based on the conditional mutual information expression given in Eq. (1.1). Various limits of it follow from the connection between the two keys, and , or between a key, or , and the query, . Expressing the conditional mutual information in terms of its constituent entropies provides various limiting expressions. From Eq. (12), it is straightforward, given a token set , to evaluate e.g., because all tokens are from same alphabet. The non-negativity of this entropy provides strict bounds on the possible CMI values.
Three cases are defined: arbiter, independent (conditionally) and neutral/deterministic that achieve limiting behaviors of the conditional mutual information. They are applied to four tasks: “Temperature” analysis, language analysis, prompt compression, and knowledge graphs. The most interesting cases correspond to the arbiter situation where the CMI is close to the conditional entropy as it relies on a strong relationship between the keys. As shown, this should be quite useful for prompt compression and knowledge graph/Retrieval Augmented Generation (KG/RAG) purposes.
Finally, with reference to Eq. (1.1), a similar analysis can be conducted for or . The only distinction is which RV is fixed.
Appendix A
Eqs. (12) and (13) follow from the definitions of mutual information and entropy.
For Eq. (12), where :
For Eq. (13), where :
References
- [1]T. M. Cover and J. A. Thomas, Elements of Information Theory John Wiley & Sons, New York (1991).
- [2]P. von Platen, Medium. How to generate text: using different decoding methods for language generation with Transformers, Retrieved from https://huggingface.co/blog/how-to-generate
- [3]D. Edge, H. Trinh, N. Chang, J. Bradley, A. Chao, A. Mody, S. Truitt, J. Larson. From Local to Global: A Graph RAG Approach to Query-Focused Summarization. arXiv: 2404.16130v1 [cs.CL].arxiv.org/abs/2404.16130
- [4]R. Dalimunthe, Medium. Towards Data Science, Retrieved from https://towardsdatascience.com/an-easy-way-to-comprehend-how-graphrag-works-6d53f8b540d0
- [5]P. Zhao, H. Zhang, Q. Yu, Z. Wang, Y. Geng, F. Fu, L. Yang, W. Zhang, J. Jiang, B. Cui, Retrieval-Augmented Generation for AI-Generated Content: A Survey, arXiv:2402.19473v6 [cs.CV].arxiv.org/abs/2402.19473