feat: Amazon Bedrock Support ⛰️#9
Open
JGalego wants to merge 11 commits intoasg017:mainfrom
Open
Conversation
Author
|
Tested multimodal queries with Amazon Titan Multimodal Embeddings G1 (requires 🖼️ Data: images.zip Example: /**************
* MULTIMODAL *
**************/
-- Load sqlean extensions
.load ../sqlean/dist/crypto
.load ../sqlean/dist/fileio
.load ../sqlean/dist/text
-- Add Titan Embeddings Multimodal
insert into
temp.rembed_clients(name, options)
values
('amazon.titan-embed-image-v1', 'bedrock');
-- Create images table
create table multimodal(
input_text text,
input_image text --b64 encoded
);
-- Download images
.shell wget https://github.com/user-attachments/files/16530358/images.zip && unzip images.zip
-- Populate table with images
insert into multimodal
select
text_split(text_split(name, '/', -1), '.', 1),
encode(fileio_read(name), 'base64')
from
fileio_ls('./images')
where
name like '%.jpg';
-- Build a vector table for the multimodal embeddings
create virtual table vec_multimodal using vec0(
embeddings float[1024]
);
-- Embed text + images
insert into vec_multimodal(rowid, embeddings)
select
rowid,
rembed(
'amazon.titan-embed-image-v1',
input_text,
json(
concat(
'{"inputImage": "',
input_image,
'"}'
)
)
)
from
multimodal;
-- Run a multimodal query
.parameter set :query_image './images/puppy.jpg'
with matches as (
select
rowid,
distance
from vec_multimodal
where embeddings match
rembed(
'amazon.titan-embed-image-v1',
text_split(text_split(:query_image, '/', -1), '.', 1),
json(
concat(
'{"inputImage": "',
encode(fileio_read(:query_image), 'base64'),
'"}'
)
)
)
order by distance
limit 3
)
select
input_text,
distance
from matches
left join
multimodal
on
multimodal.rowid = matches.rowid;Output: |
Author
|
Added a fix for when the model ID contains 'bad' characters like colons The idea is to escape the model ID once ( Notice that the colon can appear multiple times in the model ID e.g. |
added 2 commits
August 8, 2024 15:40
Author
|
@asg017 would you mind reviewing this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR adds support for
EMBEDDINGmodels provided by Amazon Bedrock.Tested with Amazon Titan Embeddings Text and Cohere Embed.
Implementation includes ad-hoc functions to add AWS SigV4 signatures.
Example:
Output: