{"record":{"id":"3e69dead26ae5ee3","repo":"mem0ai/mem0","slug":"baidu-mochow-table-label-stores-dimension","errorCode":null,"errorMessage":"Baidu Mochow table '${label}' stores ${dimension}-dimensional vectors, but 'embeddingModelDims' is ${this.embeddingModelDims}.","messagePattern":"Baidu Mochow table '(.+?)' stores (.+?)-dimensional vectors, but 'embeddingModelDims' is (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/baidu.ts","lineNumber":377,"sourceCode":"    const indexes = schema?.indexes ?? [];\n    const field = (name: string) => fields.find((f) => f.fieldName === name);\n    const typeOf = (name: string) => String(field(name)?.fieldType ?? \"\");\n    const label = `${this.databaseName}.${this.tableName}`;\n\n    if (\n      typeOf(\"id\") !== \"STRING\" ||\n      !typeOf(\"data\").startsWith(\"TEXT\") ||\n      typeOf(\"vector\") !== \"FLOAT_VECTOR\" ||\n      typeOf(\"metadata\") !== \"JSON\"\n    ) {\n      throw new Error(\n        `Baidu Mochow table '${label}' exists but is missing the id/data/vector/metadata schema mem0 requires. Drop it, or point 'tableName' at an unused table.`,\n      );\n    }\n\n    const dimension = field(\"vector\")?.dimension;\n    if (dimension !== undefined && dimension !== this.embeddingModelDims) {\n      throw new Error(\n        `Baidu Mochow table '${label}' stores ${dimension}-dimensional vectors, but 'embeddingModelDims' is ${this.embeddingModelDims}.`,\n      );\n    }\n\n    this.supportsKeywordSearch =\n      typeOf(\"textLemmatized\").startsWith(\"TEXT\") &&\n      indexes.some((index) => index.indexName === BM25_INDEX);\n\n    if (!this.supportsKeywordSearch) {\n      console.warn(\n        `Baidu Mochow table '${label}' has no '${BM25_INDEX}' inverted index. keywordSearch() will return null until the table is recreated.`,\n      );\n    }\n  }\n\n  async initialize(): Promise<void> {\n    if (!this._initPromise) {\n      this._initPromise = this.ensureTable().catch((error) => {","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/baidu.ts#L359-L395","documentation":"After schema validation, the Baidu store compares the table's vector field dimension (if defined) against the configured embeddingModelDims and throws when they differ. Inserting vectors of the wrong dimension into Mochow would fail server-side, so this check catches the mismatch up front with both numbers in the message.","triggerScenarios":"Table created with 1024-dim vectors (e.g. BGE) but embeddingModelDims left at the default (1536); switching the embedder to another model without recreating the table; explicitly setting embeddingModelDims inconsistently with the embedder's real output.","commonSituations":"Changing embedding providers (openai text-embedding-3-small 1536 vs bge-m3 1024) after data already exists; copy-pasted config where dims were never aligned.","solutions":["Set vectorStore config embeddingModelDims to the actual output dimension of your embedder, matching the number in the error.","If the table must keep its dimension, switch the embedder to one producing that dimension.","If you intend to change dimensions, drop the table and let mem0 recreate it (existing vectors cannot be migrated)."],"exampleFix":"// before\nembedder: { provider: 'huggingface', config: { model: 'BAAI/bge-m3' } },\nvectorStore: { provider: 'baidu', config: { embeddingModelDims: 1536, ... } }\n// after\nvectorStore: { provider: 'baidu', config: { embeddingModelDims: 1024, ... } }","handlingStrategy":"validation","validationCode":"function assertDimsMatch(configDims: number | undefined, tableDims: number | undefined, embedder: { dims: number }) {\n  const expected = configDims ?? embedder.dims;\n  if (tableDims !== undefined && tableDims !== expected)\n    throw new Error(`embeddingModelDims (${expected}) != table dimension (${tableDims}); recreate table or change embedder`);\n}","typeGuard":null,"tryCatchPattern":"try { await memory.add(text) } catch (e) { if (e instanceof Error && /-dimensional vectors, but 'embeddingModelDims' is/.test(e.message)) { /* stop producer; fix dims; reindex */ } throw e; }","preventionTips":["Pin embeddingModelDims to your embedder's true output size in config.","When changing embedding models, plan a drop-and-rebuild of the Baidu table.","Record the dims used to create each table alongside its name in your infra config."],"tags":["baidu","dimension-mismatch","embeddings","configuration","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}