
Family of Titan Text Models - CLI Demo
This is continuation of AWS Bedrock - Learning Series - Blog 1: https://community.aws/content/2ZAHJMCN4Ffi6W2DPJFIgq8MHkX
1
2
3
aws bedrock-runtime invoke-model --model-id amazon.titan-embed-text-v1 \
--body "{\"inputText\":\"Write a Article About AWS Cloudwatch for Linkedin\"}" \
--cli-binary-format raw-in-base64-out --region us-east-1 embedding-invoke-model-output.txt
1
2
3
$ cat embedding-invoke-model-output.txt | jq -r '.inputTextTokenCount'
"inputTextTokenCount":9,}
1
2
3
4
5
6
7
8
9
10
11
$ cat embedding-invoke-model-output.txt | jq -r '.embedding' | head
0.6015625,
-0.625,
0.28125,
-0.006958008,
-0.47460938,
0.26757812,
-0.38476562,
-0.0005950928,
-0.55859375,
1
2
3
4
aws bedrock-runtime invoke-model \
--model-id amazon.titan-text-lite-v1 \
--body "{\"inputText\":\"Write article about benifits of Sagemaker for DataScientist\",\"textGenerationConfig\":{\"maxTokenCount\":256,\"stopSequences\":[],\"temperature\":0,\"topP\":0.9}}" \
--cli-binary-format raw-in-base64-out --region us-east-1 titanlite-invoke-model-output.txt
1
$ cat titanlite-invoke-model-output.txt | jq -r '.results[].outputText'
1
2
3
4
aws bedrock-runtime invoke-model \
--model-id amazon.titan-tg1-large \
--body "{\"inputText\":\"Provide Python to create S3 Bucket name awsome-s3-greatservice\",\"textGenerationConfig\":{\"maxTokenCount\":256,\"stopSequences\":[],\"temperature\":0,\"topP\":0.9}}" \
--cli-binary-format raw-in-base64-out --region us-east-1 titanlarge-invoke-model-output.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ cat titanlarge-invoke-model-output.txt | jq -r '.results[].outputText'
To create a new S3 bucket in Amazon S3, you can use the following Python code:
```Python
import boto3
# Create a boto3 S3 client
s3 = boto3.client('s3')
# Specify the bucket name
bucket_name = 'awesome-s3-greatservice'
# Create the bucket
try:
s3.create_bucket(Bucket=bucket_name)
print(f"Bucket '{bucket_name}' created successfully.")
except Exception as e:
print(f"Error creating bucket '{bucket_name}': {e}")
```
The 'boto3' library is imported, which provides the necessary AWS SDK for Python. An S3 client is created using 'boto3.client('s3')', which allows us to interact with S3 services. The 'bucket_name' variable is set to the desired name for the S3 bucket. The 'create_bucket()' method is called on the S3 client, passing the 'Bucket' parameter with the value of 'bucket_name'. This method creates a new S3 bucket with the specified name.
1
2
3
4
aws bedrock-runtime invoke-model \
--model-id amazon.titan-text-express-v1 \
--body "{\"inputText\":\"Write a Article About AWS Cloudwatch for Linkedin\",\"textGenerationConfig\":{\"maxTokenCount\":256,\"stopSequences\":[],\"temperature\":0,\"topP\":0.9}}" \
--cli-binary-format raw-in-base64-out --region us-east-1 titanexpress-invoke-model-output.txt
1
$ cat titanexpress-invoke-model-output.txt| jq -r '.results[].outputText'
- amazon.titan-image-generator-v1
- amazon.titan-embed-image-v1