Text Embedding
Generate vector embeddings for single text inputs using .GENEmbed().
Basic Usage
float[] embedding = await "Hello, world!"
.GENEmbed()
.ExecuteAsync();
Debug.Log($"Embedding dimensions: {embedding.Length}");Configuration
Model Selection
// OpenAI - Small (1536 dimensions, faster)
float[] embedding = await "Search query"
.GENEmbed()
.SetModel(OpenAIModel.TextEmbedding3Small)
.ExecuteAsync();
// OpenAI - Large (3072 dimensions, more accurate)
float[] embedding = await "Search query"
.GENEmbed()
.SetModel(OpenAIModel.TextEmbedding3Large)
.ExecuteAsync();
// Google
float[] embedding = await "Search query"
.GENEmbed()
.SetModel(GoogleModel.TextEmbedding004)
.ExecuteAsync();Unity Integration Examples
Example 1: Document Search Engine
Example 2: FAQ Matcher
Example 3: Content Deduplication
Example 4: Smart Categorization
Provider Support
OpenAI
Google
Similarity Calculation
Cosine Similarity
Most common method for comparing embeddings:
Returns value between -1 and 1:
1.0: Identical
0.5+: Similar
0.0: Unrelated
-1.0: Opposite
Euclidean Distance
Alternative method:
Lower distance = more similar.
Best Practices
✅ Good Practices
❌ Bad Practices
Use Cases
Use Case
Description
Semantic Search
Find relevant documents
FAQ Matching
Match questions to answers
Deduplication
Detect similar content
Categorization
Classify content
Recommendations
Suggest similar items
Clustering
Group related items
Performance Tips
Next Steps
Batch Embedding - Process multiple texts
Last updated