Distributed representations: reuse features across combinations
分布式表示
Contrast shared feature codes with one-hot identities, test held-out combinations and show where a linear decoder fails.
distributed-representationsStart with the problem
A local code gives each object its own unit. A distributed code represents an object by a pattern across shared units: a feature can participate in many objects, and each object can use several features. The useful property is reuse, not simply that a vector contains nonzero numbers.
The representation-learning survey discusses combinatorial expressiveness. Bengio and colleagues’ neural language model learns word features jointly with prediction so related contexts can share statistical strength. We use a small combinatorial regression task to make both the benefit and its assumptions explicit.
Definitions and derivation
Three binary factors describe eight configurations. The target is additive in those factors:
The factors are supplied by the experimenter; this program does not discover them from raw observations. A three-coordinate distributed representation can encode all eight configurations. An eight-dimensional one-hot representation instead identifies each configuration separately. Both can uniquely identify the finite inputs, but the downstream parameter sharing differs.
Append an intercept to the factor code and fit ordinary least squares on four configurations: (−1,−1,−1), (−1,−1,+1), (−1,+1,−1), (+1,−1,−1). Their four-column design is full rank, so the additive coefficients and intercept are determined. We compare a one-hot model without an intercept, using the minimum-norm solution; unseen identity weights remain zero.
The fitted factor coefficients are (2,−1,0.5), with zero intercept, so the remaining four combinations are predicted correctly. This follows from the true additive target and full-rank training design. It is not a theorem that distributed codes always generalize better. Different one-hot regularization, kernels or shared structure would define different baselines.
The second equality shows that individual coordinates need not have unique semantic meanings. Mix the factor code with any invertible matrix R and adjust decoder weights by R⁻¹; predictions remain identical. Our integer-valued mixing matrix is deliberately not described as an orthogonal rotation. The new axes mix factors, yet the representation still carries the same information.
Feature reuse does not make a linear decoder universally expressive. Change the target to the product of the first two factors. On all eight uniformly weighted combinations:
The product is orthogonal to each single factor and the constant column. The least-squares affine predictor is therefore zero, with MSE one. Adding the product as another feature makes the target exactly linear. A nonlinear decoder could also represent the interaction. Counting possible codes does not establish that a chosen decoder can express every labeling or that a learning procedure will discover useful factors.
Run the calculation
Run the complete Python 3.12 / NumPy 1.26.4 calculation:
import itertools
import numpy as np
def data():
x=np.array(list(itertools.product([-1.,1.],repeat=3)));y=x@np.array([2.,-1,.5]);return x,y
def fit_predict(features,target,train):
f=np.asarray(features,dtype=float);y=np.asarray(target,dtype=float);ids=np.asarray(train,dtype=int)
if f.ndim!=2 or y.shape!=(len(f),) or ids.ndim!=1 or not len(ids) or np.any(ids<0) or np.any(ids>=len(f)) or len(set(ids.tolist()))!=len(ids):raise ValueError('Use aligned features, targets and unique training rows.')
weights=np.linalg.lstsq(f[ids],y[ids],rcond=None)[0];return f@weights,weights
if __name__ == '__main__':
x,y=data();train=[0,1,2,4];test=[3,5,6,7]
f=np.c_[x,np.ones(8)];distributed,w=fit_predict(f,y,train);local,_=fit_predict(np.eye(8),y,train)
print('shared feature weights',w.round(9).tolist(),'held-out targets',y[test].tolist());print('distributed / local held-out MSE',round(float(np.mean((distributed[test]-y[test])**2)),12),round(float(np.mean((local[test]-y[test])**2)),9))
rotation=np.array([[1.,1,0],[0,1,1],[1,0,1]]);mixed,_=fit_predict(np.c_[x@rotation,np.ones(8)],y,train);print('invertible mixing prediction error',float(np.max(np.abs(mixed-distributed))))
interaction=x[:,0]*x[:,1];linear,_=fit_predict(f,interaction,list(range(8)));nonlinear,_=fit_predict(np.c_[f,interaction],interaction,list(range(8)));print('interaction target linear / product-feature MSE',round(float(np.mean((linear-interaction)**2)),9),round(float(np.mean((nonlinear-interaction)**2)),12))
Actual output:
shared feature weights [2.0, -1.0, 0.5, -0.0] held-out targets [-2.5, 3.5, 0.5, 1.5]
distributed / local held-out MSE 0.0 5.25
invertible mixing prediction error 5.10702591327572e-15
interaction target linear / product-feature MSE 1.0 0.0
Held-out targets are (−2.5,3.5,0.5,1.5). The factor model has zero MSE to displayed precision; the stated one-hot baseline predicts zero and has MSE 5.25. Invertible mixing changes predictions only at rounding scale. For the interaction target, the affine code has MSE one, while adding the product feature reduces it to rounding zero.
These are exact finite-design comparisons, not language-model benchmarks. Least-squares fitting is a reproducible way to expose decoder assumptions. In actual word embeddings, the vocabulary table still stores parameters per word, and useful sharing arises through shared feature coordinates and downstream functions; saying that an embedding has d dimensions does not mean the entire vocabulary costs only d parameters.
When the method fails
A shared representation can also share mistakes. Factors may be entangled, rare combinations may lack support, and a downstream task may depend on interactions absent from the decoder. Dense codes are not automatically interpretable, and sparse codes can still be distributed when units participate in multiple objects.
Distributed representation is unrelated to distributing computation across machines. The term concerns how information is encoded. Evaluate learned codes with held-out tasks, combinations and nuisance shifts; do not infer semantic structure from vector arithmetic alone.
Exercises with answers
- Why do four training configurations suffice here?
Answer 1: The target is affine in three supplied factors and the four-row augmented design is full rank.
- Why does the specified one-hot model predict zero for unseen identities?
Answer 2: Their columns never occur during training, so the minimum-norm least-squares solution leaves those weights zero.
- Does invertible mixing destroy the factor information?
Answer 3: No. The decoder can apply the inverse mixing; individual axes may lose simple interpretations.
- Why does the product target defeat the affine decoder?
Answer 4: It is orthogonal to all three individual factor columns and the intercept on the balanced cube.
Sources and next steps
The survey’s physical page 4, Section 3.3, discusses distributed codes and combinatorial capacity. Bengio et al. physical pages 2–4 explain sharing statistical strength across contexts represented by word features. Our supplied factor code is a controlled illustration, not their learned language model. Continue with representation learning for task-dependent evaluation and autoencoders for a learned encoding objective.
Make a prediction, then check
What makes the held-out additive predictions work here?
Learning objectives
- Test compositional generalization under explicit additive assumptions.
- Separate code capacity, decoder expressiveness and semantic interpretation.
Prerequisites & connections
Explore related knowledge →References
- Representation Learning: A Review and New Perspectives — arXiv v3
Yoshua Bengio; Aaron Courville; Pascal Vincent · 2013 - A Neural Probabilistic Language Model
Yoshua Bengio; Réjean Ducharme; Pascal Vincent; Christian Jauvin · 2003
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-06 · Codex single-AI-author technical check: primary-source scope, explicit assumptions, original calculations, independent mathematical references and bilingual tests; not independent human or second-agent review.
- Single-AI-author technical check: bounded primary-source reading, explicit assumptions, original calculations, runnable examples and matching bilingual equations, code and exercises. Not an independent human or second-agent review.
- Four focused CPython 3.12.4 tests passed per chapter, including independent finite differences, literal calculations, recurrence and convolution comparisons, permutation symmetry, closed-form limits and expressive counterexamples. All eight programs use NumPy 1.26.4. CPU teaching calculations, not framework or GPU benchmarks.
- Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
- Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.
Source locations checked:
- Representation Learning: A Review and New Perspectives — arXiv v3 · Physical page 4, Section 3.3: shared distributed representations and combinatorial counting argument.
- A Neural Probabilistic Language Model · Physical pages 2–4: distributed word features and statistical sharing across related contexts.
Related topics