What would be the proper way to insert chunks of embeddings with meta data for a Q&A file?

I am getting undefined metadata and ID from a vector that I want to upload to the database… how can I fix it?

I am new at this and fist time using Pinecone, and I am not sure if I am doing the right approach.

I want to create an Q&A bot from OpenAI, and I am using Pinecone as a database.

First I have a json file that looks like this:

[
{
“id:”: 1,
“question:”: "What are your hours of operations? ",
“answer:”: "We open at 10am and close at 8pm. "
},
{
“id:”: 2,
“question:”: “Do you offer vegetarian food?”,
“answer:”: “Yes, we have a vegetarian menu to choose from”
}
]

^^^ Now I am splitting maybe 20-30 questions into chunks <— Is that OK?

Once I get the chuncks I am trying to create vectors to then upsert it into Pinecone… but the vector is not looking as expected… and getting some of the metadata as undefined…

Could somebody be so awesome on a feedback on how to properly prepare this vector before uploading it into the Pinecone database?

code I have is:

let vector = embeddingResult.data.map((item, i) => {
return {
id: item.id,
metadata: {
question: item.question,
answer: item.answer,
},
values: embeddings[i],
};
});
console.log(vector);

and when I do console.log from the vector… I get undefined metadata and ID…

id: undefined,
metadata: { question: undefined, answer: undefined },
values: [
-0.014396188, 0.0010330598, -0.005212655, 0.016514925,
0.0033166655, 0.031767026, -0.043076314, -0.017469058,

Looks like you have an extra colon “:” in the JSON keys, where you have

{
"id:": 1,
   ^
"question:": "What are your hours of operations? ",
         ^
"answer:": "We open at 10am and close at 8pm. "
       ^
}

instead of

{
"id": 1,
"question": "What are your hours of operations? ",
"answer": "We open at 10am and close at 8pm. "
}

I’m not sure what you mean by “the vector is not looking as expected”, can you say more about why it is not as expected?

1 Like

Oh thanks for pointing out about the extra colon…

I think this problem is fixed… just needed to understand what are the metadata and that I needed to input it manually…

Hey I do have other errors that I will post pretty soon here :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.