TextRank is an unsupervised, extractive summarization and keyword extraction algorithm that models a document as a semantic graph. In this graph, vertices represent lexical units (words or sentences), and edges represent co-occurrence relations defined by a sliding window. The algorithm applies a recursive, iterative voting mechanism derived from PageRank to score the importance of each vertex until convergence, surfacing the most salient terms or sentences without requiring prior training data.
Glossary
TextRank

What is TextRank?
TextRank is a graph-based ranking algorithm for natural language processing that identifies the most important sentences or keywords in a document based on their co-occurrence links.
Unlike supervised methods that rely on annotated corpora, TextRank exploits the inherent structure of the text itself. For keyword extraction, vertices are filtered to retain only nouns and adjectives, and edges connect words appearing within a window of N tokens. For sentence extraction, vertices represent full sentences, and edges are weighted by semantic similarity—typically cosine similarity of TF-IDF vectors. The final ranking identifies the sentences that best represent the document's core themes for extractive summarization.
Key Features of TextRank
TextRank adapts Google's PageRank algorithm to natural language, constructing graphs from text units and iteratively scoring them based on co-occurrence links to identify the most salient sentences or keywords.
Graph Construction from Co-occurrence
TextRank builds a graph where vertices represent text units (sentences or words) and edges represent co-occurrence within a defined window. For keyword extraction, a window of N words slides across the text, linking all words that appear together. For sentence extraction, edges connect sentences with overlapping lexical content. This unsupervised approach requires no labeled training data, making it domain-agnostic and immediately applicable to any language or corpus.
Iterative Convergence Scoring
The algorithm initializes all vertices with a default score of 1 and iteratively updates each vertex's score using the weighted sum of its neighbors' scores until convergence (typically when the change between iterations falls below a threshold of 0.0001). The damping factor—usually set to 0.85—prevents rank sinks and ensures convergence. The final score of a vertex represents its global salience within the entire graph, not just local prominence.
Keyword Extraction Variant
For keyword extraction, TextRank filters candidate words to retain only nouns and adjectives after part-of-speech tagging. Words that are adjacent in the filtered sequence form multi-word keyphrases. The top T vertices by final score are selected as the document's key terms. This variant outperforms TF-IDF on tasks requiring semantic coherence because it captures structural relationships rather than relying solely on raw frequency statistics.
Extractive Summarization Variant
For sentence extraction, TextRank treats each sentence as a vertex and computes edge weights based on content overlap—typically the number of shared lexical tokens normalized by sentence length. This penalizes long sentences that accumulate high overlap purely due to length. The top-ranked sentences are selected in their original order to form an extractive summary, preserving the document's narrative flow without generating new text.
Undirected vs. Directed Graph Variants
The original TextRank uses undirected, weighted graphs where edge weights are symmetric, reflecting the reciprocal nature of co-occurrence. However, directed variants exist that incorporate forward-looking context—edges point from earlier to later text units within the window—to model the sequential nature of language. Directed graphs can better capture discourse structure but introduce sparsity and require careful tuning of the damping factor to maintain convergence guarantees.
Advantages Over Supervised Methods
TextRank's primary advantage is its language independence and domain portability. Unlike supervised extractors that require expensive annotated corpora, TextRank operates on raw text alone. It also naturally handles redundancy reduction—the graph-based scoring inherently penalizes duplicate information because vertices that are highly similar to already high-scoring vertices receive diminished marginal contribution, a property analogous to Maximum Marginal Relevance (MMR) without requiring a separate diversity mechanism.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about the graph-based ranking algorithm for keyword and sentence extraction.
TextRank is a graph-based ranking algorithm for natural language processing that identifies the most important sentences or keywords in a document by modeling text as a network of co-occurrence links. It works by building a graph where vertices represent lexical units (words or sentences) and edges represent co-occurrence relationships within a defined window. The algorithm then applies a recursive, PageRank-inspired scoring mechanism where the importance of a vertex is determined by the number and quality of incoming connections. The process iterates until convergence, producing a ranked list of the most salient elements without requiring any prior training data or language-specific resources, making it a fully unsupervised, domain-independent method.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core algorithms and concepts that form the mathematical and linguistic backbone of the TextRank graph-based ranking approach to keyword and sentence extraction.
PageRank
The foundational link analysis algorithm from which TextRank is directly derived. PageRank models the web as a directed graph where pages are nodes and hyperlinks are edges. It computes a recursive importance score based on the principle that a node is important if it is linked to by other important nodes, using a random surfer model with a damping factor (typically 0.85) to prevent rank sinks.
- Formula: PR(A) = (1-d) + d * Σ(PR(Ti)/C(Ti))
- Converges iteratively until scores stabilize
- TextRank adapts this by replacing hyperlinks with lexical co-occurrence edges
TF-IDF
A classical bag-of-words weighting scheme that quantifies term importance by multiplying Term Frequency (how often a word appears in a document) by Inverse Document Frequency (how rare the word is across the corpus). Unlike TextRank, TF-IDF is purely statistical and ignores word order, context, and semantic relationships.
- IDF = log(N / df(t))
- Requires a reference corpus for IDF calculation
- TextRank often outperforms TF-IDF for keyphrase extraction because it captures co-occurrence structure rather than raw frequency
BM25
A probabilistic relevance ranking function that extends TF-IDF with document length normalization and term frequency saturation. BM25 is the default retrieval algorithm in Elasticsearch and Lucene. While BM25 excels at document ranking for queries, TextRank operates on a single-document graph and identifies salient terms without requiring a query.
- k1 controls term frequency saturation (default 1.2)
- b controls length normalization (default 0.75)
- Both BM25 and TextRank can be combined in hybrid retrieval pipelines
Maximum Marginal Relevance (MMR)
A redundancy-penalizing selection algorithm used in extractive summarization to build a ranked list where each new item balances query relevance against novelty relative to already-selected items. TextRank's sentence extraction can be paired with MMR as a post-processing step to ensure the top-ranked sentences are not repetitive.
- MMR = argmax[λ * Sim(Di, Q) - (1-λ) * max(Sim(Di, Dj))]
- λ parameter controls the relevance-novelty trade-off
- Often applied after TextRank scoring to diversify summaries
Keyphrase Extraction
The NLP task of automatically identifying the most representative multi-word expressions from a document. TextRank approaches this by building a graph where candidate phrases (filtered by Part-of-Speech patterns) are nodes, and edges connect phrases that co-occur within a sliding window.
- Common POS filter: (JJ)*(NN|NNP|NNS)+
- Alternatives include RAKE (Rapid Automatic Keyword Extraction) and YAKE
- TextRank's graph-based approach captures topical centrality rather than just frequency
Dependency Parsing
A syntactic analysis technique that identifies binary grammatical relations between words in a sentence, producing a directed tree structure. Advanced TextRank variants replace simple co-occurrence windows with dependency-based edges, connecting words that share a syntactic relationship rather than mere proximity.
- Relations include nsubj, dobj, amod, etc.
- Produces sparser, more linguistically meaningful graphs
- Improves precision for entity-centric salience scoring by filtering noise from window-based co-occurrence

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us