OpenAI.Embeddings API Endpoint

From GM-RKB
(Redirected from OpenAI.Embeddings)
Jump to navigation Jump to search

An OpenAI.Embeddings API Endpoint is a text-item embedding web service endpoint that is an OpenAI API endpoint.



References

2024

  • https://platform.openai.com/docs/guides/embeddings
    • It provides a way to convert text strings into numerical vectors, enabling various applications like search, clustering, and recommendation systems.
    • It includes new models, text-embedding-3-small and text-embedding-3-large, which offer improved performance, lower costs, and enhanced multilingual capabilities.
    • It measures the relatedness of text by generating embeddings, which are vectors of floating point numbers where distances between vectors indicate relatedness.
    • It requires sending text strings to the embeddings API endpoint with a specified model name to receive an embedding vector in response.
    • It allows for the adjustment of the dimensionality of the embedding vectors to suit different use cases without losing conceptual information.
    • It supports a wide range of use cases, including but not limited to, question answering, text and code search, recommendations, and as feature encoders for machine learning algorithms.
    • It answers frequently asked questions regarding the use of embeddings, including token counting, vector database retrieval, distance functions, sharing of embeddings, and the knowledge cutoff for the models.
    • Example requests:
curl https://api.openai.com/v1/embeddings \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer $OPENAI_API_KEY" \
 -d '{
   "input": "Your text string goes here",
   "model": "text-embedding-3-small"
 }'

2023

  • chat
# Create an embedding for a text string
response = openai.Embedding.create(
 input = "canine companions say",
 model = "text-embedding-ada-002")
# Get the embedding vector
embedding = response["data"][0]["embedding"]
# Print the size of the embedding vector
print("The size of the embedding vector is:", len(embedding))
>> The size of the embedding vector is: 1536

2023

  • https://platform.openai.com/docs/guides/embeddings
    • QUOTE: ... To get an embedding, send your text string to the embeddings API endpoint along with a choice of embedding model ID (e.g., text-embedding-ada-002). The response will contain an embedding, which you can extract, save, and use.
    • Example requests:
curl https://api.openai.com/v1/embeddings \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer $OPENAI_API_KEY" \
 -d '{
   "input": "Your text string goes here",
   "model": "text-embedding-ada-002"
 }'