跳转到内容
For the complete documentation index, see llms.txt. This page is also available as Markdown.

嵌入提供商

集成将文本转换为向量以用于语义搜索的服务。

将您的文本转换为向量表示!嵌入让您可以添加检索增强生成(RAG)到您的 AI 应用中。

可用的嵌入提供商

该框架已经包含以下嵌入提供商。

Ollama

使用 Ollama,您可以在本地运行嵌入模型。文档 - https://ollama.com/blog/embedding-models

namespace App\Neuron;

use NeuronAI\RAG\Embeddings\EmbeddingsProviderInterface;
use NeuronAI\RAG\Embeddings\OllamaEmbeddingsProvider;
use NeuronAI\RAG\RAG;

class MyRAG extends RAG
{
    ...
    
    protected function embeddings(): EmbeddingsProviderInterface
    {
        return new OllamaEmbeddingsProvider(
            model: 'OLLAMA_EMBEDDINGS_MODEL'
        );
    }
}

Voyage AI

文档 - https://www.voyageai.com/

OpenAI

文档 - https://platform.openai.com/docs/guides/embeddings

OpenAILikeEmbeddings

您可以使用任何与 OpenAI API 格式兼容的提供商:

Gemini

Cohere

Aws Bedrock

实现一个新的提供商

要创建自定义提供商,您只需扩展 AbstractEmbeddingsProvider 类。该类已经实现了框架特定的方法,您只需自由实现其中唯一的提供商特定 HTTP 调用即可: embedText() 方法:

您应该根据自定义提供商的 API 来调整 HTTP 请求。

最后更新于