Embeddings¶
pgraf.embeddings
¶
Engine
¶
HuggingFace
¶
Handles the generation of vector embeddings for text content.
This class provides functionality to convert text into vector embeddings using sentence transformers. It handles chunking of text to ensure optimal embedding generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | None
|
The sentence transformer model to use for embeddings |
DEFAULT_HUGGING_FACE_MODEL
|
Source code in pgraf/embeddings.py
__init__(model=DEFAULT_HUGGING_FACE_MODEL)
¶
Initialize the embeddings generator with the specified model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | None
|
The sentence transformer model to use (defaults to 'all-MiniLM-L6-v2') |
DEFAULT_HUGGING_FACE_MODEL
|
Source code in pgraf/embeddings.py
get(value)
¶
Generate embeddings for the provided text value.
The text is automatically chunked into manageable pieces using sentence boundaries and maximum word count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The text to generate embeddings for |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
A list of numpy arrays containing the embeddings for each chunk |
Source code in pgraf/embeddings.py
OpenAI
¶
Handles the generation of vector embeddings for text content using the OpenAI client
Source code in pgraf/embeddings.py
__init__(model=DEFAULT_OPENAI_MODEL, api_key=None)
¶
Initialize the embeddings generator with the specified model.
Source code in pgraf/embeddings.py
get(value)
¶
Generate embeddings for the provided text value.
The text is automatically chunked into manageable pieces using sentence boundaries and maximum word count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The text to generate embeddings for |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
A list of numpy arrays containing the embeddings for each chunk |