Part V · PageRank, Search, and Information Retrieval

Chapter 16

PageRank Through the Lens of Grammar

mixed One proposed model (the grammar-constrained surfer) with proved basic properties and measured costs; its novelty and usefulness are open. Everything else is a re-reading of established results.

Learning objectives
  • Read the random surfer as an operational grammar with probabilistic semantics.
  • Define the grammar-constrained surfer, prove its basic properties, and state its cost.
  • Interpret its measured effect on rankings, and say what would be needed to show that it is useful.
  • Place host/block structure, ordering and incremental updates in the mechanism taxonomy.
  • List what the grammatical view does not provide for PageRank.

16.1 The surfer as a grammar

The random surfer of Chapter 15 has two moves, follow and teleport, applied at random. As an operational grammar its states are pages, its moves are relations — follow maps uu to its out-neighbours, teleport maps uu to every page — and its semantics is probabilistic: each move carries a probability distribution over successors instead of a set. The PageRank vector is the long-run frequency with which the moves’ composition visits each page. Nothing is gained by renaming the model; the reason to read it this way is that the operational-grammar toolkit of Part II — and in particular admissibility languages and the product construction — applies to it directly.

16.2 Constraining the surfer

On a graph whose links carry labels (a citation that supports or refutes, a link between people that is colleague or family, a hyperlink in navigation or content), one may want a ranking driven only by certain patterns of links. Admissibility languages express such patterns, and the product construction of Chapter 8 turns them into a Markov chain.

Definition 16.1 (Grammar-constrained random surfer)CGT-PROP-010

Let GG be an edge-labelled graph on nn vertices, D=(Q,Σ,δ,q0,F)D = (Q, \Sigma, \delta, q_0, F) a DFA over labels (all states treated as live; the language is effectively prefix-closed), and α∈[0,1)\alpha \in [0,1). The constrained surfer lives on V×QV \times Q. From (u,q)(u, q):

  • with probability α\alpha it follows a uniformly random edge (u,a,w)(u, a, w) among those with δ(q,a)\delta(q, a) defined, moving to (w,δ(q,a))(w, \delta(q, a)); if there is no such edge, it jumps as in the next case;
  • with probability 1−α1 - \alpha it jumps to (w,q0)(w, q_0) with ww uniform.

The constrained rank of ww is ∑qπ(w,q)\sum_q \pi(w, q), where π\pi is the stationary distribution.

Proposition 16.2 (Basic properties of the constrained surfer)ProposedCGT-PROP-010
  1. Only states reachable from V×{q0}V \times \{q_0\} carry probability; there are at most ∣Q∣⋅n|Q| \cdot n of them.
  2. One power iteration costs at most ∣Q∣⋅m|Q| \cdot m edge operations plus O(∣Q∣n)\Oh(|Q| n).
  3. The stationary distribution exists and is unique, and power iteration converges with rate α\alpha with the certified error bound of Theorem 15.2.
  4. For the one-state universal DFA, constrained rank equals PageRank of the underlying multigraph.
Proof.

(1) and (2) hold by the product construction (Theorem 8.2): each product state is expanded once per iteration, inspecting the edges of its vertex whose label the DFA admits. (3) is Theorem 15.2 applied to the product chain with teleportation vector 1n1V×{q0}\frac{1}{n}\mathbf{1}_{V \times \{q_0\}}, a probability distribution. (4) With one state that admits every label, the product chain is the surfer chain itself.

∎

The status badge reads proposed: the model is defined here, its properties are elementary, and its novelty is unknown. Products of Markov chains with automata are standard in probabilistic model checking [Baier & Katoen 2008], and similarity measures driven by label patterns (“meta-paths”) are established for heterogeneous information networks [Sun et al. 2011]; whether this exact ranking model has been published is an open literature question (CGT-OPEN-011).

Python · executed by the book's example checker
import random
from cgtsdk import DFA, Cost, compile_regex
from cgtsdk.algorithms import constrained_pagerank, pagerank_power

rng = random.Random(10)
n = 2000
E = [(u, rng.choice("abc"), int(rng.random() ** 2 * n)) for u in range(n) for _ in range(rng.randrange(0, 7))]
E = [(u, a, w) for (u, a, w) in E if u != w]
adj = [[] for _ in range(n)]
for u, _, w in E:
    adj[u].append(w)
plain_cost = Cost()
plain = pagerank_power(adj, 0.85, tol=1e-10, cost=plain_cost)
top = lambda s: [i for i, _ in sorted(enumerate(s), key=lambda t: (-t[1], t[0]))[:10]]
for name, dfa in [("universal", DFA.universal("abc")), ("no c: (a | b)*", compile_regex("(a | b)*")),
                  ("alternate: (a b)* (a | ε)", compile_regex("(a b)* (a | ε)"))]:
    c = Cost()
    scores, res, N = constrained_pagerank(n, E, dfa, 0.85, 1e-10, cost=c)
    l1 = sum(abs(x - y) for x, y in zip(scores, plain.scores))
    print(f"{name:26s} |Q|={dfa.size}  product states={N:5d}  cost ratio={c.counts['edge'] / plain_cost.counts['edge']:.2f}"
          f"  top-10 overlap={len(set(top(scores)) & set(top(plain.scores)))}  L1 distance={l1:.3f}")
Output (checked)
universal                  |Q|=1  product states= 2000  cost ratio=1.03  top-10 overlap=10  L1 distance=0.000
no c: (a | b)*             |Q|=1  product states= 2000  cost ratio=0.80  top-10 overlap=7  L1 distance=0.338
alternate: (a b)* (a | ε)  |Q|=2  product states= 3118  cost ratio=0.67  top-10 overlap=8  L1 distance=0.411

The universal language reproduces PageRank exactly, at a small overhead for building the product. A one-state language that forbids c links is cheaper than PageRank (fewer admissible edges), is at L1L_1 distance 0.340.34 from it — so about 17%17\% of the probability mass moves, since L1L_1 distance is twice the total-variation distance — and changes three of the top ten pages; the alternating language uses about 1.6n1.6 n product states, moves about 21%21\% of the mass and changes two of the top ten. The ledger’s experiment (CGT-EXP-010) found the same pattern on other graphs and languages, with costs from 0.46×0.46\times to 6.4×6.4\times PageRank, and validated each constrained ranking against a direct linear solve of the materialized product chain (CGT-OBS-018).

Claim boundary

These experiments show that constrained rankings differ from PageRank and what they cost. They do not show that the differences are improvements for any retrieval task. That requires labelled corpora and relevance judgments, which this research does not have. The proposal is a model with known costs, not a demonstrated improvement.

16.3 Block structure as a structural grammar

Web graphs are not random: most links stay within a host. BlockRank exploits this by computing local rankings inside hosts, combining them by host importance, and using the result to start a global power iteration, reporting a speed-up by a small factor [Kamvar et al. 2003]. In this book’s taxonomy the host partition is a structural grammar of the graph (a two-level grammar: hosts, then pages), and the method combines M-SHARE (local computations reused as a starting vector), ordering, and M-PRE (warm starts). The general lesson of Chapter 15 applies: power iteration’s cost per iteration is invariant under reordering, and what structure buys is a better starting point or a better sweep order for Gauss–Seidel-like methods — and fewer cut edges when the graph is distributed.

16.4 What the grammatical view does not provide

It is important to be explicit:

What it does provide is a uniform way to state constrained and structured link analyses — as languages over link labels and grammars over graph structure — together with cost bounds that follow from the product construction rather than having to be derived afresh for each variant. Related ranking problems — personalized and topic-sensitive rankings [Haveliwala 2002], hub-and-authority methods, ranking in heterogeneous networks [Sun et al. 2011] — fit the same pattern, and are directions rather than results of this book.

Exercise 16.1

Show that the constrained surfer with a DFA that admits a label only from state q0q_0 and then has no further transitions (the language “at most one link”) produces a ranking computable without iteration. What is it?

Solution to Exercise 16.1

From (u,q0)(u, q_0) the surfer follows one admissible link to (w,q1)(w, q_1), from which every move is a jump back to V×{q0}V \times \{q_0\}. The chain has depth one, and π\pi can be written in closed form: mass on (w,q1)(w, q_1) is α\alpha times the uniform mass flowing over in-links of ww, normalized. The ranking is essentially a weighted in-degree (one-step citation count).

Exercise 16.2

Prove part 2 of Proposition 16.2 precisely, and give a family of graphs and languages on which the bound ∣Q∣⋅m|Q| \cdot m per iteration is attained.

Exercise 16.3

Design an evaluation that could show whether a constrained ranking is better than PageRank for a concrete task. What data, metric and baseline would you need, and what would count as a negative result?

Summary
  • The random surfer is an operational grammar with probabilistic semantics; admissibility languages constrain it through the product construction.
  • The grammar-constrained surfer has at most ∣Q∣n|Q| n states, costs at most ∣Q∣m|Q| m edge operations per iteration, converges at rate α\alpha with certified error, and reduces to PageRank for the universal language (CGT-PROP-010).
  • Measured: constrained rankings differ materially from PageRank at costs between about half and six times PageRank’s; their usefulness is untested and their novelty unverified.
  • Host structure is a structural grammar of the graph; what it buys is starting points, sweep orders and fewer cut edges, not cheaper iterations.
  • The grammatical view gives a uniform statement of constrained link analysis with derived costs, not a faster PageRank.

References cited in this chapter

  1. Baier & Katoen 2008 C. Baier, J.-P. Katoen (2008). Principles of Model Checking. MIT Press (ISBN 978-0-262-02649-9).
  2. Haveliwala 2002 T. H. Haveliwala (2002). Topic-sensitive PageRank. Proc. 11th International World Wide Web Conference (WWW 2002). link.
  3. Kamvar et al. 2003 S. Kamvar, T. Haveliwala, C. Manning, G. Golub (2003). Exploiting the block structure of the Web for computing PageRank. Technical Report 2003-17, Stanford University.
  4. Sun et al. 2011 Y. Sun, J. Han, X. Yan, P. S. Yu, T. Wu (2011). PathSim: Meta path-based top-k similarity search in heterogeneous information networks. Proceedings of the VLDB Endowment 4(11):992–1003.

Report an erratum or an unclear passage in this chapter