# 写一个关于 AWS Lambda 的文章express_prompt="write article about AWS Lambda"
3.2 配置模型
1
2
3
4
5
6
7
8
9
body=json.dumps({"inputText":express_prompt,"textGenerationConfig":{"maxTokenCount":128,"stopSequences":[],# 定义指示模型结束文本生成的短语"temperature":0,# 温度控制随机性;较高的值会增加多样性,较低的值会提高可预测性"topP":0.9# Top P 是一种文本生成技术,从分布中最可能的标记中采样}})
AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS). It allows developers to run code in response to events without the need to manage any infrastructure. In this article, we will explore the features and benefits of AWS Lambda, as well as how to use it to build serverless applications.
Features and Benefits of AWS Lambda:
Serverless Computing: AWS Lambda is a serverless computing service, which means that developers do not have to worry about managing servers, operating systems, or infrastructure. Lambda runs the code in an environment that is managed by AWS, and scales automatically based
4 Titan 文本模型 - Lite
4.1 设置 Prompt
1
2
# AWS DynamoDB 和 AWS Redis 两个 AWS 服务的区别lite_prompt="2 difference between AWS DynamoDB and AWS Redis"
4.2 配置模型
1
2
3
4
5
6
7
8
9
body=json.dumps({"inputText":lite_prompt,"textGenerationConfig":{"maxTokenCount":128,"stopSequences":[],# 定义指示模型结束文本生成的短语"temperature":0,# 温度控制随机性;较高的值会增加多样性,较低的值会提高可预测性"topP":0.9# Top P 是一种文本生成技术,从分布中最可能的标记中采样}})
Amazon DynamoDB is a fully managed NoSQL database service in the cloud that offers fast and predictable performance with seamless scalability. It is designed to run high-performance applications at any scale. On the other hand, Amazon Redis is a fully managed in-memory data structure store that provides real-time analytics, caching, and key-value data storage. It is suitable for applications that require fast data retrieval and low latency.
5 Titan 文本模型 - Embeddings
5.1 设置 Prompt
1
2
# AWS re:Invent 2023 是我们今年最大的云活动,在内华达州拉斯维加斯举行,包括主题演讲、创新讲座、构建者实验室、研讨会、技术和可持续发展演示embed_prompt="AWS re:Invent 2023, our biggest cloud event of the year, in Las Vegas, Nevada, featured keynotes, innovation talks, builder labs, workshops, tech and sustainability demos"
response_body=json.loads(response.get("body").read())embedding_output=response_body.get("embedding")# 此代码从响应正文中检索“嵌入”向量,并打印其长度以及前三个和最后三个值的预览,显示嵌入向量的片段print(f"You can find the Embedding Vector {len(embedding_output)} values\n{embedding_output[0:3]+['...']+embedding_output[-3:]}")
5.5 运行结果
1
2
You can find the Embedding Vector 1536 values
[0.40429688, -0.38085938, 0.19726562, '...', 0.2109375, 0.012573242, 0.18847656]