Building the Ultimate RAG setup with Contextual Summaries, Sparse Vectors and Reranking

You’ll probably need to update the collection’s dimension size when creating the collection if you’re using OpenAI embeddings.

  • Cohere’s embedding model has a dimension size of 1024.
  • OpenAI’s text-embedding-small has a dimension size of 1536.
  • You can’t create a collection with one size of vector and then try to save differently sized vectors to it.
{
  "vectors": {
    "default": {
       "distance": "Cosine",
       "size": "1536"  // <-- example for text-embedding-small
    }
  },
  ...
}
1 Like

Thank you, that was it :slight_smile:

Hi,

I went ahead and also tried the local version wthout any changes and the
Qdrant with BM25 ReRank seems to be not properly configured.

it says Query is not defined as an answer to the query

{
  "query": "What is BTC?"
}


query is not defined
query is not defined

Error details
Other info

n8n version

1.62.4 (Self Hosted)

Time

10/11/2024, 3:03:31 PM

Error cause

{}

I tried to understand the code, but i dont get where is the input coming from and the query is obviously there

The issue and fix in the retriever for anyone else.

 const rankedDocs = await retriever.invoke(input);  // Use 'input' instead of 'query'
1 Like

@Jim_Le , I’m struggling with the following error in LangChain Code node:
Cannot read properties of undefined (reading ‘json’) [line 24]

Using latest template (local-only ver) with n8n v1.62.5

UPDATE
FIX of error in line 24:
Do NOT touch stock parameters of " Recursive Character Text Splitter" (size 2000, overlap 0).

@Jim_Le I’m getting a Problem in node ‘Insert Documents with Sparse Vectors‘ Bad Request null error using llama3.2 locally

If I remove this line const res = await client.upsert(collectionName, { points }) the code node completes correctly.