Heaps' law

Verification of Heaps' law on War and Peace, as well as a randomly shuffled version of it. Both cases fit well to the Heaps' law with very similar exponents β, but different K.
A schematic Heaps-law plot. The x-axis represents the text size, and the y-axis represents the number of distinct vocabulary elements present in the text. Compare the values of the two axes.

In linguistics, Heaps' law (also called Herdan's law) is an empirical law which describes the number of distinct words in a document (or set of documents) as a function of the document length (so called type-token relation). It can be formulated as

where VR is the number of distinct words in an instance text of size n. K and β are free parameters determined empirically. With English text corpora, typically K is between 10 and 100, and β is between 0.4 and 0.6.

The law is frequently attributed to Harold Stanley Heaps, but was originally discovered by Gustav Herdan (1960).[1] Under mild assumptions, the Herdan–Heaps law is asymptotically equivalent to Zipf's law concerning the frequencies of individual words within a text.[2] This is a consequence of the fact that the type-token relation (in general) of a homogenous text can be derived from the distribution of its types.[3]

Empirically, Heaps' law is preserved even when the document is randomly shuffled,[4] meaning that it does not depend on the ordering of words, but only the frequency of words.[5] This is used as evidence for deriving Heaps' law from Zipf's law.[4]

Heaps' law means that as more instance text is gathered, there will be diminishing returns in terms of discovery of the full vocabulary from which the distinct terms are drawn.

Deviations from Heaps' law, as typically observed in English text corpora, have been identified in corpora generated with large language models.[6]

Heaps' law also applies to situations in which the "vocabulary" is just some set of distinct types which are attributes of some collection of objects. For example, the objects could be people, and the types could be country of origin of the person. If persons are selected randomly (that is, we are not selecting based on country of origin), then Heaps' law says we will quickly have representatives from most countries (in proportion to their population) but it will become increasingly difficult to cover the entire set of countries by continuing this method of sampling. Heaps' law has been observed also in single-cell transcriptomes[7] considering genes as the distinct objects in the "vocabulary".

  1. ^ Egghe (2007): "Herdan's law in linguistics and Heaps' law in information retrieval are different formulations of the same phenomenon".
  2. ^ Kornai (1999); Baeza-Yates & Navarro (2000); van Leijenhorst & van der Weide (2005).
  3. ^ Milička (2009)
  4. ^ a b Sano, Yukie; Takayasu, Hideki; Takayasu, Misako (2012). "Zipf's Law and Heaps' Law Can Predict the Size of Potential Words". Progress of Theoretical Physics Supplement. 194: 202–209. Bibcode:2012PThPS.194..202S. doi:10.1143/PTPS.194.202. ISSN 0375-9687.
  5. ^ Najafi, Elham; Darooneh, Amir H. (2015-06-19). Esteban, Francisco J. (ed.). "The Fractal Patterns of Words in a Text: A Method for Automatic Keyword Extraction". PLOS ONE. 10 (6): e0130617. Bibcode:2015PLoSO..1030617N. doi:10.1371/journal.pone.0130617. ISSN 1932-6203. PMC 4474631. PMID 26091207.
  6. ^ Lai, Uyen; Randhawa, Gurjit; Sheridan, Paul (2023-12-12). "Heaps' Law in GPT-Neo Large Language Model Emulated Corpora". Proceedings of the Tenth International Workshop on Evaluating Information Access (EVIA 2023), a Satellite Workshop of the NTCIR-17 Conference. Tokyo, Japan. pp. 20–23. doi:10.20736/0002001352.
  7. ^ Lazzardi, Silvia; Valle, Filippo; Mazzolini, Andrea; Scialdone, Antonio; Caselle, Michele; Osella, Matteo (2021-06-17). "Emergent Statistical Laws in Single-Cell Transcriptomic Data". bioRxiv: 2021–06.16.448706. doi:10.1101/2021.06.16.448706. S2CID 235482777. Retrieved 2021-06-18.