Skip to content

Prompting and Embedding

Our metadata transformers are generic over the SimplePrompt trait. This enables different models to be used for different usecases. Similarly, the embedding transformer is generic over the EmbeddingModel trait.

The SimplePrompt trait

Which is defined as follows:

pub trait SimplePrompt: Debug + Send + Sync {
async fn prompt(&self, prompt: Prompt) -> Result<String>;
}

Or in human language: “Given a Prompt, give me a response”. Prompts can be created from strings, loaded from a template repository, or loaded from files. They use Tera under the hood.

The EmbeddingModel trait

Which is defined as follows:

pub trait EmbeddingModel: Send + Sync {
async fn embed(&self, input: Vec<String>) -> Result<Embeddings>;
}

Or in human language: “Given a list of things to Embed, give me embeddings”. The embedding transformer will link back the embeddings to the original nodes by order.

Built in inference and embedding models

NameDescriptionFeature Flag
OpenAIImplements both SimplePrompt and Embed via async_openaiopenai
FastEmbedImplements Embed via fastembed-rs, including many dense and sparse modelsfastembed
Titan (Bedrock)AWS Titan via Bedrockaws-bedrock
Anthropic models (Bedrock)Recent Anthropic models via Bedrockaws-bedrock
GroqImplements SimplePromptgroq
ollamaImplements both SimplePrompt and Embed via ollama-rs, using local modelsollama