NAME

get-embeddings.pl - Get embeddings from the OpenAI API

SYNOPSIS

perl get-embeddings.pl

DESCRIPTION

When working with LLMs, strings are first tokenized and then converted into embeddings. Sometimes, when working with other tools, they expect embeddings instead of the strings. This script demonstrates how to get embeddings from the OpenAI API using the `createEmbedding` method.

MODELS

  • text-embedding-3-small

    This model is the most cost-effective, optimized for latency and storage. This is 5x cheaper than text-embedding-ada-002 ($0.00002 per 1k tokens).

    1536 dimensions

  • text-embedding-3-large

    This model is priced higher and is best suited for tasks requiring high accuracy.

    $0.00013 per 1k tokens.

    Up to 3072 dimensions

  • text-embedding-ada-002

    This model falls between the two in terms of pricing.

    $0.0001 per 1k tokens.

    1536 dimensions