Embeddings
Usage guide of embeddings endpoint
Introduction to Embeddings
OpenAI’s text embeddings measure the relatedness of text strings. Embeddings are commonly used for:
Search (where results are ranked by relevance to a query string)
Clustering (where text strings are grouped by similarity)
Recommendations (where items with related text strings are recommended)
Anomaly detection (where outliers with little relatedness are identified)
Diversity measurement (where similarity distributions are analyzed)
Classification (where text strings are classified by their most similar label)
An embedding is a vector (list) of floating point numbers. The distance between two vectors measures their relatedness. Small distances suggest high relatedness and large distances suggest low relatedness.
Currently available Embedding models are:
text-embedding-3-large
Most capable embedding model for both english and non-english tasks
3,072
text-embedding-3-small
Increased performance over 2nd generation ada embedding model
1,536
text-embedding-ada-002
Most capable 2nd generation embedding model, replacing 16 first generation models
1,536
Using Embeddings
To use embeddings, you simply need to send a post request to the embeddings endpoint (https://api.webraft.in/v2/embeddings) with an input field containing text and a model field containing the model name.
Python
You can use the requests
library to make HTTP requests in Python. First, you need to install requests
if you haven't already:
Then, you can use the following code:
Curl
Here is the complete curl
command:
Node.js
You can use the axios
library to make HTTP requests in Node.js. First, you need to install axios
if you haven't already:
Then, you can use the following code:
The response will contain the embedding vector along with some additional metadata. Example Response:
In the next section, we'll talk about integrating webraftai api with commonly known AI softwares.
Last updated