numpy==2.2.6
pandas==2.3.3
PyYAML==6.0.3
# Three packages, and for a node2vec post that is a deliberate choice rather
# than minimalism. Every graph-embedding library hides at least one of the
# three results this repository exists to show.
#
# `gensim.models.Word2Vec` takes the walk corpus and returns vectors. It also
# decides, on your behalf, that you want the input table and not the output
# table, and `wv[node]` hands you W with no mention that V exists. On a
# bipartite graph that single default is the difference between recall@20 of
# 0.4207 and 0.0327. A library whose default is catastrophic on your graph
# shape and whose API does not expose the alternative is not a library you
# can debug, and `--tables` is the output that makes it visible.
#
# `node2vec` (the pip package) wraps gensim and precomputes the second-order
# alias tables. It would also have hidden the candidate-class census, which
# is the finding that p and q have ONE effective parameter here, not two.
#
# Everything below is optional and deliberately not installed.
#
# What it would replace: `graph/bipartite.py::BipartiteGraph._build_csr` and
# every dense score matrix in `eval/metrics.py`. Neither needs replacing at
# 4,200 nodes and a 3,000-by-1,200 score matrix, which is 28 MB of float64.
# What flips at production scale is the dense matrix, not the graph: at 10
# million items the (users, items) score array stops existing and the
# evaluation has to run per user-batch against an ANN index, which is post
# 27's subject. The graph itself stays small: a CSR of 100 million edges is
# about 1.2 GB and fits where the score matrix does not.
# scipy==1.15.3
#
# What it would replace: `models/als.py` entirely, with `implicit`'s
# Cython/GPU ALS, which is 50 to 100 times faster and numerically identical.
# Worth knowing what the hand-written version bought: the fair-comparison
# table in `--dim` needs ALS at MATCHED dimension against node2vec, and the
# measured result is that ALS is ahead at dim 8, 16 and 32 (-0.0003, -0.0010
# and -0.0010 of recall@20 for node2vec) and behind by 0.0053 at 64 and 128.
# A comparison that close is only meaningful if both sides were tuned with
# the same effort, and the ALS sweep that produced alpha=2.0 and reg=30.0
# moved it from 0.2283 to 0.4153. The first version of this repository
# compared tuned node2vec against ALS at a cited alpha=40 and reg=0.02 and
# concluded the walk won by 0.19, which was a statement about the sweep.
# implicit==0.7.2
#
# What it would replace: `graph/walks.py::random_walks` and
# `models/skipgram.py` together. In production it should: gensim's SGNS is
# multithreaded C with a Huffman-free negative-sampling table and will train
# this corpus in under a second against this file's 15.7. Use it, and pass
# the output table explicitly.
# gensim==4.3.3
#
# What it would replace: `graph/bipartite.py`, with real graph algorithms
# behind it. The reason it is not here is that a bipartite user-item graph
# needs exactly two operations, a neighbour slice and a degree, and a general
# graph library charges a Python-object-per-node for the ones it does not
# need. At 4,200 nodes that is irrelevant and at 100 million it is the whole
# problem, which is why production graph pipelines are CSR arrays rather than
# networkx objects.
# networkx==3.4.2
#
# What it would replace: `models/skipgram.py`, and this is the recommendation
# with a real caveat. A GNN (LightGCN, PinSage) is the current answer to this
# problem class and it subsumes node2vec: it propagates over the same
# bipartite graph, learns the propagation rather than sampling it, and takes
# node features so a new item is not a cold start. What it does not do is run
# in 17 seconds on three packages. The honest sizing: LightGCN on this graph
# would be about 20 lines of torch and would be expected to land within noise
# of the 0.4207 that two-hop, node2vec and ALS all reach here, because the
# ceiling in this table is set by the graph's information content and not by
# the model. That expectation is NOT measured in this repository and is
# labelled as an expectation for that reason.
# torch==2.6.0
