ruvnet/ruflo · error

Embeddings must have same dimension

Error message

Embeddings must have same dimension

What it means

hyperbolicDistance() was called with Poincaré-ball vectors a and b whose lengths differ. The geodesic-distance formula requires dimensionally matched points, so the guard fires before any curvature math — typically mixed-model embeddings or a truncated vector.

Source

Thrown at v3/@claude-flow/embeddings/src/hyperbolic.ts:161

 *
 * The geodesic distance between two points in the Poincaré ball.
 *
 * @param a - First Poincaré embedding
 * @param b - Second Poincaré embedding
 * @param config - Hyperbolic geometry configuration
 * @returns Hyperbolic distance
 */
export function hyperbolicDistance(
  a: Float32Array | number[],
  b: Float32Array | number[],
  config: HyperbolicConfig = {}
): number {
  const { curvature, epsilon } = { ...DEFAULT_CONFIG, ...config };
  const c = Math.abs(curvature);
  const sqrtC = Math.sqrt(c);

  if (a.length !== b.length) {
    throw new Error('Embeddings must have same dimension');
  }

  // ||a - b||^2
  let diffNormSq = 0;
  for (let i = 0; i < a.length; i++) {
    const d = a[i] - b[i];
    diffNormSq += d * d;
  }

  // ||a||^2 and ||b||^2
  let normASq = 0;
  let normBSq = 0;
  for (let i = 0; i < a.length; i++) {
    normASq += a[i] * a[i];
    normBSq += b[i] * b[i];
  }

  // Poincaré distance formula:

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Pass embeddings produced by the same model/dimension to the hyperbolic operation.
  2. Truncate or pad is not supported; regenerate the mismatched embedding with the correct model.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/@claude-flow/embeddings/src/hyperbolic.ts:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/8fb8b4291043b5b7. Report an issue: GitHub.