blob: 4b38629cb50029b4aa42b26f41c5469cb1273b9e [file] [log] [blame]
ben-aaron188287b30b2022-09-11 16:46:37 +02001% Generated by roxygen2: do not edit by hand
ben-aaron1882b89c2a2022-09-11 16:54:25 +02002% Please edit documentation in R/gpt3_single_embedding.R
ben-aaron188ca1c3982022-09-22 15:15:53 +02003\name{gpt3_single_embedding}
4\alias{gpt3_single_embedding}
ben-aaron188287b30b2022-09-11 16:46:37 +02005\title{Obtains text embeddings for a single character (string) from the GPT-3 API}
6\usage{
ben-aaron188ca1c3982022-09-22 15:15:53 +02007gpt3_single_embedding(input, model = "text-similarity-ada-001")
ben-aaron188287b30b2022-09-11 16:46:37 +02008}
9\arguments{
10\item{input}{character that contains the text for which you want to obtain text embeddings from the GPT-3 model}
11
12\item{model}{a character vector that indicates the \href{https://beta.openai.com/docs/guides/embeddings/similarity-embeddings}{similarity embedding model}; one of "text-similarity-ada-001" (default), "text-similarity-curie-001", "text-similarity-babbage-001", "text-similarity-davinci-001"}
13}
14\value{
15A numeric vector (= the embedding vector)
16}
17\description{
ben-aaron188ca1c3982022-09-22 15:15:53 +020018\code{gpt3_single_embedding()} sends a single \href{https://beta.openai.com/docs/guides/embeddings}{embedding request} to the Open AI GPT-3 API.
ben-aaron188287b30b2022-09-11 16:46:37 +020019}
20\details{
21The function supports the text similarity embeddings for the four GPT-3 models as specified in the parameter list. The main difference between the four models is the sophistication of the embedding representation as indicated by the vector embedding size.
22\itemize{
23\item Ada (1024 dimensions)
24\item Babbage (2048 dimensions)
25\item Curie (4096 dimensions)
26\item Davinci (12288 dimensions)
27}
28
29Note that the dimension size (= vector length), speed and \href{https://openai.com/api/pricing/}{associated costs} differ considerably.
30
31These vectors can be used for downstream tasks such as (vector) similarity calculations.
32}
33\examples{
34# First authenticate with your API key via `gpt3_authenticate('pathtokey')`
35
36# Once authenticated:
37
38## Simple request with defaults:
39sample_string = "London is one of the most liveable cities in the world. The city is always full of energy and people. It's always a great place to explore and have fun."
ben-aaron188ca1c3982022-09-22 15:15:53 +020040gpt3_single_embedding(input = sample_string)
ben-aaron188287b30b2022-09-11 16:46:37 +020041
42## Change the model:
ben-aaron188ca1c3982022-09-22 15:15:53 +020043#' gpt3_single_embedding(input = sample_string
ben-aaron188287b30b2022-09-11 16:46:37 +020044 , model = 'text-similarity-curie-001')
45}