InterviewsVector
Arc 2
Concept labFoundation80 min estimateOriginal publication

Vectors as Representations

A vector is useful only through the contract that produced its coordinates and the downstream behavior those coordinates preserve.

Authorship
InterviewsVector
Published / updated
2026-08-14 / 2026-08-14
Review status
Artifact tests passing · primary sources recorded

Original InterviewsVector material. Code examples are covered by repository tests and primary references are recorded. No named human reviewer is claimed.

The decision in one pass

A vector is an ordered coordinate representation, not the thing being represented. Its dimension, basis, scale, model revision, preprocessing, and intended comparisons define what operations mean. A coordinated change of basis can preserve downstream behavior even while every coordinate changes; an uncoordinated transform, truncation, or quantization can keep the same type while destroying the information a consumer needs. Migrate representations by testing declared invariants on stable item identities, not by comparing coordinate columns by eye.

Why this matters

Representation migrations are deceptively compatible. Two services may exchange finite arrays with the same dimension while using different model revisions or coordinate conventions. Conversely, a safe basis rotation can make raw coordinates look completely different. Without behavioral invariants, teams either approve a breaking change or block a valid one for the wrong reason.

You will be able to

  • Distinguish an object, its vector representation, and the coordinate system used to encode it.
  • Derive how downstream linear probes and distances behave under coordinate transforms.
  • Identify when projection, truncation, normalization, or quantization discards task-relevant information.
  • Build a representation migration audit with stable identities, finite-number checks, and explicit drift tolerances.
  • Version representation semantics across producers, stores, indexes, and downstream consumers.

Prerequisite contract

Your Vector Loop for this lab

  1. 01

    Model

    Name the represented objects, coordinate contract, and downstream questions.

  2. 02

    Derive

    Relate basis changes, transformed probes, geometric invariants, and information loss.

  3. 03

    Build

    Capture stable item identities and audit a declared linear representation migration.

  4. 04

    Stress

    Reuse stale probes, collapse dimensions, corrupt values, and swap representation IDs.

  5. 05

    Operate

    Version producers and consumers, shadow migrations, and monitor behavior by slice.

  6. 06

    Defend

    Explain which properties must remain invariant and which changes are intentional.

Model the vector as a contract

An entity such as a support request, image, token, or user is not a vector. An encoder maps that entity and its context into coordinates. Those coordinates become meaningful only when paired with a representation ID that fixes the encoder revision, preprocessing, pooling, dimension order, scale, and intended uses. The same entity can have several valid representations for different decisions.

A vector payload needs semantic identity in addition to a numeric shape.
Contract fieldQuestion it answersSilent failure
item identitywhich real object is this?rows are compared after reorder
representation IDwhich encoder and semantics produced it?equal dimensions are treated as compatibility
dimension and axeshow are coordinates shaped and interpreted?a pooled vector is mistaken for token states
scale or normalizationwhat should magnitude influence?norm becomes accidental rank signal
invariantswhich downstream behavior must survive?coordinate similarity substitutes for product evidence

Derive what a coordinate change must preserve

x′ = A x

A linear coordinate transform maps a source vector x into target coordinates x′. Its row count is the target dimension and its column count must equal the source dimension.

w′ = A⁻ᵀw ⇒ w′ᵀx′ = wᵀx

For an invertible change, a downstream linear probe must transform contragrediently. Reusing source weights against target coordinates changes the score even if both vectors have the same length. For an orthogonal A, A⁻ᵀ = A.

‖Ax − Ay‖₂ = ‖x − y‖₂ only when A preserves Euclidean geometry

Orthogonal rotations and reflections preserve L2 distance. General scaling, shearing, projection, or truncation does not. Decide whether distance is an invariant before treating drift as an error.

When a transform maps a higher-dimensional space into fewer coordinates, distinct source vectors can collide. That is information loss, but not automatically a defect: a projection may deliberately discard nuisance variation. The engineering obligation is to show that the lost distinctions are irrelevant to named downstream decisions on representative slices.

Move the basis and watch behavior

Vector basis explorer

Compare full-rank and rank-one transforms, move an input and collision twin, then use rank, determinant, and output separation to judge recoverability and information loss.

See when a transform forgets

Change the input and compare it with a deliberately different twin. A full-rank map changes coordinates without losing a degree of freedom; a rank-one map makes the two inputs indistinguishable.

Transformation

The twin is always (2 + 1, 1 − 1). Its coordinate sum matches the original, exposing the erased direction in the rank-one map.

Two transformed vectors on an output planeThe original output and twin output remain 1.12 units apart.output spacesolid: inputdashed: twin
Rank / determinant
2 / 1
Input output
(2.50, 1)
Twin output
(3, 0)

The outputs stay 1.12 units apart. The transform can be inverted even though angles and lengths may change.

What can the current transformation guarantee for arbitrary 2D inputs?

Make a prediction, then check it against the current evidence.

Build a representation invariance audit

The reference artifact snapshots item IDs, vectors, transform rows, and source/target probe weights into immutable tuples. It rejects duplicate identities, empty or ragged shapes, booleans disguised as numbers, NaN, infinity, source-ID mismatches, and missing probes. The report compares declared linear scores, pairwise distances, and source-distinct items that collapse in the target representation.

representation_invariance.py
1if __name__ == "__main__":
2 report = audit_invariance(
3 EXAMPLE_REPRESENTATIONS, EXAMPLE_ROTATION, EXAMPLE_PROBES
4 )
5 print(
6 f"representation={report.source_representation_id}"
7 f"->{report.target_representation_id}"
8 )
9 print(f"dimensions={report.source_dimension}->{report.target_dimension}")
10 print(f"max_score_drift={report.max_score_drift:.6f}")
11 print(f"max_distance_drift={report.max_distance_drift:.6f}")
12 print(f"collisions={len(report.collisions)}")

Expected output

representation=support-intent-v3->support-intent-v4
dimensions=2->2
max_score_drift=0.000000
max_distance_drift=0.000000
collisions=0

Verify: Run python3 -m unittest discover courses/ai-engineering/reference-impl/vector_representation.

  1. 01Join by stable identityCompare the same canonical items across versions; row position, filenames, or arrival order are not identity contracts.
  2. 02Declare behavioral probesChoose scores, neighbors, classifications, or task outputs that consumers actually depend on, and migrate each probe explicitly.
  3. 03Separate intended from unintended driftA dimensional reduction may intentionally alter distance. Record the accepted property and evaluate task utility rather than forcing every numeric invariant to pass.

Stress the assumptions that arrays conceal

  1. 01Keep the dimension, change the modelReject the payload unless the representation ID matches. An equal-length output from another encoder is syntactically compatible and semantically unrelated.
  2. 02Rotate coordinates, keep stale weightsRaw vectors remain valid, but a downstream linear probe now asks a different question. The audit should expose score drift by item.
  3. 03Project away one coordinateSearch for distinct items that become identical and inspect whether the lost distinction matters on rare, safety-critical, or high-cost slices.
  4. 04Quantize near a decision boundaryAggregate error can look small while small coordinate perturbations flip high-impact decisions. Measure margin-conditioned behavior, not only mean squared drift.
  5. 05Inject non-finite valuesFail before storage or scoring. NaN can poison comparisons and sorting while still occupying an otherwise valid numeric container.

Operate representation changes as migrations

ControlEvidenceRollback unit
versioned producerresolved model, preprocessing, pooling, dimensionencoder release
canonical comparison setstable item IDs plus protected slicesevaluation snapshot
shadow consumersold/new score, neighbor, and decision diffsconsumer configuration
dual index or storecoverage, freshness, delete, and ACL parityindex alias
drift budgettask-specific tolerance and collision reviewmigration gate
  • Record vector norm and invalid-value distributions by representation version and data slice.
  • Keep old and new coordinates out of the same namespace unless every read is version-filtered.
  • Shadow representative traffic before cutover and retain the source objects needed to rebuild either version.
  • Evaluate retrieval or decision utility after approximate indexing, filtering, and thresholds—not just at the encoder boundary.
  • Treat a normalization or truncation change as a representation change even when the base model name is unchanged.

Operate at three altitudes

Production lens

  • Propagate representation identity through storage, cache keys, indexes, traces, and offline datasets.
  • Evaluate both numeric invariants and task-level behavior on stable identities and operational slices.
  • Reject non-finite and mismatched vectors before they enter a shared corpus or online index.
  • Isolate encoder, preprocessing, normalization, index, and consumer changes so each can be shadowed and rolled back.

Staff lens

  • Define representation compatibility as an organization-level contract rather than a convention inside one model team.
  • Require downstream owners to name which geometric or decision properties they depend on before approving compression.
  • Fund canonical rebuild inputs and evaluation identities; without them a representation store becomes irreversible state.

Interview defense

A new embedding model returns vectors with the same dimension as the old model. How would you determine whether an in-place rollout is safe?

I would treat the model and preprocessing revision as a new representation identity despite the equal shape. I would rebuild a shadow corpus from canonical objects, join old and new outputs by stable item ID, validate finite values and norm distributions, and compare declared downstream behavior: exact and approximate neighbors, task recall, thresholds, and protected slices. I would never mix versions in one unfiltered index. After dual writes and shadow reads, I would canary an index alias with separate rollback for encoder, index, and consumer policy.

Expect the interviewer to press on

  • When can every coordinate change without changing behavior?
  • What evidence would justify truncating an embedding?
  • Why can a low average drift still hide a severe regression?

Misconceptions to remove

A vector's coordinates have stable meaning by themselves.

Coordinates are defined relative to a representation contract; learned axes can rotate or redistribute information without human-readable labels.

Equal dimensions make two embedding versions compatible.

Dimension is only a shape check. Model revision, preprocessing, basis, scale, and downstream behavior must also agree.

Reducing dimension merely makes a vector less precise.

Projection can erase entire distinctions and create collisions. Whether that loss is acceptable is a task- and slice-specific claim.

Check your model

1. If x′ = Ax under an invertible change of coordinates, why should a source linear probe w usually not be applied directly to x′?

Because the coordinates changed. To preserve wᵀx, the target probe must be w′ = A⁻ᵀw; reusing w generally computes a different score.

2. Why can an orthogonal rotation produce large coordinate differences while preserving retrieval geometry?

Orthogonal transforms preserve dot products, norms, angles, and pairwise L2 distances. Individual coordinate values change because the basis changed, not because the geometry changed.

3. What does a collision after projection prove?

It proves the transform discarded a distinction between those source vectors. It does not alone prove product harm; the lost distinction must be evaluated against downstream tasks and slices.

Prove the mechanism

Add a non-orthogonal but invertible transform and migrate a linear probe with A⁻ᵀ. Show that probe scores remain stable while pairwise Euclidean distances change, then explain which result should gate a real migration.

Add a production constraint

Extend the artifact with top-k neighbor overlap and a protected-slice report that refuses approval when a small global drift hides a large slice regression.

Artifact: Representation invariance audit

courses/ai-engineering/reference-impl/vector_representation/representation_invariance.py

Download reference implementation

Primary references and next links

References

  1. 1. Efficient Estimation of Word Representations in Vector Space

    Mikolov, Chen, Corrado, and Dean. Primary paper establishing learned continuous vectors as task-tested word representations.

  2. 2. Matryoshka Representation Learning

    Kusupati et al.. Primary paper showing that useful nested dimensionalities can be learned, rather than assumed for arbitrary truncation.

  3. 3. Python Array API vecdot specification

    Consortium for Python Data API Standards. Official cross-library specification for vector dot-product dimensions and numeric behavior.

Continue through the graph

Glossary: vector · coordinate · basis · linear probe · projection · invariant · representation identity