- Newest
- Most votes
- Most comments
Hi Vishal! Thanks for reaching out.
Refer to the below snippet to generate a vector embedding for a sentence stored in a string:
from langchain.embeddings import BedrockEmbeddings
#create an Amazon Titan Text Embeddings client
embeddings_client = BedrockEmbeddings()
#Define the text from which to create embeddings
text = "Can you please tell me how to get to the bakery?"
#Invoke the model
embedding = embeddings_client.embed_query(text)
#Print response
print(embedding)
This snippet was pulled from the "Getting started with Amazon Titan Text Embeddings in Amazon Bedrock" blog - https://aws.amazon.com/blogs/machine-learning/getting-started-with-amazon-titan-text-embeddings/
You'll be able to get the full example in the above link so please feel free to review this resource for additional, insightful information. This example uses the boto3 library which you can also use for authentication. That said, credentials can be configured in multiple ways so I'll point you to another relevant resource. You can choose which method is most appropriate given your specific use-case and/or needs which is helpful if you're working within a local Jupyter notebook - https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
Cheers!
Relevant content
- asked 6 months ago
- asked 5 months ago
- Accepted Answerasked 5 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 6 days ago
- AWS OFFICIALUpdated a month ago