ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
ben-aaron188 | 2b89c2a | 2022-09-11 16:54:25 +0200 | [diff] [blame] | 2 | % Please edit documentation in R/gpt3_single_embedding.R |
ben-aaron188 | ca1c398 | 2022-09-22 15:15:53 +0200 | [diff] [blame] | 3 | \name{gpt3_single_embedding} |
| 4 | \alias{gpt3_single_embedding} |
ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 5 | \title{Obtains text embeddings for a single character (string) from the GPT-3 API} |
| 6 | \usage{ |
ben-aaron188 | 68434e4 | 2022-12-24 20:04:21 +0100 | [diff] [blame^] | 7 | gpt3_single_embedding(input, model = "text-embedding-ada-002") |
ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 8 | } |
| 9 | \arguments{ |
| 10 | \item{input}{character that contains the text for which you want to obtain text embeddings from the GPT-3 model} |
| 11 | |
ben-aaron188 | 68434e4 | 2022-12-24 20:04:21 +0100 | [diff] [blame^] | 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-embedding-ada-002" (default), "text-similarity-ada-001", "text-similarity-curie-001", "text-similarity-babbage-001", "text-similarity-davinci-001". Note: it is strongly recommend to use the faster, cheaper and higher quality second generation embeddings model "text-embedding-ada-002".} |
ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 13 | } |
| 14 | \value{ |
| 15 | A numeric vector (= the embedding vector) |
| 16 | } |
| 17 | \description{ |
ben-aaron188 | ca1c398 | 2022-09-22 15:15:53 +0200 | [diff] [blame] | 18 | \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-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 19 | } |
| 20 | \details{ |
| 21 | The 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{ |
ben-aaron188 | 68434e4 | 2022-12-24 20:04:21 +0100 | [diff] [blame^] | 23 | \item Second-generation embeddings model \code{text-embedding-ada-002} (1536 dimensions) |
ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 24 | \item Ada (1024 dimensions) |
| 25 | \item Babbage (2048 dimensions) |
| 26 | \item Curie (4096 dimensions) |
| 27 | \item Davinci (12288 dimensions) |
| 28 | } |
| 29 | |
| 30 | Note that the dimension size (= vector length), speed and \href{https://openai.com/api/pricing/}{associated costs} differ considerably. |
| 31 | |
| 32 | These vectors can be used for downstream tasks such as (vector) similarity calculations. |
| 33 | } |
| 34 | \examples{ |
| 35 | # First authenticate with your API key via `gpt3_authenticate('pathtokey')` |
| 36 | |
| 37 | # Once authenticated: |
| 38 | |
| 39 | ## Simple request with defaults: |
| 40 | sample_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-aaron188 | ca1c398 | 2022-09-22 15:15:53 +0200 | [diff] [blame] | 41 | gpt3_single_embedding(input = sample_string) |
ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 42 | |
| 43 | ## Change the model: |
ben-aaron188 | ca1c398 | 2022-09-22 15:15:53 +0200 | [diff] [blame] | 44 | #' gpt3_single_embedding(input = sample_string |
ben-aaron188 | 287b30b | 2022-09-11 16:46:37 +0200 | [diff] [blame] | 45 | , model = 'text-similarity-curie-001') |
| 46 | } |