Skip to main content
QUICK REVIEW

[Paper Review] Pointer Networks

Oriol Vinyals, Meire Fortunato|arXiv (Cornell University)|Jun 9, 2015
Machine Learning and Data ClassificationComputer Science134 citations
TL;DR

This paper introduces Pointer Networks (Ptr-Nets), a neural architecture that uses attention mechanisms to dynamically select output tokens from an input sequence, enabling variable-sized output dictionaries. The model learns to solve combinatorial optimization problems like convex hulls, Delaunay triangulations, and the TSP by predicting indices of input points, achieving strong generalization beyond training lengths and outperforming baselines on small-scale TSP tasks.

ABSTRACT

We introduce a new neural architecture to learn the conditional probability of an output sequence with elements that are discrete tokens corresponding to positions in an input sequence. Such problems cannot be trivially addressed by existent approaches such as sequence-to-sequence and Neural Turing Machines, because the number of target classes in each step of the output depends on the length of the input, which is variable. Problems such as sorting variable sized sequences, and various combinatorial optimization problems belong to this class. Our model solves the problem of variable size output dictionaries using a recently proposed mechanism of neural attention. It differs from the previous attention attempts in that, instead of using attention to blend hidden units of an encoder to a context vector at each decoder step, it uses attention as a pointer to select a member of the input sequence as the output. We call this architecture a Pointer Net (Ptr-Net). We show Ptr-Nets can be used to learn approximate solutions to three challenging geometric problems -- finding planar convex hulls, computing Delaunay triangulations, and the planar Travelling Salesman Problem -- using training examples alone. Ptr-Nets not only improve over sequence-to-sequence with input attention, but also allow us to generalize to variable size output dictionaries. We show that the learnt models generalize beyond the maximum lengths they were trained on. We hope our results on these tasks will encourage a broader exploration of neural learning for discrete problems.

Motivation & Objective

  • To address the limitation of sequence-to-sequence models in handling variable-sized output dictionaries, where the number of possible output classes depends on input length.
  • To develop a neural architecture capable of learning discrete, combinatorial sequence generation tasks where outputs are indices from the input sequence.
  • To demonstrate that a data-driven neural approach can learn approximate solutions to NP-hard geometric problems such as convex hulls, Delaunay triangulations, and the symmetric TSP.
  • To show generalization of the model to input lengths beyond those seen during training, particularly for problems with structured output sequences.
  • To establish that attention can be repurposed as a 'pointer' to input elements, enabling end-to-end learning without fixed output vocabularies.

Proposed method

  • The model uses an encoder RNN (LSTM) to encode the input sequence into a context vector, which is then used to guide a decoder RNN.
  • At each decoder step, a content-based attention mechanism computes a softmax over the input sequence positions, effectively acting as a pointer to select the next output token.
  • The output is a sequence of indices corresponding to positions in the input sequence, rather than fixed-class outputs, enabling variable-sized output dictionaries.
  • The model is trained end-to-end by maximizing the log-likelihood of ground-truth output sequences using stochastic gradient descent.
  • Beam search with validity constraints is applied during inference for the TSP task to prevent invalid tours (e.g., repeated or missing cities).
  • The architecture is applied to three geometric problems: planar convex hulls, Delaunay triangulations, and symmetric TSP, using synthetic training data generated via exact algorithms.

Experimental results

Research questions

  • RQ1Can a neural network learn to generate sequences of indices from an input sequence without a fixed output vocabulary?
  • RQ2Can such a model generalize to longer input sequences than seen during training, particularly for combinatorial problems?
  • RQ3Can a purely data-driven approach learn competitive approximate solutions to NP-hard problems like the TSP?
  • RQ4Does using attention as a pointer to input positions outperform standard sequence-to-sequence models with attention for variable-dictionary tasks?
  • RQ5To what extent can the model learn complex geometric relationships such as convex hulls and Delaunay triangulations from training examples alone?

Key findings

  • The Ptr-Net achieved 100% accuracy on convex hull prediction for inputs up to n=50, generalizing beyond the training length of n=20.
  • For Delaunay triangulation, the model achieved 52.8% triangle coverage on n=50 inputs, demonstrating meaningful generalization despite not reaching full correctness.
  • On the TSP, the model trained on optimal data for n≤20 generalized well to n=25 and n=30, with tour lengths within 1.5% of optimal, but performance degraded at n=40 and n=50.
  • When trained on suboptimal algorithm data (e.g., A1), the Ptr-Net outperformed the original algorithm, showing it can learn better heuristics from data.
  • The model significantly outperformed standard sequence-to-sequence with attention on fixed-length problems, confirming its effectiveness even in constrained settings.
  • The architecture generalizes beyond training lengths, particularly for problems with lower algorithmic complexity (e.g., O(n log n)), but struggles with higher-complexity problems like TSP at larger scales.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.