# Embedding

A list of numbers (a vector, often 384 or 1536 long) that captures the meaning of a piece of text. Similar meanings get similar numbers.

AI developers · Part 05: Embeddings + RAG · Card 1 of 14 · Last updated 2026-10-13

## Analogy

A hash function that went to therapy: instead of scrambling everything, it puts similar ideas next to each other.

## Code example

`embed.ts`

```typescript
const res = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: "How do I revert a deploy?",
});

const vector = res.data[0].embedding; // [0.12, -0.80, 0.33, ...]
```

## In an agent

Embeddings power semantic search, which is how agents find the right docs to read.

## Practice

### Flashcards

- **What is an embedding?** A list of numbers that represents the meaning of text. Similar meanings end up close together.
- **Interview: four uses for embeddings?** Semantic search, RAG, deduplication and clustering.

### Interview questions

**What are embeddings?**

- Vectors that represent meaning.
- Similar meanings give nearby vectors, measured with cosine similarity.
- They power semantic search, RAG, deduplication and clustering.

## Questions people ask

### What is an embedding in AI?

An embedding is a list of numbers, a vector often 384 or 1536 long, that captures the meaning of a piece of text. Texts with similar meanings get vectors that sit close together. That makes it possible to search, group or compare text by meaning instead of by exact words.

### How do I create embeddings in JavaScript?

Call an embeddings endpoint, for example client.embeddings.create with model text-embedding-3-small and your text as input. The vector is in data[0].embedding. You can also run a small open model locally with Transformers.js. Store each vector next to its text, usually in a vector database.

## Related concepts

- [Semantic search](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/semantic-search)
- [Cosine similarity](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/cosine-similarity)
- [Vector database](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/vector-database)
- [RAG](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/rag)

Web page: https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/embedding
Study this card in the app: https://studyvisually.com/app/learn?category=ai-developers&card=embedding
