---
title: embeddings | CodeWeaver Docs
description: API reference for codeweaver.core.types.embeddings
url: "https://docs.knitli.com/api/core/types/embeddings"
type: static
generatedAt: "2026-04-17T17:21:08.168Z"
---

# embeddings
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/core/types/embeddings.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F&text=embeddings)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F&text=embeddings)[Share on Bluesky](https://bsky.app/intent/compose?text=embeddings%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F&title=embeddings)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F&t=embeddings)[Share on Email](mailto:?subject=embeddings&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F)[Share on WhatsApp](https://wa.me/?text=embeddings%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Ftypes%2Fembeddings%2F&text=embeddings)
# `codeweaver.core.types.embeddings`
[Section titled “codeweaver.core.types.embeddings”](#codeweavercoretypesembeddings)
Core embedding type definitions for CodeWeaver.

## Class: `ChunkEmbeddings`
[Section titled “Class: ChunkEmbeddings”](#class-chunkembeddings)
Model representing the embeddings associated with a specific CodeChunk.

Uses a dynamic dictionary to support arbitrary named embeddings (intents). Common keys include: “primary”, “sparse”, “backup”, “summary”, “ast”.

### Method: `add`
[Section titled “Method: add”](#method-add)

**

```
add()
```

Add an EmbeddingBatchInfo to the ChunkEmbeddings.

Args: embedding_info: The embedding information to add (intent is extracted from this object).

Returns: ChunkEmbeddings: A new ChunkEmbeddings instance with the added embedding.

Raises: ValueError: If embedding already exists for this intent or chunk IDs don’t match.

### Method: `get_model_by_vector_intent`
[Section titled “Method: get_model_by_vector_intent”](#method-get_model_by_vector_intent)

**

```
get_model_by_vector_intent()
```

Get the model name used for a specific embedding intent, if it exists.

### Method: `update`
[Section titled “Method: update”](#method-update)

**

```
update()
```

Update or replace an EmbeddingBatchInfo in the ChunkEmbeddings.

Unlike `add()`, this method will replace existing embeddings of the same intent. This is useful for re-embedding scenarios where we want to update embeddings.

Args: embedding_info: The embedding information to update/replace (intent is extracted from this object).

Returns: ChunkEmbeddings: A new ChunkEmbeddings instance with the updated embedding.

Raises: ValueError: If chunk IDs don’t match.

## Class: `CodeWeaverSparseEmbedding`
[Section titled “Class: CodeWeaverSparseEmbedding”](#class-codeweaversparseembedding)
NamedTuple representing sparse embedding with indices and values.

Sparse embeddings are represented as two parallel arrays:

 - indices: positions in the vocabulary that have non-zero values
 - values: weights/importance scores for those positions

This format is used by SPLADE, SparseEncoder and similar models.

### Method: `to_tuple`
[Section titled “Method: to_tuple”](#method-to_tuple)

**

```
to_tuple()
```

Convert to a CodeWeaverSparseEmbedding with tuples for indices and values.

## Class: `DataType`
[Section titled “Class: DataType”](#class-datatype)
Enum representing the data type of embedding vectors.

### Method: `cross_walk`
[Section titled “Method: cross_walk”](#method-cross_walk)

**

```
cross_walk()
```

Get the corresponding data type string for crosswalks.

## Class: `EmbeddingBatchInfo`
[Section titled “Class: EmbeddingBatchInfo”](#class-embeddingbatchinfo)
BasedModel representing metadata about a CodeChunk’s embedding within a batch.

### Method: `create_dense`
[Section titled “Method: create_dense”](#method-create_dense)

**

```
create_dense()
```

Create EmbeddingBatchInfo for dense embeddings.

### Method: `create_sparse`
[Section titled “Method: create_sparse”](#method-create_sparse)

**

```
create_sparse()
```

Create EmbeddingBatchInfo for sparse embeddings.

Args: batch_id: Unique identifier for the batch batch_index: Index within the batch chunk_id: Unique identifier for the chunk model: Model name embeddings: CodeWeaverSparseEmbedding with indices and values intent: Intent/purpose of this embedding (default: “sparse”) dimension: Dimensionality of the embedding (always 0 for sparse) dtype: Data type of the embedding values

## Class: `EmbeddingKind`
[Section titled “Class: EmbeddingKind”](#class-embeddingkind)
Enum representing the kind of embedding.

## Class: `QueryResult`
[Section titled “Class: QueryResult”](#class-queryresult)
Multi-vector embedding result from an embedding query.

Stores embeddings from multiple intents (primary, backup, sparse, etc.) in a dictionary keyed by intent name.

### Method: `get`
[Section titled “Method: get”](#method-get)

**

```
get()
```

Get embedding for an intent with optional default.