scrimba
AI Engineering
Embeddings and Vector Databases
Challenge: Pair text with embedding
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Challenge: Pair text with embedding
AboutCommentsNotes
Challenge: Pair text with embedding
Expand for more info
index.js
run
preview
console
import openai from './config.js';

const content = [
"Beyond Mars: speculating life on distant planets.",
"Jazz under stars: a night in New Orleans' music scene.",
"Mysteries of the deep: exploring uncharted ocean caves.",
"Rediscovering lost melodies: the rebirth of vinyl culture.",
"Tales from the tech frontier: decoding AI ethics.",
];

/*
Challenge: Pair text with its embedding
- For each text input, create an object with
a 'content' and 'embedding' property
- The value of 'content' should be the text
- The value of 'embedding' should be the vector embedding for that text
*/

async function main() {
const embedding = await openai.embeddings.create({
model: "text-embedding-ada-002",
input: content,
});
console.log(embedding.data);
}
main();
Console
/index.html
-4:22