# DefaultEmbeddingGenerationService

Namespace: **Wisej.AI.Services**

Assembly: **Wisej.AI** (3.5.0.0)

Represents a service that provides functionality to generate embeddings for given text inputs using a [SmartEndpoint](https://docs.wisej.com/ai/components/api/smartendpoint)

{% tabs %}
{% tab title="C#" %}

```csharp
public class DefaultEmbeddingGenerationService : IEmbeddingGenerationService
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DefaultEmbeddingGenerationService
    Inherits IEmbeddingGenerationService
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) DefaultEmbeddingGenerationService(endpoint, vectorSize)

Initializes a new instance of the [DefaultEmbeddingGenerationService](https://docs.wisej.com/ai/components/api/services/iembeddinggenerationservice/wisej.ai.services.defaultembeddinggenerationservice) class with the specified endpoint and vector size.

| Name           | Type                                                                    | Description                                                                                                                                                                                             |
| -------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **endpoint**   | [SmartEndpoint](https://docs.wisej.com/ai/components/api/smartendpoint) | The endpoint used for embedding generation. If not specified, defaults to a new instance of [OpenAIEndpoint](https://docs.wisej.com/ai/components/api/smartendpoint/wisej.ai.endpoints.openaiendpoint). |
| **vectorSize** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)             | The size of the embedding vector. Default is 1536, which corresponds to the size for "text-embedding-3-small".                                                                                          |

## Properties

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) Endpoint

[SmartEndpoint](https://docs.wisej.com/ai/components/api/smartendpoint): Gets or sets the default endpoint used for generating embeddings. (Default: `Wisej.AI.Endpoints.OpenAIEndpoint`)

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) MaxArraySize

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the maximum number of text chunks that can be sent as an array to the provider. (Default: `512`)

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) VectorSize

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the dimension of the embedding vectors. (Default: `1536`)

## Methods

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) EmbedAsync(chunks)

Asynchronously generates an embedding for a given array of text chunks.

| Parameter  | Type                                                              | Description                                                         |
| ---------- | ----------------------------------------------------------------- | ------------------------------------------------------------------- |
| **chunks** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of text strings to be embedded. Must not be null or empty. |

**Returns:** [Task\<Embedding>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a result of type [Embedding](https://docs.wisej.com/ai/components/api/embeddings/wisej.ai.embeddings.embedding).

This method provides a way to generate embeddings for text data which can be utilized in various NLP tasks. Embeddings are numerical representations of text that capture semantic information.\
Applications may use embeddings for:

* Similarity comparisons
* Semantic searches
* Machine learning models

```csharp

  var textChunks = new[] { "Hello, world!", "C# is awesome." };
  var embeddings = await myEmbeddingService.EmbedAsync(textChunks);

```

## Implements

| Name                                                                                                         | Description                                                                      |
| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
| [IEmbeddingGenerationService](https://docs.wisej.com/ai/components/api/services/iembeddinggenerationservice) | Represents a service capable of generating embeddings from provided text chunks. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/api/services/iembeddinggenerationservice/wisej.ai.services.defaultembeddinggenerationservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
