I have a Supabase knowledge base where all embeddings are stored with 3072 dimensions (created with the text-embedding-3-large model). I connect this to an AI agent in n8n to ask questions.
When I query the Vector Retrieve tool in n8n with the text-embedding-3-large model and 3072 dims set as option, I get the following error:
Error searching for documents: 22000 different vector dimensions 1536 and 3072 null
What I have verified
Running:
SELECT vector_dims(embedding)
FROM knowledgebase
LIMIT 1;
confirms my stored embeddings are 3072 dims.
When I query the same Supabase RPC directly via the Supabase API, I get a correct and relevant response (no error).
This makes me suspect that n8n may be generating or passing 1536-dim vectors for the query, even though I have configured it to use text-embedding-3-large.
My question
Could it be that, despite explicitly selecting text-embedding-3-large (3072) in n8n, the embeddings node is actually generating 1536-dim vectors?
Or is there something in n8n’s Supabase / Vector Retrieve tool implementation that could be defaulting to the wrong dimension?
Please share your workflow
Share the output returned by the last node
Last node = vector retrieve tool. Only the error as stated above
Information on your n8n setup
n8n version: 1.102.3
database: PostgreSQL 14
EXECUTIONS_MODE: queue
Running n8n via: Docker in k8s
Operating System: Amazon Linux EKS 1.28.5-20240227
CREATE OR REPLACE FUNCTION public.match_knowledgebase(query_embedding vector, match_count integer DEFAULT 5, filter jsonb DEFAULT NULL::jsonb)
RETURNS TABLE(id bigint, content text, metadata jsonb, similarity double precision)
LANGUAGE sql
AS $function$
SELECT
d.id,
d.content,
d.metadata,
1 - (d.embedding <=> (query_embedding::vector(3072))) AS similarity
FROM public.documents d
WHERE (filter IS NULL OR d.metadata @> filter)
ORDER BY d.embedding <=> (query_embedding::vector(3072))
LIMIT match_count;
$function$
hi @jabbson, apologies, that’s not the correct match function.
When I printed the function I was messing around with the match function to try and fix it by explicitly mentioning the 3072 dims.
So you can disregard the last function, this is the right function (where I can query on query with 3072 dims through Supabase API, just mention EMBEDDING_MODEL=text-embedding-3-large there)
CREATE OR REPLACE FUNCTION public.match_knowledgebase(query_embedding vector, match_count integer DEFAULT 5, filter jsonb DEFAULT NULL::jsonb)
RETURNS TABLE(id bigint, content text, metadata jsonb, similarity double precision)
LANGUAGE sql
AS $function$
SELECT
kb.id,
kb.content,
kb.metadata,
1 - (kb.embedding <=> (query_embedding::vector(3072))) AS similarity
FROM public.knowledgebase kb
WHERE (filter IS NULL OR kb.metadata @> filter)
ORDER BY kb.embedding <=> (query_embedding::vector(3072))
LIMIT match_count;
$function$
based on SELECT pg_get_functiondef(‘public.match_knowledgebase(vector, integer, jsonb)’::regprocedure)
then enjoy your holiday! I’m still facing the same issue I’m afraid, but it can wait (I have a workaround in LangGraph, but it would be great if I can set this bot up in N8N so my non tech colleagues can tweak as well!)
hi @jabbson , now I’m back from a long holiday
I tried with a new table using your queries, but still getting ‘Error searching for documents: 22000 different vector dimensions 3072 and 1536 null‘ (I tried embedding 3-large with and without 3072 dimensions option), what’s the alternative, switch to another embedding model?