Class: MixedbreadAIEmbeddings()
Class for generating embeddings using the mixedbread ai API.
This class leverages the model "mixedbread-ai/mxbai-embed-large-v1" to generate embeddings for text documents. The embeddings can be used for various NLP tasks such as similarity comparison, clustering, or as features in machine learning models.
Examples
const mxbai = new MixedbreadAIEmbeddings({ apiKey: 'your-api-key' });
const texts = ["Baking bread is fun", "I love baking"];
const result = await mxbai.getTextEmbeddings(texts);
console.log(result);
const mxbai = new MixedbreadAIEmbeddings({
apiKey: 'your-api-key',
model: 'mixedbread-ai/mxbai-embed-large-v1',
encodingFormat: MixedbreadAI.EncodingFormat.Binary,
dimensions: 512,
normalized: true,
});
const query = "Represent this sentence for searching relevant passages: Is baking bread fun?";
const result = await mxbai.getTextEmbedding(query);
console.log(result);
Extends
MixedbreadAIEmbeddings<
Options
>(nodes
,options
?):Promise
<BaseNode
<Metadata
>[]>
Class for generating embeddings using the mixedbread ai API.
This class leverages the model "mixedbread-ai/mxbai-embed-large-v1" to generate embeddings for text documents. The embeddings can be used for various NLP tasks such as similarity comparison, clustering, or as features in machine learning models.
Type Parameters
• Options extends Record
<string
, unknown
>
Parameters
• options?: Options
Returns
Examples
const mxbai = new MixedbreadAIEmbeddings({ apiKey: 'your-api-key' });
const texts = ["Baking bread is fun", "I love baking"];
const result = await mxbai.getTextEmbeddings(texts);
console.log(result);
const mxbai = new MixedbreadAIEmbeddings({
apiKey: 'your-api-key',
model: 'mixedbread-ai/mxbai-embed-large-v1',
encodingFormat: MixedbreadAI.EncodingFormat.Binary,
dimensions: 512,
normalized: true,
});
const query = "Represent this sentence for searching relevant passages: Is baking bread fun?";
const result = await mxbai.getTextEmbedding(query);
console.log(result);
Defined in
packages/llamaindex/src/embeddings/MixedbreadAIEmbeddings.ts:81
Constructors
new MixedbreadAIEmbeddings()
new MixedbreadAIEmbeddings(
params
?):MixedbreadAIEmbeddings
Constructor for MixedbreadAIEmbeddings.
Parameters
• params?: Partial
<MixedbreadAIEmbeddingsParams
>
An optional object with properties to configure the instance.
Returns
Throws
If the API key is not provided or found in the environment variables.
Throws
If the batch size exceeds 256.
Overrides
Defined in
packages/llamaindex/src/embeddings/MixedbreadAIEmbeddings.ts:92
Properties
embedBatchSize
embedBatchSize:
number
Inherited from
Defined in
packages/core/dist/embeddings/index.d.ts:34
embedInfo?
optional
embedInfo:EmbeddingInfo
Inherited from
Defined in
packages/core/dist/embeddings/index.d.ts:35
id
id:
string
Inherited from
Defined in
packages/core/dist/schema/index.d.ts:171
requestOptions
requestOptions:
RequestOptions
Defined in
packages/llamaindex/src/embeddings/MixedbreadAIEmbeddings.ts:83
requestParams
requestParams:
EmbeddingsRequestWithoutInput
Defined in
packages/llamaindex/src/embeddings/MixedbreadAIEmbeddings.ts:82
Methods
getQueryEmbedding()
getQueryEmbedding(
query
):Promise
<null
|number
[]>
Parameters
• query: MessageContentDetail
Returns
Promise
<null
| number
[]>
Inherited from
BaseEmbedding
.getQueryEmbedding
Defined in
packages/core/dist/embeddings/index.d.ts:39
getTextEmbedding()
getTextEmbedding(
text
):Promise
<number
[]>
Generates an embedding for a single text.
Parameters
• text: string
A string to generate an embedding for.
Returns
Promise
<number
[]>
A Promise that resolves to an array of numbers representing the embedding.
Example
const query = "Represent this sentence for searching relevant passages: Is baking bread fun?";
const result = await mxbai.getTextEmbedding(text);
console.log(result);
Overrides
BaseEmbedding
.getTextEmbedding
Defined in
packages/llamaindex/src/embeddings/MixedbreadAIEmbeddings.ts:142
getTextEmbeddings()
getTextEmbeddings(
texts
):Promise
<number
[][]>
Optionally override this method to retrieve multiple embeddings in a single request
Parameters
• texts: string
[]
An array of strings to generate embeddings for.
Returns
Promise
<number
[][]>
A Promise that resolves to an array of embeddings.
Example
const texts = ["Baking bread is fun", "I love baking"];
const result = await mxbai.getTextEmbeddings(texts);
console.log(result);
Overrides
BaseEmbedding.getTextEmbeddings
Defined in
packages/llamaindex/src/embeddings/MixedbreadAIEmbeddings.ts:156
getTextEmbeddingsBatch()
getTextEmbeddingsBatch(
texts
,options
?):Promise
<number
[][]>
Get embeddings for a batch of texts
Parameters
• texts: string
[]
• options?: BaseEmbeddingOptions
Returns
Promise
<number
[][]>
Inherited from
BaseEmbedding
.getTextEmbeddingsBatch
Defined in
packages/core/dist/embeddings/index.d.ts:50
similarity()
similarity(
embedding1
,embedding2
,mode
?):number
Parameters
• embedding1: number
[]
• embedding2: number
[]
• mode?: SimilarityType
Returns
number
Inherited from
Defined in
packages/core/dist/embeddings/index.d.ts:37
truncateMaxTokens()
truncateMaxTokens(
input
):string
[]
Parameters
• input: string
[]
Returns
string
[]
Inherited from
BaseEmbedding
.truncateMaxTokens
Defined in
packages/core/dist/embeddings/index.d.ts:51