Inferensys

Glossary

TextRank

An unsupervised, graph-based ranking algorithm that builds a word or phrase co-occurrence network from a document and applies a PageRank variant to identify the most salient keyphrases and sentences.
Knowledge engineer constructing knowledge base on laptop, document hierarchy visible, casual office setup.
GRAPH-BASED KEYPHRASE EXTRACTION

What is TextRank?

TextRank is an unsupervised, graph-based ranking algorithm that builds a word or phrase co-occurrence network from a document and applies a PageRank-derived iterative scoring mechanism to identify the most salient keyphrases.

TextRank models a document as a co-occurrence graph where vertices represent lexical units (words or phrases) and weighted edges represent their collocation within a defined sliding window. The algorithm initializes all vertices with equal scores and iteratively updates them using the PageRank formula until convergence, effectively identifying central nodes that act as 'recommenders' for other important terms. Unlike supervised methods, it requires no labeled training data.

The algorithm's strength lies in its ability to capture global structural salience rather than just local frequency. By ranking phrases based on their connectivity within the entire text network, TextRank naturally filters out high-frequency but semantically weak terms. It is widely used for unsupervised keyphrase extraction and automatic summarization, often serving as a robust baseline against which embedding-based methods like EmbedRank are compared.

Graph-Based Ranking

Core Characteristics of TextRank

TextRank is a graph-based ranking algorithm for unsupervised keyphrase extraction that models a document as a co-occurrence network and applies PageRank to identify the most salient phrases.

01

Graph-Based Ranking Model

TextRank constructs a co-occurrence graph where vertices represent words or phrases, and edges are weighted by their co-occurrence frequency within a sliding window. The algorithm then applies a recursive PageRank-style computation to score each vertex based on the importance of its neighbors. The core formula iterates until convergence:

S(Vi) = (1 - d) + d * Σ (w_ji / Σ w_jk) * S(Vj)

  • d: Damping factor (typically 0.85), controlling the probability of jumping to a random vertex
  • w_ji: Weight of the edge between vertex j and vertex i
  • Convergence: Scores stabilize when the difference between iterations falls below a threshold
02

Unsupervised and Domain-Independent

TextRank requires no labeled training data and operates independently of domain-specific corpora. It relies solely on the intrinsic structure of the input document:

  • No external knowledge bases: Unlike Wikification approaches, TextRank does not require Wikipedia or ontologies
  • Language agnostic: Works on any language with tokenization and POS tagging support
  • Single-document processing: Extracts keyphrases from one document at a time without needing a background corpus
  • Bootstrapping: Uses the document's own lexical cohesion patterns to determine salience
03

Candidate Phrase Filtering

Before graph construction, TextRank applies syntactic filters to select candidate phrases. The original implementation uses part-of-speech (POS) tag patterns to extract noun phrases:

  • Pattern: Sequences of zero or more adjectives followed by one or more nouns (JJ)*(NN)+
  • Stopword handling: Stopwords are excluded from candidate phrases but preserved for co-occurrence context
  • Multi-word phrases: Post-processing merges adjacent single-word candidates that appear consecutively in the text
  • Filtering rationale: Restricts the graph to content-bearing terms, reducing noise and computational complexity
04

Post-Processing and Ranking

After the PageRank scores converge, TextRank applies post-processing steps to produce the final ranked keyphrase list:

  • Phrase merging: Adjacent single-word candidates with high individual scores are combined into multi-word phrases
  • Score aggregation: The score of a merged phrase is the sum of its constituent word scores
  • Top-K selection: The highest-scoring phrases are returned, typically the top 10-20 candidates
  • Redundancy control: Unlike MMR-based approaches, TextRank does not explicitly penalize redundancy, which can lead to semantically overlapping keyphrases
05

TextRank for Summarization

Beyond keyphrase extraction, TextRank extends naturally to extractive summarization by treating sentences as vertices:

  • Sentence graph: Vertices are sentences; edges are weighted by inter-sentence similarity (e.g., TF-IDF cosine or lexical overlap)
  • Similarity threshold: Edges are only created when similarity exceeds a minimum threshold, preventing a fully connected graph
  • Ranking: PageRank identifies the most central sentences that collectively represent the document's core content
  • Multi-document variant: Can be applied across document clusters by building a unified sentence graph
06

Strengths and Limitations

TextRank offers a compelling balance of simplicity and effectiveness, but has known trade-offs:

Strengths:

  • No training required: Fully unsupervised, deployable on any text immediately
  • Interpretable: Graph structure and scores are transparent and auditable
  • Lightweight: Minimal computational overhead compared to embedding-based methods like KeyBERT

Limitations:

  • Cannot extract absent keyphrases: Only identifies phrases present verbatim in the text
  • Frequency bias: Favors frequently occurring terms, potentially missing rare but salient concepts
  • No semantic understanding: Relies on surface co-occurrence rather than deep contextual meaning
UNSUPERVISED ALGORITHM COMPARISON

TextRank vs. Other Keyphrase Extraction Methods

A feature-level comparison of TextRank against other widely used unsupervised keyphrase extraction algorithms, highlighting architectural differences and operational characteristics.

FeatureTextRankTF-IDFRAKEYAKE

Core Mechanism

Graph-based ranking (PageRank on co-occurrence network)

Statistical weighting (term frequency × inverse document frequency)

Stopword-delimited phrase scoring (word degree/frequency ratio)

Statistical feature scoring (5 features from single document)

Requires External Corpus

Handles Multi-word Phrases

Language Independence

POS Tagging Required

Typical Precision@10 on Inspec

31.2%

24.7%

28.6%

33.8%

Computational Complexity

O(|V|²) per iteration (graph construction + PageRank convergence)

O(N) (linear scan of term frequencies)

O(N) (single pass with sliding window)

O(N) (single pass with sliding window)

Sensitivity to Document Length

Moderate (graph density increases with length)

High (short documents produce sparse vectors)

Low (window-based co-occurrence is robust)

Low (normalized statistical features)

TEXTRANK EXPLAINED

Frequently Asked Questions

Clear, technically precise answers to the most common questions about the graph-based keyphrase extraction algorithm.

TextRank is an unsupervised, graph-based ranking algorithm for extracting keyphrases and summarizing text. It operates by building a co-occurrence graph where vertices represent words or phrases, and weighted edges represent the strength of their association within a sliding window. The algorithm then applies a modified PageRank iterative convergence process to score each vertex based on the principle of 'voting' or 'recommendation'—a vertex is important if it is linked to by other important vertices. Unlike supervised methods, TextRank requires no labeled training data, relying solely on the structural properties of the text itself. After convergence, the top-ranked vertices are post-processed to form the final multi-word keyphrases.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.