35 lines
1.1 KiB
Markdown
35 lines
1.1 KiB
Markdown
---
|
|
slug: /default-embedding-function-of-api
|
|
---
|
|
|
|
# Default embedding function
|
|
|
|
An embedding function converts text documents into vector embeddings for similarity search. pyseekdb supports built-in and custom embedding functions.
|
|
|
|
The `DefaultEmbeddingFunction` is the default embedding function if none is specified. This function is already available in seekdb and does not need to be created separately.
|
|
|
|
Here is an example:
|
|
|
|
```python
|
|
from pyseekdb import DefaultEmbeddingFunction
|
|
|
|
# Use default model (all-MiniLM-L6-v2, 384 dimensions)
|
|
ef = DefaultEmbeddingFunction()
|
|
|
|
# Use custom model
|
|
ef = DefaultEmbeddingFunction()
|
|
|
|
# Get embedding dimension
|
|
print(f"Dimension: {ef.dimension}") # 384
|
|
|
|
# Generate embeddings
|
|
embeddings = ef(["Hello world", "How are you?"])
|
|
print(f"Generated {len(embeddings)} embeddings, each with {len(embeddings[0])} dimensions")
|
|
```
|
|
|
|
## Related operations
|
|
|
|
If you want to use a custom function, you can refer to the following topics to create and use a custom function:
|
|
|
|
* [Create a custom embedding function](200.create-custim-embedding-functions-of-api.md)
|
|
* [Use a custom embedding function](300.using-custom-embedding-functions-of-api.md) |