pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: theodufort (@theodufort) <noreply+theodufort@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #717: Updating vector(768) doesn't do anything
Date: Sun, 24 Nov 2024 14:00:59 +0000
Message-ID: <gh-pgvector-pgvector-717@github.com> (raw)

Im trying to update the column `title_embedding` from this query in the nodejs postgres package:
```
async function updateTitleEmbeddings(rows) {
  if (!rows || rows.length === 0) {
    return { success: false, error: "No rows provided for update" };
  }

  const firstRow = rows[0];
  const { id, title_embedding: embedding } = firstRow;

  // Validate embedding dimensions
  if (!Array.isArray(embedding) || embedding.length !== 768) {
    throw new Error(
      `Invalid embedding dimensions for id ${id}. Expected 768, got ${embedding?.length}`
    );
  }

  // Convert the embedding array to a string in the format '[value1,value2,...]'
  const embeddingString = "[" + embedding.join(",") + "]";

  try {
    const result = await sql`
      UPDATE books_parted 
      SET title_embedding = ${embeddingString}::vector
      WHERE id = ${id}
      RETURNING id, title_embedding
    `;

    if (result.length === 0) {
      console.warn("Update completed but no rows were modified");
    }
    return { success: true, updatedRows: result.length, result };
  } catch (error) {
    console.error("Error updating embeddings:", error);
    return { success: false, error: error.message };
  }
}
```
on my table:
```
public.books_parted (
	id text NOT NULL,
	work_id text NULL,
	isbn10 text NULL,
	isbn13 text NOT NULL,
	title text NULL,
	subtitle text NULL,
	description text NULL,
	"language" text NOT NULL,
	published_date text NULL,
	page_count int4 NULL,
	title_embedding public.vector NULL,
	description_embedding public.vector NULL,
	"format" text NULL,
	CONSTRAINT books_parted_pkey PRIMARY KEY (language, id),
	CONSTRAINT unique_id UNIQUE (language, id),
	CONSTRAINT unique_isbn10_isbn13_parted UNIQUE (language, isbn10, isbn13)
)
```

I don't get any errors, but the column won't update, even if the row to update looks like:
```
{
    id: "/books/OL28612670M",
    title: "Tabula Plena",
    title_embedding: [
      0.036224365, 0.023529053, -0.14013672, -0.010719299, 0.006790161, -0.0023899078,
      -0.028518677, -0.03744507, -0.03515625, 0.00015091896, 0.0072746277, 0.029037476,
      0.0758667, -0.0357666, 0.019821167, -0.06628418, 0.024932861, -0.056243896,
      -0.0064926147, 0.05996704, 0.0008764267, 0.006164551, -0.0657959, -0.042236328,
      0.026763916, 0.039611816, 0.012680054, -0.02609253, -0.008140564, -0.054138184,
      -0.011329651, -0.053588867, 0.03994751, 0.014259338, 0.015037537, -0.039916992,
      -0.00774765, 0.0056495667, 0.03982544, 0.06286621, 0.011421204, 0.0022354126,
      -0.03262329, -0.0413208, -0.009140015, -0.034423828, 0.035614014, -0.002073288,
      0.027282715, -0.054656982, 0.018341064, -0.03475952, 0.041046143, -0.06793213,
      0.02645874, 0.009773254, 0.0602417, -0.014816284, 0.030715942, 0.051330566,
      0.062683105, 0.024368286, -0.09655762, 0.06689453, 0.040618896, -0.0041542053,
      -0.01512146, 0.06262207, -0.027404785, -0.00472641, 0.0927124, -0.005844116,
      0.051452637, 0.0011396408, -0.03552246, -0.013557434, -0.041992188, -0.01890564,
      0.01977539, -0.0051498413, 0.063964844, 0.04446411, 0.07940674, 0.034118652,
      0.034698486, 0.028213501, -0.036102295, -0.02885437, -0.07281494, 0.043273926,
      0.001159668, 0.0013618469, 0.06347656, -0.011634827, -0.09088135, 0.0107421875,
      0.0044822693, -0.000056624413, -0.041290283, -0.031982422, -0.010055542, -0.007156372,
      0.055725098, 0.015388489, 0.07531738, 0.03543091, -0.017745972, -0.04837036,
      -0.026763916, -0.00079250336, -0.0095825195, 0.026885986, 0.00052690506, 0.020446777,
      0.017944336, -0.0010938644, 0.0847168, -0.04156494, 0.054901123, 0.042419434,
      -0.012374878, -0.01209259, 0.028625488, 0.07342529, -0.029632568, 0.01184082,
      -0.058776855, 0.07928467, 0.008453369, -0.038024902, 0.020187378, -0.033050537,
      -0.006164551, 0.006008148, -0.0007081032, 0.09765625, -0.010765076, -0.031799316,
      0.026565552, 0.026153564, 0.064331055, -0.00027036667, -0.0035190582, -0.025436401,
      0.026504517, -0.044281006, 0.012283325, -0.044158936, -0.033050537, 0.014350891,
      0.04449463, 0.03567505, -0.00090169907, -0.035491943, -0.009460449, -0.032348633,
      0.0028419495, 0.014434814, -0.004638672, 0.016967773, 0.052093506, -0.016860962,
      -0.07861328, 0.028274536, -0.027069092, -0.0154418945, -0.0031356812, 0.006187439,
      0.01235199, 0.02293396, -0.019012451, -0.049743652, -0.016021729, 0.019607544,
      0.06707764, 0.013191223, 0.056884766, 0.016067505, -0.0070648193, -0.050323486,
      0.024276733, -0.042907715, 0.011558533, 0.0713501, -0.02494812, -0.03717041,
      0.003835678, -0.031799316, -0.053100586, -0.016342163, -0.023376465, 0.054992676,
      0.0061416626, -0.03881836, -0.037261963, -0.047668457, 0.046936035, -0.030471802,
      0.01020813, -0.0715332, -0.030258179, 0.027709961, -0.038391113, 0.019073486,
      -0.00623703, 0.03741455, -0.034576416, 0.009399414, -0.0071792603, 0.06640625,
      0.03677368, 0.008178711, -0.0107421875, 0.018066406, -0.034851074, -0.009628296,
      -0.04727173, 0.0034542084, 0.0029754639, 0.015945435, -0.026382446, 0.00548172,
      -0.026321411, -0.02760315, 0.060150146, 0.004337311, -0.017959595, 0.040161133,
      0.004108429, 0.019607544, -0.020065308, -0.12207031, -0.004169464, 0.013252258,
      -0.046173096, -0.0284729, -0.066345215, 0.058776855, -0.03137207, -0.007850647,
      -0.03591919, 0.021575928, 0.000040352345, -0.00077819824, -0.04638672, 0.005115509,
      0.0045547485, -0.042419434, 0.060394287, 0.07067871, 0.023376465, -0.045410156,
      0.02973938, 0.075805664, 0.02142334, -0.03074646, -0.056549072, 0.029571533,
      0.004436493, -0.04498291, 0.016815186, -0.015548706, 0.072021484, -0.013130188,
      -0.011047363, -0.037261963, 0.0029754639, 0.03503418, -0.0011749268, 0.04296875,
      -0.047912598, 0.011199951, -0.015571594, 0.033599854, 0.024536133, -0.025894165,
      -0.021102905, -0.015853882, -0.0029125214, 0.0032310486, 0.028045654, -0.022201538,
      -0.03677368, 0.015579224, 0.015098572, 0.00027275085, 0.07128906, 0.016677856,
      -0.01499939, 0.009925842, 0.020233154, -0.05810547, -0.052368164, -0.025283813,
      0.017227173, 0.023712158, 0.06185913, -0.015731812, 0.004009247, -0.007247925,
      0.026153564, 0.022598267, 0.035583496, 0.030288696, 0.014381409, 0.019638062,
      0.04925537, -0.061798096, 0.07739258, -0.047210693, -0.0057868958, -0.0050239563,
      -0.02029419, 0.05859375, -0.06781006, 0.08520508, 0.03881836, 0.047607422, 0.052520752,
      0.010848999, 0.008918762, -0.029190063, -0.010719299, -0.052001953, -0.027938843,
      -0.004219055, -0.036499023, 0.042114258, -0.023712158, -0.06085205, -0.04675293,
      0.045196533, -0.0357666, -0.018096924, 0.03253174, 0.00019216537, -0.039520264,
      0.019989014, 0.040863037, 0.023620605, 0.085754395, -0.019760132, 0.017929077,
      -0.04547119, -0.004016876, -0.013847351, 0.01184845, -0.043395996, 0.021224976,
      0.04244995, -0.0043029785, -0.0067481995, -0.040802002, -0.004627228, 0.053100586,
      -0.0017156601, 0.033050537, 0.011169434, 0.019134521, -0.008659363, 0.02633667,
      -0.016326904, 0.0007419586, -0.04220581, 0.019226074, -0.030349731, 0.071899414,
      0.019485474, -0.03515625, 0.004398346, -0.035736084, 0.021209717, -0.0036201477,
      0.0025577545, 0.008651733, 0.028305054, -0.0770874, -0.008399963, -0.05267334,
      0.025253296, 0.027862549, -0.027694702, 0.008422852, 0.02444458, -0.027145386,
      -0.030807495, 0.013023376, 0.03112793, -0.0007247925, -0.024749756, 0.02053833,
      -0.04473877, -0.056610107, -0.011131287, -0.02519226, -0.03414917, 0.0335083,
      0.03314209, -0.004081726, 0.024902344, 0.03164673, -0.06488037, 0.025802612,
      0.028289795, 0.048736572, 0.025253296, 0.017822266, -0.04611206, 0.026123047,
      0.013183594, 0.016067505, 0.022598267, 0.012245178, 0.029541016, -0.014274597,
      0.06427002, 0.032226562, 0.018966675, 0.000011563301, 0.040374756, 0.03189087,
      0.047912598, -0.012710571, -0.0129852295, -0.018005371, 0.017700195, 0.023635864,
      0.05340576, -0.019622803, -0.068481445, -0.049194336, 0.0014772415, 0.029266357,
      -0.0054512024, -0.033355713, -0.059326172, -0.00022089481, 0.04949951, -0.0058555603,
      -0.0074424744, -0.0013589859, -0.02243042, -0.0063591003, 0.026016235, -0.013381958,
      0.09729004, 0.008163452, -0.036499023, -0.04864502, -0.016296387, -0.035339355,
      -0.031707764, 0.00081920624, -0.0061950684, 0.012550354, -0.005470276, 0.016784668,
      -0.007972717, 0.054992676, 0.050872803, 0.023422241, 0.024093628, -0.039642334,
      0.04171753, -0.001496315, 0.018493652, -0.026565552, -0.028762817, 0.022323608,
      0.012863159, -0.05770874, 0.016448975, 0.008384705, 0.025253296, -0.024902344,
      -0.01727295, -0.055603027, -0.03881836, 0.005191803, -0.023925781, 0.03656006,
      -0.0054244995, -0.033355713, -0.06652832, -0.010383606, -0.018249512, 0.041778564,
      -0.03805542, 0.057739258, 0.010360718, 0.028839111, -0.011558533, 0.018798828,
      -0.009521484, -0.014198303, -0.07928467, -0.0005507469, 0.032440186, 0.095336914,
      0.03692627, 0.0647583, 0.027618408, 0.019500732, 0.030776978, 0.0231781, -0.028396606,
      0.009132385, -0.05316162, -0.039367676, 0.0027542114, -0.020889282, 0.017944336,
      -0.008872986, 0.03643799, -0.034301758, -0.011894226, 0.079956055, 0.059570312,
      -0.05432129, 0.0692749, 0.002035141, 0.024932861, -0.03527832, 0.014587402,
      -0.009727478, 0.023223877, 0.0034103394, -0.015266418, 0.052978516, -0.027954102,
      0.01739502, 0.005470276, -0.026763916, -0.019607544, -0.07720947, -0.041107178,
      -0.03640747, 0.04333496, 0.024505615, 0.04034424, -0.05529785, -0.0032672882,
      0.02166748, 0.00365448, 0.06628418, -0.0060424805, -0.024108887, 0.04888916,
      -0.021362305, -0.002248764, 0.0034160614, -0.05227661, 0.0041618347, -0.014144897,
      -0.00054073334, -0.05215454, 0.0032024384, -0.042053223, -0.049468994, -0.023986816,
      0.016326904, 0.010231018, 0.044403076, -0.0076942444, -0.012611389, -0.04510498,
      -0.03390503, -0.021911621, 0.024093628, 0.050964355, -0.010322571, -0.05557251,
      0.008201599, -0.006084442, 0.024841309, 0.0040016174, 0.05105591, -0.013206482,
      -0.024261475, 0.020141602, 0.039733887, -0.06903076, -0.046691895, 0.045318604,
      -0.024276733, -0.008056641, -0.0115737915, 0.0076675415, 0.011634827, -0.039855957,
      0.005138397, 0.024627686, 0.021530151, -0.007701874, -0.026565552, 0.0262146,
      -0.044891357, 0.039764404, -0.035888672, -0.011123657, -0.024536133, -0.044647217,
      0.01083374, -0.019744873, 0.05734253, 0.043640137, 0.03378296, 0.044311523,
      -0.0041923523, -0.02784729, 0.042297363, -0.0016870499, -0.03265381, -0.02330017,
      0.0063591003, -0.070373535, -0.01777649, -0.006084442, -0.019256592, -0.03225708,
      0.017745972, -0.043701172, 0.034729004, -0.0236969, 0.03829956, 0.0011920929,
      -0.096191406, 0.0105896, -0.006175995, 0.022018433, -0.015853882, 0.029663086,
      -0.0552063, -0.016860962, -0.049743652, 0.034698486, -0.07788086, -0.00062799454,
      -0.033721924, 0.04397583, -0.0058631897, -0.0115737915, 0.008972168, 0.008430481,
      0.061523438, 0.021942139, -0.0024204254, 0.0017471313, 0.00598526, -0.018127441,
      0.04638672, 0.047912598, -0.020065308, 0.021408081, 0.00737381, -0.015808105,
      0.025650024, -0.045166016, -0.063964844, 0.02017212, -0.06573486, 0.011108398,
      -0.003730774, -0.003768921, 0.011413574, -0.007827759, -0.011062622, 0.012619019,
      -0.08618164, -0.030181885, 0.01889038, 0.042785645, -0.024490356, -0.012260437,
      0.025238037, 0.07019043, 0.032440186, -0.029296875, -0.025985718, -0.0491333,
      -0.04159546, -0.0037212372, 0.014785767, 0.0009870529, -0.044555664, -0.06573486,
      0.04498291, -0.012306213, -0.0032024384, -0.043029785, -0.049224854, -0.051239014,
      0.01713562, -0.037719727, 0.013092041, -0.027359009, 0.014305115, -0.008552551,
      -0.05496216, 0.06732178, -0.015174866, 0.0423584, 0.010597229, 0.04888916, -0.06524658,
      -0.037261963, -0.03656006, 0.008331299, -0.030471802, -0.024780273, -0.019821167,
      0.059143066, 0.028213501, 0.049560547, 0.004497528, 0.036010742, 0.023468018,
      -0.011383057, -0.028030396, 0.005783081, -0.0014343262, -0.011734009, -0.027694702,
      -0.031463623, 0.023925781, -0.0056991577, -0.0034065247, -0.057769775, 0.056610107,
      -0.042510986, 0.034851074, -0.015220642, 0.021514893, 0.044647217, -0.02268982,
      0.042144775, -0.02243042, -0.043029785, -0.03387451, -0.014549255, -0.036102295,
      0.010940552, -0.015060425, 0.037353516, 0.0074882507, -0.05996704, -0.019134521,
      0.029678345, 0.08898926, -0.01663208, -0.011482239, -0.014595032, -0.008888245,
      0.06719971, -0.05899048, 0.010360718, 0.017089844, 0.0104599, 0.06488037, 0.011245728,
      -0.0052948, 0.029953003, 0.047424316, 0.051116943, -0.015655518, -0.026123047,
      -0.058380127, -0.03375244
    ],
  }
```


view thread (4+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-717@github.com>
Permalink:  ../gh-pgvector-pgvector-717@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox