Exporting and using Word Embeddings:
The following is the example to use word embeddings
externally:
import openai
# Set up Azure OpenAI configuration
openai.api_type = "azure"
openai.api_version = "2022-12-01"
openai.api_base =
"YOUR_RESOURCE_NAME.openai.azure.com"
# Replace with your resource endpoint
openai.api_key = "YOUR_API_KEY" # Replace with your API key
# Initialize the embedding model
embeddings =
OpenAIEmbeddings(model="text-embedding-ada-002", chunk_size=1)
# Generate embeddings for your text
response = openai.Embedding.create(input="Sample
Document goes here", engine="YOUR_DEPLOYMENT_NAME")
embeddings = response['data'][0]['embedding']
print(embeddings)
No comments:
Post a Comment