Elamur Research

ConGraT: Self-Supervised Contrastive Pretraining for Joint Graph and Text Embeddings

Paper · 2024 · William Brannon, Wonjune Kang, Suyash Fulay et al.

Summary

A citation network records which articles refer to each other. The articles themselves describe what the researchers studied. Either source can help identify related work, but they describe different kinds of relationships. The same problem arises with hyperlinks between webpages and with social networks, where a connection between users and the language of their posts can tell different stories. ConGraT learns from both sources by placing nodes and their associated texts in a shared space. It learns a separate numerical representation for each, so a downstream task can use an article, a person, or a piece of writing as its input.

The method uses associations already present in the data. It takes a batch of texts and their source nodes, encodes each side separately, and compares every text with every node in the batch. Training rewards the encoders when a text ranks its source highly and a node ranks its paired text highly. The authors also test an extension that gives some credit to plausible alternatives. A text from a structurally similar node can receive a higher training target than a text from a distant part of the graph. The actual association and the distribution of alternatives contribute separately, and a setting controls how much weight each receives.

The experiments cover a rebuilt Pubmed citation graph, a Wikipedia hyperlink graph drawn from T-REx, and a Twitter follow graph. The authors split by node and remove edges crossing the splits in the main experiments. The best ConGraT setting beats the comparison systems on the reported classification outcomes. On Twitter, its best test-set link prediction AUC is 0.806, compared with 0.723 for the strongest baseline in the main experiment, even though ConGraT receives no additional link prediction training. After further training for next-token prediction, its causal encoder achieves lower mean perplexity than the text-only baseline on each dataset in the main setup.

On Twitter, communities formed from ConGraT node vectors are also easier to predict from users’ writing than communities based directly on the follow graph or clustered from baseline graph vectors. The graph-based extension often helps, but its effect depends on the task and how the node vectors are initialized. The paper reports a release of the code and datasets, including a reconstruction of Pubmed with titles and abstracts alongside the citation network.

Deep dive: ConGraT: Self-Supervised Contrastive Pretraining for Joint Graph and Text Embeddings

ConGraT learns a shared space for graph nodes and their texts, improving classification, link prediction, and next-token prediction in its main tests. · about 39 minutes to read

The problem and its context

What the edges tell us about the writing

In a text-attributed graph, the graph describes relationships between entities and the text is attached to those entities. An article is a node in a citation graph, while its title and abstract supply text for that node. A Twitter account is a node in a follow graph, while its posts supply the text. These examples differ in an important way. A scientific article contains the text assigned to it, while an account can produce many independent pieces of writing. A useful learning procedure needs a way to use either arrangement without requiring the same number of texts for every node.

The edges and the text also carry different kinds of evidence. A piece of writing can name its subject directly. A citation can connect articles whose titles describe the subject in different terms. An account’s posts may rarely mention its region, while its follow connections may be informative about geography. In the other direction, accounts that use similar language can have something in common even when there is no direct connection between them. Which source matters depends on the question being asked. A useful vector for an individual post therefore has a different job from a useful vector for its author.

The authors want both kinds of vectors to be informed by joint training and comparable in a common coordinate system. This requirement goes beyond using text to initialize a graph algorithm. In that setup, text information can reach the node vector, but the resulting node vector provides no general way to encode a new piece of writing. It also goes beyond using links to choose training examples for a text encoder. That approach can improve a document vector while leaving the graph without a separate representation of its nodes. ConGraT treats the quality of each output as a question in its own right.

The authors distinguish these graphs from other ways of putting language and graphs together. A graph produced by dependency parsing describes relations within a sentence. A knowledge graph can encode relationships between entities mentioned in text. In the datasets used by ConGraT, the graph instead connects the entities that contain or produce the text. A citation links articles, a hyperlink links pages, and a follow edge links accounts. The attachment between node and text is a separate relation from any of those edges. That distinction gives ConGraT its source of supervision.

What earlier approaches learned

One body of work described in the paper used language to improve node representations. The examples include extensions to DeepWalk that incorporate text features, sequence-to-sequence training from text attached to nodes, and selective attention that produces text-informed representations for particular social contexts. Another approach builds representations from user profiles while taking the network into account. Some work obtains the graph itself by finding entities that occur together in text. The natural output of these methods is a vector for a node. That is appropriate when the intended prediction is about the node, but a new text still needs its own route into the representation space if it is to be analyzed directly.

A different body of work used graph relationships to shape the training of text encoders. SPECTER, for instance, uses the citation graph to choose examples for a triplet objective. A triplet specifies an anchor document and examples that should rank closer to or farther from the anchor. SciNCL uses nearest neighbors in a continuous representation of the citation graph to sample examples. Both illustrate how choices made from the network can influence the geometry of document vectors. SPECTER

LinkBERT uses links when it assembles pairs of text segments. A segment can be paired with a nearby passage, with a passage from a linked document, or with unrelated material sampled as a random pair. In addition to recovering masked words, the encoder learns to identify the relation between the segments. Social-BERT and LMSOC use a different route. They supply an existing node vector to the text encoder as part of its input and keep that vector fixed during text training. The distinction matters for ConGraT because it seeks a text encoder that can make a graph-informed representation from the text itself, and a node encoder whose representations also change during joint training. LinkBERT

The paper also discusses methods that explicitly try to bring graph and text representations together. A mapping between fixed representations can put them in comparable coordinates, but its freedom is limited to transforming features the encoders already produce. Other joint approaches use external labels or specialize their learning signal for a particular task. Prefix tuning can learn a dense representation associated with a node, although the paper’s example of this approach does not use edges between nodes. For the authors, the aim is to let both encoders adapt and to do so before choosing a target such as a category or a link.

The closest comparisons include GraphFormers, GIANT, and GLEM. The paper describes GraphFormers as jointly training text and graph components through a progressive procedure that uses manipulated and original data. GIANT uses graph structure as a prediction target for a text encoder and passes the resulting features to a graph encoder. During the latter stage, the text representations are fixed. GLEM alternates updates of the graph and text components, with each supplying pseudo-labels for the other. Those pseudo-labels are predictions for a particular task, and the procedure relies on access to task labels. ConGraT instead places a loss directly on the output of both encoders and updates them together using known node–text pairs.

Why matching can serve as pretraining

The authors draw on CLIP, where the correspondence between an image and its text supplies examples of what should go together. A similar relation is already available in the graphs studied here. An article is attached to its abstract and an account to its posts. This makes the training self-supervised in a precise sense. The target can be read from the structure of the data itself. There is no need to annotate articles with subject categories or users with demographic traits to decide which examples belong together during this stage. Those labels can be reserved for measuring what the resulting vectors retain. CLIP

The graph supplies another training signal beyond the attachment. Two different nodes can have similar neighborhoods, and that similarity can distinguish a plausible alternative from an arbitrary mismatch. If related nodes produce or contain comparable texts, the network gives a reason to treat some mismatches more leniently. ConGraT makes that reasoning part of the training target. It also leaves room to test the assumption, since the method can be trained with the ordinary matching objective by switching off that extra contribution.

A further goal is to produce encoders usable beyond the graph on which they were trained. In an inductive setting, new nodes, their texts, and the edges of a new graph can be supplied after learning the encoder parameters. A transductive setup can instead learn with access to the graph containing the nodes that will be evaluated. The authors choose the former setting for their main experiments. Inductive evaluation still gives the graph encoder structure to work with at inference time. The relevant distinction is whether that structure was available when fitting the encoder. Inductive Representation Learning on Large Graphs

The method, step by step

Start with a text and its source

Consider a batch of posts, each paired with the account that produced it. The text encoder turns every post into a vector. The graph encoder turns every corresponding account into another vector, using features of the accounts and their connections. An adapter after each encoder brings its output into the coordinate system used for comparison. Once the vectors are available, the same post can be scored against its own account and all the other accounts represented in the batch. Conversely, any account can be scored against every post in that batch.

A batch consequently supplies alternatives without requiring the authors to label groups of unrelated nodes or texts in advance. The known source of a post is its direct match. Posts from other accounts become its source’s alternative candidates. In the graph-aware variant, an alternative belonging to a similar part of the network receives some target probability. This changes what counts as a good ranking among the alternatives while keeping a direct contribution from the observed match when the mixing setting is below its upper endpoint.

ConGraT pretraining on paired nodes and texts

The steps in order.

ConGraT pretraining on paired nodes and textsStep 1: Sample texts with distinct source nodes1. Sample texts with distinct source nodesStep 2: Encode texts and graph nodes separately2. Encode texts and graph nodes separatelyStep 3: Project both outputs into a shared space3. Project both outputs into a shared spaceStep 4: Score every text against every batch node4. Score every text against every batch nodeStep 5: Mix observed targets with optional graph similarity5. Mix observed targets with optional graph similarityStep 6: Measure errors in both matching directions6. Measure errors in both matching directionsStep 7: Update both encoders and their adapters7. Update both encoders and their adapters

Describe the graph and the paired examples

In mathematical terms, the graph has a node set and an edge set. The edges can carry direction, as in a citation from one article to another, or be treated as undirected for a given run. The attachment of a text to a node is recorded separately. The paper’s introductory illustration also allows a node without text. Such a node can belong to the graph even if it contributes no positive pair when the dataset of training examples is assembled.

G = (V, E),   E ⊆ V × V

Here G is the graph, V its node set, and E its edge set. The symbol × forms ordered pairs of members of V, while ⊆ says that the edges are a subset of those possible pairs. With directed edges, the order of the two nodes distinguishes the source and destination.

T⁽ᵛ⁾ = {tᵢ⁽ᵛ⁾}ᵢ₌₁ᴺ�

In this expression, T⁽ᵛ⁾ is the collection of texts for node v, and tᵢ⁽ᵛ⁾ denotes the text at index i in that collection. The upper bound, written Nᵛ, is the number of texts for v. The braces collect those indexed texts. A node with no attached text supplies no entries to this collection.

tᵢ⁽ᵛ⁾ = (S₀, S₁, S₂, …, Sₗ)

The symbols S with subscripts are tokens in text tᵢ⁽ᵛ⁾. The ellipsis stands for the intervening tokens, and ℓ denotes the final position in this sequence. S₀ and Sₗ are special tokens marking its start and end. Each token comes from a vocabulary W. This description makes the input to the text encoder a sequence whose length can vary, even though the resulting vector always has the same dimension. Tokenization

Fₜ : ⋃ₙ₌₁^∞ Wⁿ → ℝᵈ

Fₜ is the text encoder with its output adaptation. The union sign ⋃ collects sequences of every finite positive length n. Wⁿ denotes the sequences with n positions filled from vocabulary W, and ∞ indicates that the expression imposes no fixed length at the level of the mathematical definition. The arrow points to ℝᵈ, the space of vectors with d real-valued coordinates.

Fɢ : V → ℝᵈ

Fɢ is the node encoder with its output adaptation. It returns a vector in the same ℝᵈ space for a node in V. Edges enter the calculation through the graph encoder, even though the item returned is a vector for a node. In the experiments, the node encoder also receives initial node features.

X = ⋃ᵥ∈ⱽ {(v, t) : t ∈ T⁽ᵛ⁾}

X is the dataset of positive pairs. The union ranges over v in V, indicated by ∈. The symbol t represents a text, and the condition after the colon says that it belongs to the attachment collection T⁽ᵛ⁾. The parentheses pair the node and the text. If a node has many texts, it can appear in many examples in X.

B = {(vᵢ, tᵢ)}ᵢ₌₁ᴺᴮ ⊆ X

B is the batch sampled from X. The bracketed pair at position i contains a node vᵢ and its paired text tᵢ, where this shorter notation leaves implicit that the text belongs to vᵢ. Nᴮ is the batch size, and ⊆ expresses that the pairs come from the dataset. Batch positions give the node and text lists a corresponding order.

Keeping this correspondence simple turns out to matter. The authors report poorer performance when multiple texts from the same node enter a batch. Doing so gives a post repeated copies of its source among the candidate node positions, and gives a node multiple texts that could reasonably count as its match. Removing duplicates after ordinary sampling wasted too much data in their trials. They instead randomize the text order each epoch with the aim of reducing repeated sources in consecutive batches and drop the duplicates that remain. A node can still contribute different texts across batches. The restriction concerns competing entries in one calculation of the loss.

Give the vectors a common coordinate system

The experiments use a graph attention network, or GAT, for the graph side. Its attention mechanism learns how to weight the messages it receives from neighboring nodes. Successive graph layers allow a node’s vector to reflect information obtained through the network. The authors use 3 layers with 2 attention heads per layer, start the graph encoder from random weights, and train it as part of ConGraT. Linear transformations and layer normalization separate the graph convolutional layers. The hidden graph representations have dimension 64, and the final graph outputs have dimension 768. Layer Normalization

The initial node features in the main experiments already contain text information. For Pubmed they are sentence embeddings of the title and abstract combined. For T-REx they come from the Wikipedia article text. For Twitter they come from user biographies. This means an account’s graph encoder can start from its bio even though the text encoder in a paired training example is processing an individual tweet. It also means joint training is being tested against a graph baseline that has access to the same type of initial features.

On the text side, the authors initialize from all-mpnet-base-v2 for the masked variant and distilgpt2 for the causal variant. A masked encoder learns from contexts in which tokens have been hidden. A causal encoder uses preceding context for the next-token task. ConGraT uses the pretrained text encoders to produce token representations and then averages across the sequence to obtain a representation for the whole text. This averaging operation is mean pooling. For the masked encoder, the appendix notes that the starting weights already reflect contrastive training on corpora from domains similar to the evaluation data. MPNet

Each output adapter contains a pair of fully connected layers with a GeLU activation between them. The activation allows the adapter to learn a nonlinear transformation of the encoder output. Layer normalization and dropout follow. Dropout randomly suppresses some activations during training, and the probability applied to the text and node embeddings is 0.3. Both adapted outputs have dimension 768. Matching dimensions makes it possible to compare the vectors, while training against paired examples gives the coordinates their shared interpretation. Dropout

Compare the batch in both directions

The score of a text and a node is their cosine similarity multiplied by a learned scale. Cosine similarity compares the angle between vectors by dividing their inner product by their lengths. A text and node pointing in similar directions receive a high cosine score even if their original vector lengths differ.

Cᵢⱼ = eᵗᵃᵘ · (Fₜ(tᵢ) · Fɢ(vⱼ)) / (‖Fₜ(tᵢ)‖ · ‖Fɢ(vⱼ)‖)

Cᵢⱼ is the score at row i and column j. The row corresponds to text tᵢ and the column to node vⱼ. Fₜ and Fɢ are the adapted encoders, ‖ ‖ gives the length of each vector, and the dot between the vectors denotes their inner product. The remaining dots multiply scalar quantities, and the slash denotes division. The expression eᵗᵃᵘ means the exponential of the learned log-temperature parameter τ, with e the base of the natural logarithm. The authors initialize τ to 3.5 and constrain it to the open interval from −log 100 to +log 100 to support stable training.

The score matrix is square because a batch has as many node entries as texts. Its rows and columns still have different meanings. A row compares one text against all candidate nodes. A column compares one node against all candidate texts. Swapping the row and column indices would compare a different text and node and can change the score. Observed pairs fall on the diagonal because the node and text orders agree. Training along rows asks the text encoder to help identify a source, while training along columns asks the graph encoder to help identify its paired writing.

With the direct matching objective, all target probability for a row or column is assigned to the observed pair. Cross-entropy measures the discrepancy between this target and the probabilities obtained by applying a softmax to that row or column. The softmax gives candidates with higher scores more probability and normalizes the probabilities within the direction being evaluated. A positive pair that gets a small share of the predicted probability incurs a large loss. Averaging both directions gives the batch-wise contrastive procedure the authors adapt from CLIP, with a loss of the InfoNCE family. Representation Learning with Contrastive Predictive Coding

The graph-aware objective changes the target probabilities. The authors define a non-negative similarity function on node pairs and another on text pairs. Their actual text similarity function is based on the nodes the texts belong to. Thus a post can be a plausible candidate for a different account because the two accounts are structurally similar, even though the construction of the training target does not compare the words of the posts.

For the undirected graph, the computation begins with the adjacency matrix. An entry in this matrix records the presence of an edge between the nodes identified by that row and column. Multiplying the matrix by its transpose produces a matrix of overlap counts.

M = A Aᵀ

A is the adjacency matrix, and Aᵀ is its transpose, obtained by exchanging rows and columns. Juxtaposition denotes matrix multiplication. M contains mutual-neighbor counts for pairs of nodes. An entry for a pair is obtained by combining the adjacency profiles of those nodes, so a common neighbor contributes to that count.

Sɢ(u, v) = cosine(Mᵤ,:, M:,ᵥ)

Sɢ(u, v) is the similarity assigned to nodes u and v. Mᵤ,: selects the entire row for u and M:,ᵥ the entire column for v. The commas separate the row and column selectors, while a colon means to take every entry along that axis. The cosine compares the resulting profiles by their angle. In the undirected case the overlap matrix is symmetric, so a row and its corresponding column describe the same profile. The paper chooses this operation in part because it is cheaper to compute on large graphs than an alternative it considers, SimRank.

Sₜ(tᵢ, tⱼ) = Sɢ(vᵢ, vⱼ)

Here Sₜ is the training similarity for texts tᵢ and tⱼ, and Sɢ is the graph similarity for their source nodes vᵢ and vⱼ. This equality connects the targets for text alternatives to the node structure. It concerns the scores used to build the targets. The learned cosine scores between text and node vectors are still computed by the encoders.

The similarity scores are then normalized within the batch. The following notation uses i for the fixed anchor and j for a candidate, in either matching direction.

Kₜ⁽ⁱ⁾ = ∑ₖ₌₁ᴺᴮ Sₜ(tᵢ, tₖ)

Kₜ⁽ⁱ⁾ is the normalization total for text similarities anchored at index i. The sum ∑ ranges over the batch positions k, up to Nᴮ, and tₖ is the text at each such position.

Kɢ⁽ⁱ⁾ = ∑ₖ₌₁ᴺᴮ Sɢ(vᵢ, vₖ)

Kɢ⁽ⁱ⁾ is the analogous total for graph similarities. The anchor is node vᵢ, and vₖ ranges over the node candidates. Nᴮ again gives the number of positions.

sₜ⁽ⁱ⁾(j) = Sₜ(tᵢ, tⱼ) / Kₜ⁽ⁱ⁾

This quotient defines sₜ⁽ⁱ⁾(j), the relative weight assigned to text candidate j from the perspective of anchor i. Sₜ supplies the numerator for that pair and Kₜ⁽ⁱ⁾ supplies the total score for that anchor. Division makes the resulting weights sum to one when the total is positive.

sɢ⁽ⁱ⁾(j) = Sɢ(vᵢ, vⱼ) / Kɢ⁽ⁱ⁾

The quantity sɢ⁽ⁱ⁾(j) is the corresponding weight for node candidate j. Its numerator is the structural similarity between vᵢ and vⱼ, and its denominator Kɢ⁽ⁱ⁾ is the total over the batch. With the chosen similarity function and unique source nodes, the structural weights for text candidates come from the same node relationships as their graph counterparts.

The final target is a mixture of an observed-match indicator and these normalized similarities. In row-oriented notation, the anchor text is tᵢ and the candidate is node vⱼ. In column-oriented notation, the anchor is vᵢ and the candidate is text tⱼ. Matching nodes are indexed by the source of the original text, and matching texts by the entry originally paired with the anchor node.

Dₜ⁽ⁱ⁾(j; α) = (1 − α) · 𝟙{vⱼ = vᵢ} + α · sₜ⁽ⁱ⁾(j)

Dₜ⁽ⁱ⁾(j; α) is the row target for candidate j at anchor i. The semicolon inside the notation separates the candidate from the setting α. The indicator 𝟙 is one when the candidate is the text’s source node and zero otherwise. The term sₜ⁽ⁱ⁾(j) uses the similarity of the texts associated with positions i and j to assign a structural weight. The factors 1 − α and α are the weights for the observed and structural parts respectively.

Dɢ⁽ⁱ⁾(j; α) = (1 − α) · 𝟙{tⱼ = tᵢ} + α · sɢ⁽ⁱ⁾(j)

Dɢ⁽ⁱ⁾(j; α) is the column target. Its indicator identifies the paired text tᵢ, and sɢ⁽ⁱ⁾(j) provides the graph-based weight for the candidate text’s node. With distinct source nodes and the intended correspondence of batch entries, the observed-match indicators select the diagonal.

ℒ(B; α) = (1 / (2Nᴮ)) · ∑ᵢ₌₁ᴺᴮ [H(Cᵢ,:, Dₜ⁽ⁱ⁾(α)) + H(C:,ᵢ, Dɢ⁽ⁱ⁾(α))]

ℒ(B; α) is the batch loss at the chosen mixture setting. H is cross-entropy, applied to the scores in its first argument and the target probabilities in its second. Cᵢ,: is the score row for text i, and C:,ᵢ is the score column for node i. Dₜ⁽ⁱ⁾(α) and Dɢ⁽ⁱ⁾(α) are the corresponding target vectors over the candidate positions j. The square brackets group the losses for those two directions. The sum covers every batch position, and 1 / (2Nᴮ) averages the two terms per position.

At α = 0.0, only direct associations supply the targets. At α = 0.1, the structural distribution contributes a smaller part of the probability, and the match retains its direct contribution. At α = 1.0, the structural distribution supplies the entire target. This last setting removes the separate indicator term. The normalized similarity distribution itself can still give weight to the observed pair through the graph’s self-similarity.

The authors describe the extension as a continuous relaxation of matching over a node’s two-hop neighborhood, motivated by the fact that a shared neighbor connects two nodes by a path through that neighbor. The mutual-neighbor entries and the subsequent cosine between overlap profiles are distinct operations. For reproducing the experiment, the stated cosine calculation specifies the weights. The neighborhood interpretation explains why structurally similar candidates can receive partial credit. The authors also describe a simpler relaxation using the presence of a direct edge as a binary similarity. Their comparison to label smoothing concerns the training targets. It is separate from the way a graph encoder aggregates neighbor representations.

Fit the encoders jointly

The principal experiments vary the choice of text encoder, whether graph edges are directed, and whether α is positive. The authors have a structural similarity construction for the undirected setting and defer a directed counterpart. For each text encoder they therefore train on undirected graphs with α = 0.0 and α = 0.1 and on directed graphs with α = 0.0. The paper reports 6 combinations per dataset and 18 across the main datasets.

The joint runs use a batch size of 36 and a constant base learning rate of 1.0e-4. AdamW is used with β values of 0.9 and 0.999 and with weight decay disabled. Spikes in the gradient norm caused failures during training, so the authors clip the norm to 1 at each step. They use 16-bit mixed precision to fit larger batches, but find it necessary to reduce the gradient scaler’s initial scale to 256 because of overflow. Each joint run uses a single NVIDIA RTX A6000 or A100. For the joint runs and baselines together, the authors estimate 263 hours of GPU time. Decoupled Weight Decay Regularization

The batch size is a substantive part of this design because the batch determines which candidates compete. A larger batch can expose an anchor to more unrelated and related alternatives. It also calls for more pairwise comparisons. The score matrix grows with the square of the number of positions. The authors use the largest batch they can fit consistently on their hardware. Their procedure ties the optimization and the supply of alternatives to that practical choice.

Experiments and results

Three kinds of text-attributed graph

The Pubmed graph is a reconstruction of a benchmark for classifying diabetes research. The authors start with the article identifiers for the benchmark and retrieve titles, abstracts, and reference lists through Pubmed. They retain citations to articles within the dataset and omit an identifier that the database does not return. The resulting graph has 19,716 nodes, 61,110 edges, and 59,381 texts. Its article labels distinguish type I diabetes, type II diabetes, and experimental evidence. For a graph-learning benchmark whose widely available versions lacked the actual text, recovering the text makes it possible to compare what can be learned from the title and abstract with what can be learned from the citation graph. Collective Classification in Network Data

The T-REx dataset is constructed from Wikipedia pages in the Robots category or its descendant categories. The texts are introductory passages and the edges come from links in those passages. The dataset counts are 9,214 nodes, 22,689 edges, and 18,422 texts. The authors expand category annotations up the Wikipedia hierarchy to improve the balance of the possible prediction targets. The set grows from 1,433 unique categories to 6,643. They select frequent categories with relatively little overlap for the classification tasks. The selected labels are Robots, Rockets, Sci-Fi, Spacecraft, and Space Telescopes. A page can have more than one of these labels, and some pages have none.

The Twitter dataset pairs 167,558 tweets with 8,721 influential accounts in media, politics, and entertainment. There are 2,373,956 follow edges among those accounts. For each account, the authors sample no more than 20 posts from the 3,200 latest tweets as of May 9, 2021. For classification, they collect attributes for age, gender, occupation, political party, and geographic region. They use Wikidata through matches to Wikipedia for age and gender, information from Ballotpedia for politics-related attributes, and locations self-reported in Twitter profiles for geographic categories. The appendix distinguishes how politician status and party are derived, with politician status defined more strictly.

In the main experiment, the split is by node, with 70% for training, 10% for validation, and 20% for testing. Every text attached to a node follows it into the same split. An edge is omitted if its endpoints are in different splits. That matters directly for the claim about inductive performance. The graph encoder receives test-time nodes and their within-split connections, while the text encoder receives texts from held-out sources. Both are evaluated on their ability to apply learned transformations after the split, with the graph side still able to use connections within the graph it is given.

What the baselines control for

The graph baseline uses the same GAT architecture as the joint node encoder. It starts from sentence embeddings of the relevant node text in the main setup, just as ConGraT’s graph component does. Its training objective is to reconstruct adjacency from the node vectors. The authors train it from 30 to 100 epochs, with early stopping on validation AUC, a patience of 3 epochs, and a minimum delta of 0.01. The comparison controls for the graph architecture and the source of initial features while changing how the encoder learns. It is an especially relevant baseline for link prediction because that is the task it is trained to perform.

The text-only baselines start from the same masked and causal encoders used by ConGraT and undergo fine-tuning on each dataset’s training texts for 3 epochs. This comparison asks what the paired graph information contributes beyond further learning from the same domain. The authors also implement graph-informed text baselines. Their LinkBERT implementation uses the same masked starting architecture as the other masked systems. This avoids basing the comparison on a different underlying text encoder and leaves the construction of training examples and the choice of objective as substantial differences.

LinkBERT’s pair construction is adapted to each graph. For Pubmed, a nearby segment means the next sentence of the same abstract, a linked segment comes from an article connected by a citation, and a random segment comes from an article outside that connection. On T-REx the equivalent units are sentences from introductory passages, with hyperlinks supplying the linked examples. On Twitter, two different tweets by the same author serve as the counterpart to contiguous text. For linked pairs the authors use a tweet that mentions another account in the dataset and a tweet from that account. A random pair draws tweets from different accounts. The distinct definitions are important when interpreting the baseline. A Twitter mention used to build a linked training pair is a different relation from a follow edge used by ConGraT.

The authors sample the three relation types evenly for LinkBERT, using 100,000 pairs per type for Pubmed and for Twitter, and 10,000 per type for T-REx. The masked-token and document-relation objectives are fitted for 3 epochs. Since LinkBERT uses masked prediction, its results are compared against the masked ConGraT encoder. Its document-relation head is removed when producing downstream representations.

Social-LM supplies a frozen GAT vector to the text encoder via a special token placed at the beginning of the text. Placing it there makes the added information available to both the causal and masked variants. The graph vector is obtained from the graph autoencoder, and only the text component is subsequently fine-tuned. The authors use the same fine-tuning schedule as for the text-only baseline. Social-LM therefore tests a different way of incorporating network information, by conditioning the text encoder on a fixed graph representation during training.

Predicting categories from either kind of vector

In the classification experiment, the authors fit logistic or softmax regression on the learned embeddings. This asks whether the relevant category can be read from a vector by a simple predictor. In the graph version the input vector represents a node. In the text version it represents a text and is given the label of that text’s source node. For instance, geographic region is an account-level attribute even when the input to the classifier is the vector of a tweet. The authors downsample to balance the classification training data before fitting and use the default L2 regularization of the regression implementation.

The paper reports test-set AUC, the area under the receiver operating characteristic curve. In a binary comparison, it measures how well scores rank positive examples above negative examples as the decision threshold varies. The T-REx experiment reports the average AUC across its several binary label tasks because labels can overlap. The classification setup makes room for separate conclusions about graph and text representations even though the category labels are the same. A useful graph vector can draw on the held-out node’s neighborhood. A useful text vector can carry evidence learned from the graph while being computed from the words of the text.

Pubmed article classification from node embeddings, test-set AUC

The causal ConGraT setting with graph-based targets achieves the highest AUC in this comparison.

Pubmed article classification from node embeddings, test-set AUCGAT autoencoder: 0.956GAT autoencoder0.956Causal ConGraT, α = 0.0: 0.967Causal ConGraT, α = 0.00.967Causal ConGraT, α = 0.1 (this paper): 0.973Causal ConGraT, α = 0.1 (this paper)0.973
The numbers
System or settingAUC
GAT autoencoder0.956
Causal ConGraT, α = 0.00.967
Causal ConGraT, α = 0.1 (this paper)0.973

For Pubmed classification with text embeddings, the causal encoder with graph-based targets reaches 0.969 test-set AUC, compared with 0.931 for its causal text-only baseline. The masked ConGraT variant with the structural term reaches 0.966, with 0.954 for LinkBERT and 0.943 for the masked text-only baseline. The graph and text scores in this experiment come from classification of the same kind of article category using different features. The text-only improvement is consequently evidence about what can be transferred into the text representation, even though the node side had title and abstract features available from the start.

On T-REx, the causal ConGraT graph setting with α = 0.0 attains 0.951 test-set average AUC, compared with 0.939 for GAT. On the text side, the causal setting with α = 0.1 gives 0.931, compared with 0.908 for the causal text-only baseline. The variation between these settings shows why the best choice for a graph embedding need not be the best choice for a text embedding. The two representations share a training objective, but each classifier sees only one side of the resulting space.

Twitter gives a clearer view of the difference between the available signals. With graph embeddings, test-set AUC for political party reaches 0.986 for masked ConGraT with α = 0.1, versus 0.757 for GAT. With tweet embeddings, the corresponding masked setting reaches 0.796, versus 0.769 for the masked text-only baseline. For geographic region, the best graph score is 0.780 test-set AUC, from the causal setting with graph similarity. The best text score is 0.693, from causal ConGraT with α = 0.0. The causal text-only baseline scores 0.587 on that outcome, and masked LinkBERT scores 0.606. The paper uses region to illustrate how the network can contribute information that is hard to read from posts alone.

Across the classification comparisons, the authors report that the best joint setting beats the nearest baseline with bootstrap significance at p < 10⁻⁴. They also report that even the weaker ConGraT comparison beats the baselines in 26 of 28 experiments. The claim is about the reported set of node and text classification comparisons. Individual settings can be sensitive to the encoder, the outcome being predicted, and the form of the graph target. The table of Twitter outcomes makes this pattern visible because age, occupation, political party, and region show different degrees of predictability from language and network structure.

For link prediction, the authors compute an inner product between learned node vectors to score whether an edge exists. This is a different use of the embeddings from the cosine comparison between a node and a text during pretraining. ConGraT’s node encoder receives no further training on the link task. Its performance is therefore called zero-shot for link prediction. The GAT baseline uses the same type of scoring but is trained directly to reconstruct edges.

Twitter link prediction from node vectors, test-set AUC

The strongest ConGraT result exceeds the best directly trained GAT baseline in the main setup.

Twitter link prediction from node vectors, test-set AUCGAT, undirected: 0.713GAT, undirected0.713GAT, directed: 0.723GAT, directed0.723Causal ConGraT, undirected, α = 0.0: 0.791Causal ConGraT, undirected, α = 0.00.791Causal ConGraT, directed, α = 0.0: 0.797Causal ConGraT, directed, α = 0.00.797Causal ConGraT, undirected, α = 0.1: 0.802Causal ConGraT, undirected, α = 0.10.802Masked ConGraT, undirected, α = 0.0 (this paper): 0.806Masked ConGraT, undirected, α = 0.0(this paper)0.806
The numbers
System or settingAUC
GAT, undirected0.713
GAT, directed0.723
Causal ConGraT, undirected, α = 0.00.791
Causal ConGraT, directed, α = 0.00.797
Causal ConGraT, undirected, α = 0.10.802
Masked ConGraT, undirected, α = 0.0 (this paper)0.806

The paper reports the Twitter comparison between the strongest entries as a relative increase of 11.5% in test-set AUC. Pubmed test-set link AUC reaches 0.980 for causal ConGraT with α = 0.1 and 0.979 for the equivalent masked setting, compared with 0.943 for the undirected GAT baseline. On T-REx, masked ConGraT with α = 0.1 reaches 0.957, against an undirected GAT score of 0.927. These results are particularly informative because training with text correspondences could in principle have pulled node vectors away from a geometry useful for edges. Under the principal initialization, the best vectors retain very good edge discrimination.

The broad pattern in the link table is more precise than a claim that every individual joint entry beats every baseline entry. On T-REx, for example, masked ConGraT with α = 0.0 gives 0.908 for undirected edges and 0.897 for directed edges, while the corresponding GAT scores are 0.927 and 0.925. The structural term makes a material difference in that dataset. Twitter provides a complementary result. The strongest masking-based result there occurs without the structural contribution. Thus the best-versus-best comparison and the comparison of a particular fixed configuration answer different questions.

Returning to next-token prediction

For the language experiment, the authors attach a randomly initialized prediction head to the causal ConGraT encoder and train both the encoder and head further to predict the next token. They compare against further training of the baseline DistilGPT-2 on the dataset text. The metric is mean perplexity, which expresses how much probability the predictor assigns to the observed sequence under the next-token objective. A lower value indicates better predictions under that evaluation. Only the causal variant participates in this experiment.

T-REx causal next-token prediction, mean perplexity

Both jointly pretrained settings improve on the text-only baseline, with direct matching alone giving the lowest perplexity here.

T-REx causal next-token prediction, mean perplexityText-only DistilGPT-2: 16.84Text-only DistilGPT-216.84ConGraT, α = 0.0 (this paper): 15.99ConGraT, α = 0.0 (this paper)15.99ConGraT, α = 0.1: 16.07ConGraT, α = 0.116.07
The numbers
System or settingmean perplexity
Text-only DistilGPT-216.84
ConGraT, α = 0.0 (this paper)15.99
ConGraT, α = 0.116.07

On Pubmed the reported mean perplexities are 6.95 for α = 0.0 and 6.94 for α = 0.1, with 6.98 for the causal text-only baseline. On Twitter they are 16.08 and 16.07, compared with 16.44 for the baseline. The table reports mean perplexity for the downstream language evaluation. The authors give a paired t-test result of p < 5.7 × 10⁻⁷ at the 5σ level for their main comparisons. The effect measured here is the contribution of joint pretraining to an encoder that is subsequently adapted for next-token prediction. The prediction head is trained in that adaptation stage.

Finding communities with a textual basis

The community experiment asks how closely a proposed grouping of accounts corresponds to what they write. The authors obtain communities in three ways. Louvain partitions the follow graph directly. The other approaches cluster node embeddings produced by GAT and by ConGraT with α = 0.0. Both embedding-based approaches use UMAP to obtain a lower-dimensional representation and HDBSCAN to identify clusters from it. Keeping the clustering procedure the same for the two sets of node vectors makes the input representation the main difference between those comparisons. UMAP · HDBSCAN

For each account, the authors average the vectors of its texts to get a centroid describing its writing, then assign the account’s community label as the prediction target. They fit logistic regression on the training split and measure test-set AUC for predicting those labels from the centroids. Text predicts Louvain communities poorly, GAT embedding clusters better, and ConGraT embedding clusters best in the reported figure. This order is consistent with the different sources of the community assignments. Louvain uses edges directly, GAT can carry some text signal from its initial features, and ConGraT is explicitly trained to relate node vectors to their writing.

This is an application of the learned embeddings without the graph-based soft targets. Its relevance is that the elementary matching objective already changes which users appear similar when embedded. The outcome measures whether membership can be reconstructed from text. It gives an empirical meaning to the authors’ description of more textually grounded communities, even when there is no externally annotated community assignment to use as a target.

What the ablations show

How much probability to give the graph

The Pubmed sensitivity experiment isolates the mixing setting α by comparing 0.0, 0.1, 0.5, and 1.0. The direct matching term dominates at the low positive setting. At the high endpoint, only the structural distribution supplies target probability. Looking at intermediate values helps distinguish the benefit of introducing related alternatives from the effect of giving them much more influence.

For classification from graph vectors, the test-set AUCs in the sensitivity comparison are 0.967 at 0.0 and 0.973 at 0.1, followed by 0.962 at 0.5 and 0.941 at 1.0. The analogous classification scores from text vectors are 0.962, 0.969, 0.958, and 0.900. The link prediction column has 0.956 at 0.0, 0.979 at 0.1, 0.977 at 0.5, and 0.897 at 1.0. The same broad relationship holds across these probes. Some structural information helps most in this Pubmed comparison, while replacing the direct term produces the lowest joint score for each of these outcomes.

The causal next-token evaluation gives a different ordering. Pubmed mean perplexity is 6.95 at 0.0, 6.94 at 0.1, 6.98 at 0.5, and 6.88 at 1.0. The authors suggest that a target emphasizing similarity across articles may help the text encoder learn regularities of language use shared by documents. That suggestion is an interpretation of the result. The comparison measures perplexity after adaptation, so it does not directly identify which linguistic regularities are responsible. It nevertheless gives a concrete reason to evaluate α against the intended downstream use. The configuration that yields the best token predictions can be different from the one that yields the best categories or links.

The main tables add variation across datasets and outcomes. In T-REx link prediction, introducing the soft targets helps both text-encoder variants trained on undirected graphs. In Twitter link prediction, the masked undirected variant instead reaches its best score at α = 0.0. Similarly, adding structure improves some Twitter classification outcomes while reducing others. For the causal graph encoder, the structural term raises region AUC from 0.755 to 0.780 but reduces gender AUC from 0.811 to 0.803. The soft target transfers a specific definition of relatedness. Whether that definition helps depends on how closely neighborhood similarity tracks the property being evaluated.

Direction can also be examined at α = 0.0, where the objective itself does not use a graph similarity distribution. The Twitter causal link AUCs of 0.791 for undirected edges and 0.797 for directed edges are close. On T-REx the causal values are 0.899 and 0.902. In the masked setting, the direction of the comparison reverses in both datasets. The results support using the direct matching procedure with either edge convention, with differences tied to the setting. Since directed runs never use positive α, these experiments cannot isolate the effects of direction and graph-dependent targets together.

How the geometry changes

The paper compares jointly trained representations with spaces learned separately by the GAT and text-only baselines. Its first diagnostic compares the distance between two text embeddings with the distance between the nodes those texts came from. For an article pair, for example, there are two distinct questions. Are the passages close as pieces of text, and are the corresponding articles close as nodes? The experiment takes cosine distances within each space and correlates them across sampled pairs.

The reported correlations increase for all encoder variants and datasets, with p < 10⁻⁶ by the authors’ bootstrap test. For directed causal Pubmed, the inter-embedding correlation is 0.682 for joint training and 0.100 for separately trained representations. For directed causal T-REx, it is 0.650 versus 0.038. For directed causal Twitter, it is 0.319 versus 0.035. The absolute values differ across datasets, which is informative alongside the common increase. Joint training strongly changes the degree to which a pair of texts and their source nodes occupy similar relative positions, while the strength of that relationship varies with the data.

A second diagnostic compares text-space distance with a structural measure computed directly from the graph, using SimRank. This has a different purpose from comparing two learned spaces. If joint training makes both encoders respond to some common property, their distances may agree even if that property has only a weak relationship to network structure. Comparing with SimRank supplies an independent structural reference. The paper reports a significant increase over the separate spaces in 34 out of 36 cases at the p = 10⁻⁶ level. The result concerns the relation between text geometry and the network measure. The graph-aware loss used its mutual-neighbor-based calculation to build targets, while SimRank enters this diagnostic.

The retrieval experiment asks a more direct question about the common space. Given a text, the procedure ranks the candidate nodes by cosine similarity to that text and checks whether its source appears among the top k, using k from 1 to 10. For the Pubmed test graph, which contains 1,996 article nodes, the best joint setting places the correct article in its top 10 candidates 94.3% of the time. The paper describes those candidates as 0.5% of the test set. Joint settings outperform separate encoders throughout the reported retrieval curves, with the differences significant at p = 10⁻⁶ under a bootstrap test.

Retrieval directly reuses the direction of matching trained by the loss. Its additional value is that the candidate pool is much larger than a training batch and consists of held-out nodes. The comparison with separately trained spaces also makes a distinction between equal dimensionality and actual registration. The separate vectors can each support tasks within their own space, but cosine comparison across those spaces requires the coordinates to have acquired a related meaning. Joint training gives their cross-space scores that interpretation. The experiment establishes it for recovering the known source of a text.

The authors also illustrate the geometry with a 2D UMAP projection of accounts labeled by U.S. political party. They compare GAT with ConGraT at α = 0.0. Democrats and Republicans form more clearly distinguishable groups in the ConGraT projection. That visualization gives a qualitative view of the classification result. The test-set AUC from the original representations supplies the quantitative evidence because the displayed projection reduces the dimensionality and can change distances.

What changes when nodes start from structure alone

The initial node vectors in the principal experiments are derived from text. The authors therefore rerun the analysis after replacing them with vectors from a truncated singular value decomposition, or SVD, of the adjacency matrix. This represents patterns of connectivity in a lower-dimensional space. The authors retain 768 dimensions to match the size of the sentence embeddings. They use the basis obtained on the training set when constructing test features. In the appendix’s description, the test features use the connections from test nodes to training nodes for this projection. This is a different feature construction from the main disjoint-graph condition, and matters when comparing the two setups.

Best-setting classification advantages persist with the structural initialization. On Pubmed, the masked ConGraT setting with α = 0.1 scores 0.878 test-set AUC from node vectors, while GAT scores 0.600. From text vectors, the causal joint setting at α = 0.1 produces 0.961, compared with 0.931 for the causal text-only baseline. On the Twitter region outcome, the masked joint setting with α = 0.1 yields 0.774 test-set AUC from graph embeddings and the GAT baseline yields 0.706. Twitter political party is omitted from this results table. The authors report that the structural vectors let the graph and joint encoders separate the party classes perfectly, making that outcome uninformative for discriminating among them.

Link prediction retains substantial signal, but the baseline comparison is sensitive to the initialization. On the undirected Pubmed data, the masked joint setting at α = 0.1 reaches 0.990 test-set AUC, versus 0.866 for GAT. On T-REx the undirected causal setting at α = 0.1 gives 0.925, versus 0.839 for GAT. On Twitter, however, the undirected GAT baseline reaches 0.875 while the undirected masked ConGraT entry without graph-based targets is 0.805. The directed Twitter GAT score is 0.838, compared with 0.826 for the directed masked joint setting. The authors observe that the Twitter baseline benefits strongly from SVD initialization while ConGraT’s scores remain close to their earlier levels. This is a case where the initialization changes the outcome of the comparative claim without removing the link signal in the joint vectors.

The SVD language results also qualify the main table. On Pubmed both causal joint settings give mean perplexity of 7.03, against 6.98 for the text-only baseline. On T-REx the α = 0.0 setting gives 17.42, above the baseline’s 16.84, whereas α = 0.1 gives 15.62. Both tested Twitter joint settings give 16.05 against the baseline’s 16.44. Changing the graph encoder’s starting input can therefore affect downstream token prediction even though that task ultimately uses the text component. The controlled change supports the authors’ claim that the text encoder learns from the graph component. It also shows that a stronger result on every language dataset depends on the specific training setup.

Limitations

Limits the authors identify

The paper leaves graph-based smoothing for directed edges open. Its positive-α experiments use undirected graphs because the authors have not selected and validated a similarity function that respects edge direction. This matters in a citation graph, where citing an article and being cited by it have distinct meanings. The direct matching objective can be used with directed edges and is evaluated that way. The evidence for the structural distribution, however, comes from graphs whose edge directions have been discarded for those runs.

The authors also leave the returns to larger batches for future work. Each batch incurs pairwise comparison costs, and the number of candidate alternatives in the loss is limited by the number of positions the hardware can accommodate. The reported batch size of 36 establishes one practical operating point. It does not establish how quickly performance improves with more candidates, or how effective the duplicate-avoidance procedure remains on collections with even more uneven numbers of texts per node. The training appendix also reports sensitivity to gradient spikes, learning rate, and numerical overflow. The published hyper-parameters describe how the authors made their chosen setup work.

The graph-aware objective is motivated by homophily, the tendency for related nodes to resemble one another. The authors expect the similarity term to be valuable when network neighbors or structurally similar nodes have comparable texts. The Pubmed sensitivity experiment shows that the setting can affect tasks differently. Whether the assumption transfers to a graph where edges frequently connect very different kinds of entities depends on what those edges mean and how the similarity score handles them.

Limits of the evidence

The main inductive protocol shows transfer to held-out parts of the same constructed datasets. It keeps the graph type, the definition of a node, and the rules for attaching texts fixed when forming each train and test partition. There is no experiment in which an encoder trained on one of these domains is evaluated unchanged on another. The choice of encoders is also narrower than the general formulation. The adapter makes other architectures possible, while the experiments use two text initializations and a common GAT node encoder.

The link prediction scores show that an inner-product decoder is useful on the learned test-graph representations. The node encoder itself takes graph structure as an input. Zero-shot in this context means that ConGraT receives no additional link-specific training, and should be interpreted with that meaning. Results from the SVD check have the further qualification that the appendix describes test features based on connections to training-set nodes. Fitting the SVD basis on the training data and applying it to those connections is a different setup from evaluating a node encoder using only the separate test graph. The main results and the robustness results thus test related, but distinct, notions of what structural information is available.

The classification probes use the study’s available labels and inherit their scope. The Pubmed task is about article categories in diabetes research. The T-REx label set comes from a selected part of Wikipedia and was chosen for relatively high frequency and low overlap after expanding the hierarchy. The Twitter accounts are influential public figures, and classification targets reflect information that can be matched to profile data and external records. This supports comparisons for these outcomes. A high region or party AUC in this collection gives no estimate of performance for ordinary accounts or for other classifications of geography and political identity.

The community experiment measures alignment with text by predicting discovered community labels from writing. It has no independent reference for which partition best represents the users’ relationships or interests. Community labels also differ by detection procedure, so greater predictability from text establishes that the label assignment is more recoverable from text features. It leaves questions about the usefulness or interpretation of particular communities to an evaluation with that separate aim.

The retrieval experiment uses the known source node as the answer and compares with independently learned spaces. This is a direct test of the intended alignment. It gives less information about an open-ended search in which several nodes might be relevant, or in which a query is formulated differently from the texts attached to the graph. Likewise, lower next-token perplexity following downstream adaptation establishes improvement on the reported token prediction objective. That experiment supplies no direct measurement of the quality of longer generated outputs or of performance for the masked encoders on an equivalent language task.

Finally, the main baselines establish comparative gains under their tested objectives and features. ConGraT’s graph encoder begins with text features in the principal runs, and the GAT baseline uses those features too. The SVD comparison helps isolate the contribution of changing that initial input, while also showing that it can improve the graph-only competitor substantially. Across the experiments, the observed benefits concern a joint objective, a choice of initialization, and a particular training and evaluation regime. The ablations give evidence for contributions from both the direct attachment and the structural weighting, with their relative effects depending on the task.

What came after

LightRAG belongs to the literature on retrieval-augmented generation. Its title identifies a goal of making retrieval-augmented generation simple and fast, and the work cites ConGraT. The connection is a shared interest in using information associated with text to support retrieval. ConGraT itself tests retrieval of a known source node from its text, a more specific objective than supplying context for generation. The citation establishes the relationship between the papers, while the available description leaves open whether LightRAG uses ConGraT’s joint embedding procedure or its graph-based target distribution. LightRAG

Text-Attributed Graph Learning with Coupled Augmentations cites ConGraT in the same setting of learning from texts attached to graph nodes. Its title identifies coupled augmentations as the focus. ConGraT provides a point of comparison because it couples the modalities through observed node–text pairs and, optionally, through the probability assigned to alternative pairs. The later work’s title identifies augmentation as the mechanism it studies, while leaving the details of the transformations and the use of ConGraT’s objective unspecified. Text-Attributed Graph Learning with Coupled Augmentations

Cite

Cite as William Brannon, Wonjune Kang, Suyash Fulay, Hang Jiang, Brandon Roy, Deb Roy and Jad Kabbara. 2024. ConGraT: Self-Supervised Contrastive Pretraining for Joint Graph and Text Embeddings. Proceedings of TextGraphs-17: Graph-based Methods for Natural Language Processing.

The paper itself, not this page. BibTeX from the library's record of the work.

@inproceedings{brannon2024congrat,
  title = {{ConGraT: Self-Supervised Contrastive Pretraining for Joint Graph and Text Embeddings}},
  author = {William Brannon, Wonjune Kang, Suyash Fulay, Hang Jiang, Brandon Roy, Deb Roy and Jad Kabbara},
  booktitle = {Proceedings of TextGraphs-17: Graph-based Methods for Natural Language Processing},
  year = {2024},
  url = {https://aclanthology.org/2024.textgraphs-1.2/}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/brannon-2024-congrat-self-supervised-contrastive-pretraining/