AWS Machine Learning Blog 04月05日 04:05
Prompting for the best price-performance
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

文章探讨了企业如何利用人工智能降低成本并提高效率,重点关注从OpenAI模型迁移到Amazon Nova模型的策略。通过对比不同模型的性能和价格,文章强调了Amazon Nova在处理大规模应用时的优势。此外,文章还详细介绍了Amazon Nova的产品套件,以及如何针对不同需求优化提示工程,以实现最佳的性价比。文章最后给出了一个实际案例,展示了如何将OpenAI的提示迁移到Amazon Nova Pro,以保持甚至超越原有质量。

💡 迁移原因:OpenAI模型在处理大规模应用时,运营成本可能过高。Amazon Nova Pro在成本效益上更具优势,其更长的上下文窗口使其能够处理更广泛和更复杂的数据输入。

🚀 Amazon Nova套件:Amazon Nova提供多种模型,包括Pro、Lite和Micro,以满足不同的业务需求。Pro模型擅长处理文本、图像和视频,Lite模型兼顾多模态处理和速度,Micro模型则专注于低延迟的文本处理。

⚙️ 提示工程差异:OpenAI采用分层消息系统,强调系统、开发者和用户提示的协同作用;Amazon Nova则侧重于明确定义任务、角色、响应风格和指令,并通过结构化思考和格式化来优化输出。

🔄 迁移策略:从OpenAI迁移到Amazon Nova需要重新调整提示工程。关键在于分解现有提示,明确任务、角色、响应风格和指令,并进行结构化,以充分利用Amazon Nova的优势。

In the drive to remain competitive, businesses today are turning to AI to help them minimize cost and maximize efficiency. It’s incumbent on them to find the most suitable AI model—the one that will help them achieve more while spending less. For many businesses, the migration from OpenAI’s model family to Amazon Nova represents not only a shift in model but a strategic move toward scalability, efficiency, and broader multimodal capabilities.

In this blog, we discuss how to optimize prompting in Amazon Nova for the best price-performance.

Why migrate from OpenAI to Amazon Nova?

OpenAI’s models remain powerful, but their operational costs can be prohibitive when scaled. Consider these figures from Artificial Analysis:

Model Input Token Cost (per Million Tokens) Output Token Cost (per Million Tokens) Context Window Output Speed (Tokens per Second) Latency (Seconds per first token)
GPT-4o ~$2.50 ~$10.00 Up to 128K tokens ~63 ~0.49
GPT-4o Mini ~$0.15 ~$0.60 Up to 128K tokens ~90 ~0.43
Nova Micro ~$0.035 ~$0.14 Up to 128K tokens ~195 ~0.29
Nova Lite ~$0.06 ~$0.24 Up to 300K tokens ~146 ~0.29
Nova Pro ~$0.80 ~$3.20 Up to 300K tokens ~90 ~0.34

For high-volume applications—like global customer support or large-scale document analysis—these cost differences are disruptive. Not only does Amazon Nova Pro offer over three times the cost-efficiency, its longer context window also enables it to handle more extensive and complex inputs.

Breaking down the Amazon Nova suite

Amazon Nova isn’t a single model—it’s a suite designed for various needs:

The lower per-token costs and higher output per second of Amazon Nova give you the flexibility to simplify prompts for real-time applications so you can balance quality, speed, and cost for your use case.

Understanding the foundations

To make the best decision about which model family fits your needs, it’s important to understand the differences in prompt engineering best practices in both OpenAI and Amazon Nova. Each model family has its own set of strengths, but there are some things that apply to both families. Across both model families, quality accuracy is achieved through clarity of instructions, structured prompts, and iterative refinement. Whether you’re using strong output directives or clearly defined use cases, the goal is to reduce ambiguity and improve response quality.

The OpenAI approach

OpenAI uses a layered messaging system for prompt engineering, where system, developer, and user prompts work in harmony to control tone, safety, and output format. Their approach emphasizes:

The Amazon Nova approach

Evolving your prompt strategy: Migrating from OpenAI to Amazon Nova

Transitioning to Amazon Nova isn’t merely a change in API endpoints—it requires retooling your prompt engineering to align with the strengths of Amazon Nova. You need to reframe your use case definition. Begin by breaking down your current GPT-4o or GPT-4o Mini prompt into its core elements of task, role, response style, and instructions and success criteria. Make sure to structure these elements clearly to provide a blueprint for the model.

To understand how to migrate an existing OpenAI prompt to work optimally for Amazon Nova Pro, consider the following example using the meeting notes summarizer. Here is the GPT-4o system prompt:

You will be provided with meeting notes, and your task is to summarize the meeting as follows: -Overall summary of discussion -Action items (what needs to be done and who is doing it) -If applicable, a list of topics that need to be discussed more fully in the next meeting.

The user prompt is the meeting notes that need to be summarized:

Meeting Date: March 5th, 2050Meeting Time: 2:00 PMLocation: Conference Room 3B, Intergalactic Headquarters...

GPT produces this helpful response:

Overall Summary of Discussion: The team discussed the recent mission to Planet Zog, the space pirate issue in Sector 7, the annual Intergalactic Bake-Off, planning for the upcoming charity fundraiser, and a proposed team-building retreat. The mission to Planet Zog was successful, but communication with the Zogians was challenging. The team also discussed the need for a better strategy to deal with space pirates. The team placed second in the Intergalactic Bake-Off and is planning for the upcoming charity fundraiser. A team-building retreat to the Moon Resort and Spa was proposed.Action Items:1. Dr. Quasar to start working on a Zogian-English dictionary.2. Captain Stardust to speak with Admiral Starbeam about increasing patrols in Sector 7.3. Dr. Quasar to finalize the prototype of the new cloaking technology.4. All team members to start gathering supplies and preparing games for the Intergalactic Charity Bazaar.5. Captain Stardust to check the budget for the proposed team-building retreat to the Moon Resort and Spa.Topics for Next Meeting:1. Update on the Zogian-English dictionary.2. Progress report on the cloaking technology.3. Results of increased patrols in Sector 7.4. Final preparations for the Intergalactic Charity Bazaar.

To meet or exceed the quality of the response from GPT-4o, here is what an Amazon Nova Pro prompt might look like. The prompt uses the same best practices discussed in this post, starting with the system prompt. We used a temperature of .2 and a topP of .9 here:

You are an experienced executive assistant skilled in meeting note analysis and summarization. Your primary responsibilities include distilling complex discussionsinto clear, actionable summaries.Follow these instructions:##INSTRUCTIONS##1. Read understand the meeting notes found in ##NOTES##2. Put all of your outputs in a section called ##OUTPUTS## in markdown formatting3. Summarize the meeting notes in 5 sentences or less. Put this in a section called "Overall Summary".4. Numerically list any action items for specific people and what needs to be completed. Put this list in a section called "Action Items".5. If applicable, list the topics that need to be discussed more fully in the next meeting. Put this in a section called "Topics for Next Meeting".

Here’s the user prompt, using prefilled responses:

##NOTES##Meeting Date: March 5th, 2050Meeting Time: 2:00 PMLocation: Conference Room 3B, Intergalactic HeadquartersAttendees:- Captain Stardust- Dr. Quasar- Lady Nebula- Sir Supernova- Ms. CometMeeting called to order by Captain Stardust at 2:05 PM1. Introductions and welcome to our newest team member, Ms. Comet2. Discussion of our recent mission to Planet Zog- Captain Stardust: "Overall, a success, but communication with the Zogians was difficult. We need to improve our language skills."- Dr. Quasar: "Agreed. I'll start working on a Zogian-English dictionary right away."- Lady Nebula: "The Zogian food was out of this world, literally! We should consider having a Zogian food night on the ship."3. Addressing the space pirate issue in Sector 7- Sir Supernova: "We need a better strategy for dealing with these pirates. They've already plundered three cargo ships this month."- Captain Stardust: "I'll speak with Admiral Starbeam about increasing patrols in that area.- Dr. Quasar: "I've been working on a new cloaking technology that could help our ships avoid detection by the pirates. I'll need a few more weeks to finalize the prototype."4. Review of the annual Intergalactic Bake-Off- Lady Nebula: "I'm happy to report that our team placed second in the competition! Our Martian Mud Pie was a big hit!"- Ms. Comet: "Let's aim for first place next year. I have a secret recipe for Jupiter Jello that I think could be a winner."5. Planning for the upcoming charity fundraiser- Captain Stardust: "We need some creative ideas for our booth at the Intergalactic Charity Bazaar."- Sir Supernova: "How about a 'Dunk the Alien' game? We can have people throw water balloons at a volunteer dressed as an alien."- Dr. Quasar: "I can set up a 'Name That Star' trivia game with prizes for the winners."- Lady Nebula: "Great ideas, everyone. Let's start gathering the supplies and preparing the games."6. Upcoming team-building retreat- Ms. Comet: "I would like to propose a team-building retreat to the Moon Resort and Spa. It's a great opportunity to bond and relax after our recent missions."- Captain Stardust: "Sounds like a fantastic idea. I'll check the budget and see if we can make it happen."7. Next meeting agenda items- Update on the Zogian-English dictionary (Dr. Quasar)- Progress report on the cloaking technology (Dr. Quasar)- Results of increased patrols in Sector 7 (Captain Stardust)- Final preparations for the Intergalactic Charity Bazaar (All)Meeting adjourned at 3:15 PM. Next meeting scheduled for March 19th, 2050 at 2:00 PM in Conference Room 3B, Intergalactic Headquarters.##OUTPUTS##

The following example shows that the Amazon Nova response meets and exceeds the accuracy of the OpenAI example, formats the output in Markdown, and has found clear owners for each action item:

### Overall SummaryThe meeting covered the successful mission to Planet Zog, the ongoing issue with space pirates in Sector 7, the results of the annual Intergalactic Bake-Off, plans for the upcoming charity fundraiser, and a proposed team-building retreat. Action items were assigned, and the next meeting's agenda was set.### Action Items1. **Dr. Quasar**: Begin working on a Zogian-English dictionary.2. **Captain Stardust**: Speak with Admiral Starbeam about increasing patrols in Sector 7.3. **Dr. Quasar**: Finalize the prototype for the new cloaking technology within a few weeks.4. **Team**: Start gathering supplies and preparing games for the Intergalactic Charity Bazaar.5. **Captain Stardust**: Check the budget for the proposed team-building retreat to the Moon Resort and Spa.### Topics for Next Meeting1. Update on the Zogian-English dictionary (Dr. Quasar)2. Progress report on the cloaking technology (Dr. Quasar)3. Results of increased patrols in Sector 7 (Captain Stardust)4. Final preparations for the Intergalactic Charity Bazaar (All)

A few updates to the prompt can achieve comparable or better results from Amazon Nova Pro while enjoying a much less expensive cost of inference.

Employ Amazon Nova extended context

Amazon Nova Lite and Amazon Nova Pro can support up to 300,000 input tokens, which means that you can include more context in your prompt if needed. Expand your background data and detailed instructions accordingly—if your original OpenAI prompt was optimized for 128,000 tokens, adjust it to use the Amazon Nova extended window.

Tailor output constraints

If your GPT prompt required strict formatting (for example, “Respond in JSON only”), make sure that your Amazon Nova prompt includes these directives. Additionally, if your task involves multimodal inputs, specify when to include images or video references.

Function calling

The rise of generative AI agents has made function calling, or tool calling, one of the most important abilities of a given large language model (LLM). A model’s ability to correctly pick the right tool for the job, in a low-latency manner, is often the difference between success and failure of an agentic system.

Both OpenAI and Amazon Nova models share similarities in function calling, in particular their support for structured API calls. Both model families support tool selection through defined tool schemas, which we discuss later in this post. They also both provide a mechanism to decide when to invoke these tools or not.

OpenAI’s function calling uses flexible JSON schemas to define and structure API interactions. The models support a wide range of schema configurations, which give developers the ability to quickly implement external function calls through straightforward JSON definitions tied to their API endpoints.

Here is an example of a function:

tools = [{        "type": "function",        "function": {            "name": "get_weather",            "description": "Get current temperature for a given location.",            "parameters": {                    "type": "object",                    "properties": {                        "location": {                            "type": "string",                            "description": "City and country e.g. Montevideo, Uruguay"                        }                            },                            "required": [                                    "location"        ],        "additionalProperties": False    },    "strict": True    }}]completion = client.chat.completions.create(    model="gpt-4o",    messages=[{"role": "user", "content": "What is the weather like in Punta del Este today?"}],    tools=tools

Similar to OpenAI’s approach, Amazon Nova can call tools when passed a configuration schema as shown in the following code example. Amazon Nova has made heavy use of Greedy Decoding when calling tools, and it’s advised to set temperature, topP, and topK to 1. This makes sure that the model has the highest accuracy in tool selection. These Greedy Decoding parameters and other great examples of tool use are covered in great detail in Tool use (function calling) with Amazon Nova.

The following is an example of function calling without using additionalModelRequestFields:

tool_config = {    "tools": [{        "toolSpec": {            "name": "get_recipe",            "description": "Structured recipe generation system",            "inputSchema": {                "json": {                    "type": "object",                    "properties": {                        "recipe": {                            "type": "object",                            "properties": {                                "name": {"type": "string"},                                "ingredients": {                                    "type": "array",                                    "items": {                                        "type": "object",                                        "properties": {                                            "item": {"type": "string"},                                            "amount": {"type": "number"},                                            "unit": {"type": "string"}                                        }                                    }                                },                                "instructions": {                                    "type": "array",                                    "items": {"type": "string"}                                }                            },                            "required": ["name", "ingredients", "instructions"]                        }                    }                }            }        }    }]}# Base configuration without topK=1input_text = "I need a recipe for chocolate lava cake"messages = [{    "role": "user",    "content": [{"text": input_text}]}]# Inference parametersinf_params = {"topP": 1, "temperature": 1}response = client.converse(    modelId="us.amazon.nova-lite-v1:0",    messages=messages,    toolConfig=tool_config,    inferenceConfig=inf_params)# Typically produces less structured or incomplete output 

The following example shows how function calling accuracy can be improved by using

additionalModelRequestFields:

# Enhanced configuration with topK=1response = client.converse(    modelId="us.amazon.nova-lite-v1:0",    messages=messages,    toolConfig=tool_config,    inferenceConfig=inf_params,    additionalModelRequestFields={"inferenceConfig": {"topK": 1}})# Produces more accurate and structured function call

To maximize Amazon Nova function calling potential and improve accuracy, always use additionalModelRequestFields with topk=1. This forces the model to select the single most probable token and prevents random token selection. This increases deterministic output generation and improves function call precision by about 30–40%.

The following code examples further explain how to conduct tool calling successfully. The first scenario shows recipe generation without an explicit tool. The example doesn’t use topK, which typically results in responses that are less structured:

input_text = """I'm looking for a decadent chocolate dessert that's quick to prepare. Something that looks fancy but isn't complicated to make."""messages = [{    "role": "user",    "content": [{"text": input_text}]}]response = client.converse(    modelId="us.amazon.nova-lite-v1:0",    messages=messages,    inferenceConfig={"topP": 1, "temperature": 1})# Generates a conversational recipe description# Less structured, more narrative-driven response

In this example, the scenario shows recipe generation with a structured tool. We add topK set to 1, which produces a more structured output:

response = client.converse(    modelId="us.amazon.nova-lite-v1:0",    messages=messages,    toolConfig=tool_config,    inferenceConfig={"topP": 1, "temperature": 1},    additionalModelRequestFields={"inferenceConfig": {"topK": 1}})# Generates a highly structured, JSON-compliant recipe# Includes precise ingredient measurements# Provides step-by-step instructions

Overall, OpenAI offers more flexible, broader schema support. Amazon Nova provides more precise, controlled output generation and is the best choice when working with high-stakes, structured data scenarios, as demonstrated in Amazon Nova’s performance on the IFEval benchmark discussed in section 2.1.1 of the technical report and model card. We recommend using Amazon Nova for applications requiring predictable, structured responses because its function calling methodology provides superior control and accuracy.

Conclusion

The evolution from OpenAI’s models to Amazon Nova represents a significant shift in using AI. It shows a transition toward models that deliver similar or superior performance at a fraction of the cost, with expanded capabilities in multimodal processing and extended context handling.

Whether you’re using the robust, enterprise-ready Amazon Nova Pro, the agile and economical Amazon Nova Lite, or the versatile Amazon Nova Micro, the benefits are clear:

By evolving your prompt strategy—redefining use cases, exploiting the extended context, and iteratively refining instructions—you can smoothly migrate your existing workflows from OpenAI’s o4 and o4-mini models to the innovative world of Amazon Nova.


About the Authors

Claudio Mazzoni is a Sr Specialist Solutions Architect on the Amazon Bedrock GTM team. Claudio exceeds at guiding costumers through their Gen AI journey. Outside of work, Claudio enjoys spending time with family, working in his garden, and cooking Uruguayan food.

Pat Reilly is a Sr. Specialist Solutions Architect on the Amazon Bedrock Go-to-Market team. Pat has spent the last 15 years in analytics and machine learning as a consultant. When he’s not building on AWS, you can find him fumbling around with wood projects.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Amazon Nova OpenAI AI 提示工程 成本优化
相关文章