Using the Semantic Search endpoint
In Chapter 2, GPT-3 Applications and Use Cases, we discussed semantic search. By way of a review, semantic search lets you perform a Google-like search over a list of provided documents. A query (a word, phrase, question, or statement) is compared to the contents of documents to determine whether semantic similarities exist. The result is a ranking, or score, for each document. The score is usually between 0 and 300 but can sometimes go higher. A higher score, above 200, typically means the document is semantically similar to the query.
To perform a semantic search using the API, you'll make a POST request to the Semantic Search endpoint. Like the Create Completions endpoint, you'll also include a JSON object in the request body. The JSON body object has two elements – the documents element and the query element. The documents element is an array of documents to be searched, and each item in the array is a string that represents...