Inferensys

Glossary

Keyphrase Generation

Keyphrase generation is the NLP task of using sequence-to-sequence models to produce both present and absent keyphrases for a given source text.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
DEFINITION

What is Keyphrase Generation?

Keyphrase generation is the task of automatically producing a set of concise phrases that summarize a document's core topics, including both phrases present in the text and those that are absent but conceptually relevant.

Keyphrase generation is a sequence-to-sequence (seq2seq) modeling task that predicts a set of salient phrases—both present keyphrases (verbatim spans) and absent keyphrases (conceptual labels not in the text)—from a source document. Unlike extraction-only methods, it formulates the problem as conditional natural language generation, often using Transformer-based encoder-decoder architectures trained on large-scale datasets like KP20k.

The model learns to attend to the source context and generate a delimited sequence of keyphrases, addressing the one-to-many mapping between a document and its topics. This approach inherently handles synonym generation and abstraction, evaluating output quality using metrics like F1@K and Mean Reciprocal Rank (MRR) against author-assigned gold standards.

GENERATIVE NLP

Core Characteristics of Keyphrase Generation

Keyphrase generation is a sequence-to-sequence modeling task that produces both present and absent keyphrases, moving beyond extraction to synthesize novel, highly relevant terms for a source text.

01

Sequence-to-Sequence Architecture

The foundational architecture for keyphrase generation is the encoder-decoder framework. The encoder (e.g., a Transformer) reads the source document and compresses it into a dense context vector. The decoder then autoregressively generates a sequence of keyphrases, one token at a time, often separated by a delimiter.

  • One2Seq: A seminal model that generates multiple keyphrases in a single sequence.
  • Copy Mechanism: Allows the decoder to copy rare or out-of-vocabulary words directly from the source text, crucial for generating present keyphrases accurately.
  • Target: NLP Engineers building custom generation pipelines.
02

Present vs. Absent Keyphrase Generation

A key distinction in generation is the model's ability to produce two types of keyphrases. Present keyphrases appear verbatim in the source text, while absent keyphrases are semantically relevant but do not exist as contiguous spans.

  • Present Generation: Relies heavily on a copy mechanism to point to tokens in the source.
  • Absent Generation: Requires the model to synthesize new phrases from its learned vocabulary, demanding a deeper semantic understanding of the text.
  • Evaluation: Models are often benchmarked on F1@K for both present and absent subsets separately.
03

One2Set Training Paradigm

Traditional Seq2Seq models impose an artificial order on the target keyphrase set, which is inherently unordered. The One2Set paradigm addresses this by removing the order bias.

  • Set Loss: Uses a loss function like the K-step target assignment loss that is permutation-invariant, aligning predicted phrases with the most similar ground-truth phrases.
  • Control Codes: Models like CatSeq use control codes to indicate the presence or absence of a keyphrase, guiding the decoder's generation mode.
  • Benefit: Prevents the model from learning spurious sequential correlations between unrelated keyphrases.
04

Hierarchical Decoding

To capture the structural relationship between a document and its keyphrases, hierarchical models process text at multiple granularities. A hierarchical encoder first builds sentence-level representations, then aggregates them into a document-level vector.

  • Hierarchical Attention: The decoder can attend to both word-level and sentence-level context, improving the relevance of generated phrases.
  • Title Guidance: Some architectures encode the document title separately and use it as an additional signal to the decoder, as titles often contain the most salient concepts.
  • Use Case: Highly effective for long-form scientific documents where keyphrases summarize distinct sections.
05

Reinforcement Learning for Keyphrase Diversity

A common failure mode is generating repetitive or near-duplicate keyphrases. Reinforcement Learning (RL) can be used to directly optimize for diversity and coverage.

  • Self-Critical Sequence Training (SCST): Uses the model's own output as a baseline to reduce variance during RL training.
  • Reward Shaping: Combines F1 score (relevance) with a repetition penalty or semantic diversity metric to encourage a varied set of keyphrases.
  • Result: Produces a more comprehensive set of keyphrases that covers different facets of the document.
06

Evaluation Metrics

Keyphrase generation is evaluated against a gold-standard set of author-assigned or expert-curated keyphrases. The primary metrics are precision, recall, and F1-score computed on the top-K predictions.

  • F1@5 / F1@10: The harmonic mean of precision and recall for the top 5 or 10 generated keyphrases. This is the standard benchmark.
  • Mean Reciprocal Rank (MRR): Measures the rank of the first correct keyphrase, useful when the order of generation matters.
  • Stemming/Levenshtein: Exact match is too strict; evaluation often uses Porter Stemming or a Levenshtein distance threshold to count near-matches as correct.
TASK COMPARISON

Keyphrase Generation vs. Keyphrase Extraction

A technical comparison of generative sequence-to-sequence models against traditional extraction methods for identifying document keyphrases.

FeatureKeyphrase GenerationKeyphrase Extraction

Core Mechanism

Sequence-to-sequence generation

Ranking and selection from candidate set

Produces Absent Keyphrases

Produces Present Keyphrases

Requires Candidate Generation Step

Output Format

Free-text sequences

Spans from source text

Training Data Requirement

Parallel text-keyphrase pairs

Labeled spans or unsupervised

Primary Architecture

Transformer encoder-decoder

Graph ranking or embedding similarity

Typical Evaluation Metric

F1@K, MRR

F1@K, MRR

KEYPHRASE GENERATION

Frequently Asked Questions

Explore the mechanics of sequence-to-sequence models that produce both present and absent keyphrases, moving beyond extraction to true generation.

Keyphrase generation is a sequence-to-sequence (seq2seq) task where a model produces a set of keyphrases—both present keyphrases that appear verbatim in the source text and absent keyphrases that do not—that capture the document's core topics. Unlike keyphrase extraction, which is limited to selecting contiguous spans from the input, generation models can synthesize novel, abstractive phrases. This is typically framed as a conditional text generation problem: given a source document x, the model learns to predict a target sequence y consisting of delimited keyphrases. Architectures like BART, T5, and Pegasus are fine-tuned on datasets such as KP20k to perform this task. The critical distinction lies in the model's ability to reason about the document's semantics and produce multi-word expressions that are conceptually relevant but lexically absent, such as generating 'neural network optimization' when the text only mentions 'backpropagation' and 'gradient descent'.

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.