diegosouzapw/OmniRoute · error · Error

Unexpected safetensors shape: ${JSON.stringify(shape)}

Error message

Unexpected safetensors shape: ${JSON.stringify(shape)}

What it means

Error "Unexpected safetensors shape: ${JSON.stringify(shape)}" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/memory/embedding/staticPotion.ts:123

  const modelPath = path.join(modelDir, "model.safetensors");
  const tokenizerPath = path.join(modelDir, "tokenizer.json");

  await Promise.all([
    ensureFile(vocabPath, `${hfBase}/vocab.json`),
    ensureFile(modelPath, `${hfBase}/model.safetensors`),
    ensureFile(tokenizerPath, `${hfBase}/tokenizer.json`),
  ]);

  // Load vocab
  const vocabRaw = await fs.readFile(vocabPath, "utf8");
  const vocab = JSON.parse(vocabRaw) as Record<string, number>;

  // Load matrix from safetensors
  const modelBuf = await fs.readFile(modelPath);
  const { matrix, shape } = parseSafetensors(modelBuf);

  if (shape.length < 2) {
    throw new Error(`Unexpected safetensors shape: ${JSON.stringify(shape)}`);
  }
  const vocabSize = shape[0];
  const dim = shape[1];

  const unkIdx = vocab["[UNK]"] ?? 0;

  return { vocab, matrix, dim, vocabSize, unkIdx };
}

export function getOrLoadModel(): Promise<PotionModel> {
  if (_model) return Promise.resolve(_model);
  if (_loading) return _loading;
  _loading = loadModel().then((m) => {
    _model = m;
    _loading = null;
    return m;
  });
  return _loading;

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/memory/embedding/staticPotion.ts:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/6bad31a9505900db. Report an issue: GitHub.