A City of Millions: Mapping Literary Social Networks At Scale (2025)

Abstract: We release 70,509 high-quality social networks extracted from multilingual fiction and nonfiction narratives. We additionally provide metadata for ~30,000 of these texts (73% nonfiction and 27% fiction) written between 1800 and 1999 in 58 languages. This dataset provides information on historical social worlds at an unprecedented scale, including data for 2,510,021 individuals in 2,805,482 pair-wise relationships annotated for affinity and relationship type. We achieve this scale by automating previously manual methods of extracting social networks; specifically, we adapt an existing annotation task as a language model prompt, ensuring consistency at scale with the use of structured output. This dataset serves as a unique resource for humanities and social science research by providing data on cognitive models of social realities.

## introduction literary scholars have long been interested in the social worlds of novels. novels depict social configurations across time and space at varying levels of abstraction, from the grand descriptions of geopolitical intrigue in war and peace to the personal relationships underpinning in search of lost time. while social networks cannot represent the full detail and nuance of literary works, they provide a uniform format to identify large-scale patterns. however, prior attempts at extracting social networks from literary texts have been hindered by a dependency on supervised machine learning models limited in accuracy and scalability. in this work, we present a dataset of high quality social networks extracted from 70,509 literary texts, such as that shown in figure 1 . we extract the networks, including affinities and relationship types, using a novel method that passes a modified prompt from @xcite to gemini 1.5 flash configured to output json. we validate this approach by demonstrating that it produces annotations similar to the manual annotations provided by @xcite . in addition to networks, we also provide extended metadata for a subset of ∼30,000 works, of which 22,015 are nonfiction and 7,331 fiction. this dataset will provide researchers with the opportunity to evaluate literary and social hypotheses at scale. as an initial example, we show that nonfiction networks consist of more communities and are less clustered than fiction networks. this may help explain why characters in non-fiction texts travel more @xcite as, intuitively, a text consisting of fewer social communities may feature fewer locations. 1 2 related work literary social network extraction. significant previous research has addressed extracting social networks from literary texts. one traditional approach involves creating networks by hand @xcite @xcite , but manual annotations are time intensive and do not scale to large datasets. alternative approaches look for character co-occurrences in windowed units like sentences or chapters @xcite @xcite . identifying co-occurrences is computationally lightweight, but their dependency on surfacelevel features limits their accuracy and applicability. neural networks have also been used more widely in recent years for this task @xcite @xcite . specifically, @xcite and @xcite both use generative models to extract literary social networks, but their approaches are semi-supervised and thus not easily scaled, limiting their studies to datasets in the low hundreds of volumes. literary social networks in use. literary social networks are often used to study particular character or character-relationship traits such as prominence @xcite , cooperativeness @xcite , relationship trajectory @xcite , and relationship valence @xcite @xcite . some studies also use social networks to ground characters in particular locations @xcite . social networks are likewise useful for studying aspects of plot, including conflict @xcite , narrative trajectory @xcite , textual genre @xcite , and text veracity @xcite . they also provide data for studies comparing differences within a corpus @xcite , over time @xcite , and between different social theories @xcite @xcite @xcite . however, these studies make use of relatively small corpora, limiting the statistical significance of their results. ## methods data. we draw volumes from the project gutenberg (pg) corpus @xcite . pg is an online collection of public domain literary volumes developed by volunteers. it currently contains over 75,000 works, and continues to grow. the size and historical breadth of the corpus makes it popular with researchers working in literary analysis @xcite @xcite and corpus linguistics @xcite . to create our dataset, we first download the full corpus from pg, resulting in 72,875 volumes totaling 25gb of raw text. 2 we then supplement the limited metadata provided by pg (author and title) by aligning texts with multihathi, an extended multilingual edition of the hathitrust digital library catalog @xcite , containing metadata such as publication date, language, and fiction/nonfiction status. we use title and author edit distance @xcite to find the closest match for each pg text in multihathi, only considering matches where the multihathi title and author matches both exceed 80% similarity. this process yields 33,919 well-documented texts. model selection. we consider two qualities when selecting a suitable large language model (llm) for generating social networks from arbitrarylength texts. the first is maximum context length. the longest work in our full corpus is 13,551,565 tokens (4,233,776 words) when tokenized with the sentencepiece-based gemma 2 tokenizer @xcite . for comparison, the mean word count of all volumes in our full corpus is 63,656 words (p 95 = 170,601). prompts of this magnitude can quickly exhaust the capacity of recent "open weight" llms, which most commonly offer context windows equal to or less than 128,000 tokens, despite the growing popularity of positional embedding modifications like rope and yarn @xcite @xcite . our second consideration is support for structured output. when we generate output for ∼70,000 documents from a stochastic language model, there is no default guarantee that the output will be consistent. recent methods for guaranteeing consistent output include grammarconstrained decoding, where tokens are selectively masked at sampling time according to some context-free grammar @xcite @xcite . a competing method is structured output, where the model emits json according to a json schema passed at inference time @xcite . along with larger context windows, proprietary models have made structured output a common feature. from the pool of presently-available proprietary llms satisfying both these conditions, we select google's gemini 1.5 flash, which features a context window of 1 × 10 6 tokens and supports structured output via json schema @xcite . pipeline. to create an appropriate prompt for extracting social networks from texts, we turn to a public dataset released by @xcite . this dataset contains 2,170 annotated character relationships produced from 109 fictional narratives. each character pair is labeled with three attributes: the valence of the relationship (positive, negative, or neutral) and two descriptors ("coarsegrained" and "fine-grained," with 3 and 30 possible labels respectively) further clarifying the relationship in terms of social function and connection (e.g., whether the characters are lovers). @xcite release the annotation prompt they used for mechanical turk workers alongside the dataset. we adapt their prompt for gemini 1.5 flash in json schema, effectively requiring the model to return a json array of characters and their relationships for each text. foot_2 ## results we use this pipeline to process the entire project gutenberg corpus. it returns 71,836 networks from a total 72,875 volumes after omitting 1,039 volumes that fail to pass the gemini api safe content filter. 4 removing duplicate networks and malformed relationships (correcting attribute labels where possible) reduces this to 70,509 total networks, of which 29,346 (22,015 nonfiction and 7,331 fiction) have hathitrust metadata available. validation. we assess the validity of our approach by comparing our gemini-based pipeline against the human-annotated results reported in @xcite . for each network in @xcite , we retrieve the original text and pass it through gemini together with our prompt. we additionally instruct the model to only return an- ## network properties previous research has suggested that fictional worlds are smaller than nonfictional worlds. for example, @xcite showed that fictional protagonists travel smaller distances, follow more routine paths, and more frequently spend time in domestic or private spaces than their nonfictional counterparts. with our new access to large-scale social network information, we can test whether similar distinctions hold between community structures. in the same way that fictional characters travel less than do people in non-fiction, they may also participate in more tightly-knit social networks. network characteristics. we test the validity of this hypothesis by assessing the network characteristics of the nonfiction and fiction volumes with metadata available in our dataset. we find that nonfiction networks are on average significantly larger than fiction networks by both number of nodes (22.14 v. 42.69) and number of edges (27.42 v. 42.91). 5 two other metrics of network complexity include the number of disconnected components (groups of characters that do not interact) and transitivity (the probability that two nodes that share a mutual connection are themselves connected). fictional networks have significantly fewer disconnected components (2.20 vs. 5.12) and their mean transitivity is significantly larger (0.22 vs. 0.12) than nonfiction networks. thus, we see that fiction networks are smaller and more clustered than nonfiction networks. ## conclusion this work presents a novel dataset containing 70,509 high-quality social networks extracted from fiction and nonfiction narratives. it additionally includes metadata for 29,346 texts written between 1800 and 1999 in 58 languages. we release this resource to support researchers in the humanities and social sciences studying the development of social worlds over time, and the work of behavioral scientists who seek to understand how cognitive models of social communities compare with realworld social communities. our dataset-construction process also contributes to a growing literature on adapting annotation task instructions for language models. our results demonstrate that we can use llms to generate large-scale datasets for complicated and nuanced annotations on volume-length data. we find that constrained output such as json schema is critical to maintaining consistency and compatibility at scale. we also observe that more concrete, descriptive annotations are more successful than more abstract annotations, even when these appear logically identical to humans. next steps. while our dataset is a step forward for researchers studying social networks, there remains room for progress. generative language models improve over older social network extraction methods based on surface-level features, but we need better open and locally runnable alternatives to inefficient and costly proprietary models. these models have low interpretability, do not permit unlimited token lengths, and block content considered inappropriate for opaque reasons that may be inappropriate for historical data. we similarly lack good evaluation methods. modeling social networks as graphs is an inherently interpretive act, sometimes literally so in the context of literary data. to that end, social networks may change depending on the perspective of the narrator. our current method does not allow these perspectives be reflected in graph structures. we believe future research should consider further methods for assessing the validity of extracted social networks.