You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core-concepts/embeddings.md
+44-11Lines changed: 44 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Embeddings
2
2
3
-
Transform your content into powerful vector representations! Embeddings let you add semantic search, recommendation systems, and other advanced features to your applications - whether you're working with textor images.
3
+
Transform your content into powerful vector representations! Embeddings let you add semantic search, recommendation systems, and other advanced features to your applications - whether you're working with text, images, audio, video, or documents.
4
4
5
5
## Quick Start
6
6
@@ -24,7 +24,7 @@ echo $response->usage->tokens;
24
24
25
25
## Generating multiple embeddings
26
26
27
-
You can generate multiple embeddings at once with all providers that support embeddings, other than Gemini:
27
+
You can generate multiple embeddings at once with providers that support batch embeddings:
> Make sure your file exists and is readable. The generator will throw a helpful `PrismException` if there's any issue accessing the file.
88
88
89
-
## Image Embeddings
89
+
## Multimodal Embeddings
90
90
91
-
Some providers support image embeddings, enabling powerful use cases like visual similarity search, cross-modal retrieval, and multimodal applications. Prism makes it easy to generate embeddings from images using the same fluent API.
91
+
Some providers support multimodal embeddings, enabling powerful use cases like visual similarity search, cross-modal retrieval, and mixed media retrieval. Prism makes it easy to generate embeddings from images, audio, video, and documents using the same fluent API.
92
92
93
93
> [!IMPORTANT]
94
-
> Image embeddings require a provider and model that supports image input (such as CLIP-based models or multimodal embedding models like BGE-VL). Check your provider's documentation to confirm image embedding support.
94
+
> Multimodal embeddings require a provider and model that supports the input modalities you send. Check your provider's documentation to confirm support for images, audio, video, documents, and grouped content.
95
95
96
96
### Single Image
97
97
@@ -131,25 +131,58 @@ foreach ($response->embeddings as $embedding) {
131
131
}
132
132
```
133
133
134
-
### Multimodal: Text + Image
134
+
### Audio, Video, and Documents
135
135
136
-
Combine text and images for cross-modal search scenarios. This is particularly useful for applications like "find products similar to this image that match this description":
Use `fromContents()` when you want multiple embeddings in a single request:
168
+
169
+
```php
170
+
use Prism\Prism\Facades\Prism;
171
+
use Prism\Prism\ValueObjects\Media\Image;
172
+
173
+
$response = Prism::embeddings()
174
+
->using('provider', 'model')
175
+
->fromContents([
176
+
['The dog is cute'],
177
+
[Image::fromLocalPath('/path/to/dog.png')],
178
+
])
146
179
->asEmbeddings();
147
180
```
148
181
149
-
You can chain `fromImage()` and `fromInput()` in any order - Prism handles both gracefully.
182
+
You can still chain `fromInput()` and `fromImage()` in any order. Each chained call creates a separate content entry.
150
183
151
184
> [!TIP]
152
-
> The `Image` class supports multiple input sources: `fromLocalPath()`, `fromUrl()`, `fromBase64()`, `fromStoragePath()`, and `fromRawContent()`. See the [Images documentation](/input-modalities/images.html) for details.
185
+
> Prism media value objects support multiple input sources. See the [Images documentation](/input-modalities/images.html) and related modality guides for details.
Copy file name to clipboardExpand all lines: docs/providers/gemini.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -395,6 +395,65 @@ $response = Prism::text()
395
395
396
396
You can customize your Gemini embeddings request with additional parameters using `->withProviderOptions()`.
397
397
398
+
### Gemini Embedding 2 Preview
399
+
400
+
Gemini's `gemini-embedding-2-preview` model supports text, images, audio, video, and PDF documents in a unified embedding space. Use Prism's content entry API to control whether you want a single aggregated embedding or multiple embeddings in one request.
0 commit comments