Generative artificial intelligence (AI) models have opened up new possibilities for automating and enhancing software development workflows. Specifically, the emerging ability of generative models to generate code based on natural language prompts has opened many doors in how developers and DevOps professionals approach their work and become more efficient. This post provides an overview of how you can use Amazon Bedrock to leverage advancements in large-scale language models (LLMs) to assist developers at various stages of the software development lifecycle (SDLC).
Amazon Bedrock is a fully managed service that offers a choice of high-performance foundational models (FMs) from leading AI companies such as AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API and also provides a wide range of capabilities for building generative AI applications with security, privacy, and responsible AI.
The following process architecture proposes an example SDLC flow that incorporates generative AI in key areas to improve development efficiency and speed.
The goal of this post is to focus on how developers can use the models within Amazon Bedrock to create their own systems for extending, writing, and auditing code, rather than relying on out-of-the-box coding assistants. We cover the following topics:
- Coding assistant use case: Helping developers write code faster by providing suggestions.
- How to leverage LLM’s code understanding capabilities to uncover insights and recommendations
- Automated application generation use cases to generate working code and automatically deploy changes to a working environment
Considerations
When choosing the model and approach to implement this functionality at each step, it is important to consider several technical options. One such option is the base model to use for the task. Each model is trained on a different corpus of data, so different models perform differently on the task. For example, Amazon Bedrock’s Anthropic Claude 3 model codes effectively out of the box in many common coding languages, while other models might not reach that performance without further customization. However, customization is just another technical choice to make. For example, if your use case involves a less common language or framework, achieving production-quality performance might require model customization through fine-tuning or the use of Retrieval Augmented Generation (RAG), which is more complex and requires more engineering effort to implement effectively.
There is a wealth of literature out there detailing these trade-offs, but this article will only cover the considerations you should make on your own. Here, we will simply provide some background on what the first steps for builders to implement a generative AI-powered SDLC initiative entail.
Coding Assistant
Coding assistance is a very popular use case, with plenty of examples to choose from. AWS offers several services that can be applied to assist developers, whether that be through inline completion from tools like Amazon CodeWhisperer, or natural language interaction with Amazon Q. Amazon Q for builders has several implementations of the feature, including:
Nearly all of the use cases discussed allow for integration with chat interfaces or assistants, the use cases here are focused on more direct code generation use cases with natural language prompts (not to be confused with inline generation tools that are focused on auto-completion of coding tasks).
The assistant’s main advantage over inline generation is that it lets you kick off a new project based on a simple description. For example, you can describe that you want a serverless website where users can post in a blog format, and Amazon Q can start building your project by providing example code and recommending frameworks to use to do this. This natural language entry point gives you templates and frameworks to work with, allowing you to spend more time on the differentiating logic of your application rather than setting up repeatable, commodity components.
Code Understanding
It is common for companies that start experimenting with generative AI to increase the productivity of individual developers and then use LLM to infer the meaning and functionality of code, making the development process more reliable, efficient, secure, and fast. Human understanding of code is a central part of the SDLC, including creating documentation, performing code reviews, and enforcing best practices. Onboarding new developers can be a challenge even for mature teams. Instead of more experienced developers spending time answering questions, an LLM that is aware of the codebase and the team’s coding standards can be used to explain sections of code and design decisions to new team members. Developers onboarding have everything they need with fast response times, allowing experienced developers to focus on building. In addition to its user-facing behavior, this same mechanism can be reused to work entirely behind the scenes to augment existing continuous integration and continuous delivery (CI/CD) processes as an additional reviewer.
For example, you can use prompt engineering techniques to guide and automate the enforcement of coding standards or use custom APIs, including the existing code base as reference material. You can also take proactive measures by beginning each prompt with a reminder to follow the coding standard and making a call to retrieve the coding standard from document storage and passing it to the model as the prompt’s context. As a retroactive measure, you can enforce compliance by adding a step during the review process that checks the written code against the standard, similar to how team code reviews work. For example, let’s say one of your team’s standards is component reuse. During the review step, the model can read a new code submission, note that the component already exists in the code base, and suggest to the reviewer to reuse the existing component rather than recreating it.
The following diagram illustrates this type of workflow:
Application Generation
The use case concepts discussed in this article can be expanded to create a complete application generation implementation. In a traditional SDLC, humans create a set of requirements, design the application, write the code to implement that design, build tests, receive feedback on the system from external sources or people, and the process repeats. The bottlenecks in this cycle typically occur during the implementation and testing phases. Application builders must have substantial technical skills to write code effectively, and even the most skilled builders typically require numerous iterations to debug and perfect the code. In addition, basic knowledge of a company’s existing code base, APIs, and IP is fundamental to implementing an effective solution and takes a long time for humans to master. This can slow the time to innovation for new team members or teams with technical skill gaps. As mentioned earlier, if a model can be used with the ability to both write and interpret code, a pipeline can be created that runs developer iterations of the SDLC by feeding the model’s output back in as input.
The following diagram illustrates this type of workflow:
For example, you can use natural language to ask the model to create an application that prints all prime numbers between 1 and 100. The model returns a code block where you can define and run applicable tests. If the program does not run or some tests fail, you can feed the error and the failed code back to the model and ask it to diagnose the problem and suggest a solution. The next step in the pipeline is to take the original code and the diagnosis and proposed solution, and stitch together the code snippets to create a new program. The SDLC then starts again with the testing phase to get new results and either iterate again or create a working application. With this basic framework, you can increase the number of components in the same way as you would in a traditional human-based workflow. This modular approach can be continuously improved until you have a robust and powerful application generation pipeline that simply accepts natural language prompts and outputs a working application, with all error correction and adherence to best practices handled in the background.
The following diagram illustrates this high-level workflow:
Conclusion
We are currently at the stage in the generative AI adoption curve where teams can make real productivity gains by using different techniques and tools. Leveraging these productivity gains will be essential to remain competitive in the near future. One thing we know for sure is that things will continue to evolve and change rapidly, so it’s important to build systems that are adaptable and flexible. Developing components in a modular way allows you to be ready to adopt the latest technologies at each stage while remaining stable against the ever-changing technology landscape.
For more information about how to start building with LLM, see the following resources:
About the Author
Ian Lenora is an experienced software development leader focused on building high-quality cloud-native software and exploring the potential of artificial intelligence. He has successfully led teams delivering complex projects across various industries, optimizing efficiency and scalability. With a deep understanding of the software development lifecycle and a passion for innovation, Ian aspires to leverage AI technologies to create intelligent, adaptive software solutions that solve complex problems and drive business value.
Cody Collins Cody is a Solutions Architect at Amazon Web Services based in New York. He works with ISV customers to build cutting edge solutions in the cloud. He has extensive experience delivering complex projects across industries and optimizing for efficiency and scalability. Cody specializes in AI/ML technologies, enabling customers to develop ML capabilities and integrate AI into their cloud applications.
Summit Kumbani He is a Sr. Solutions Architect with AWS in the New York City area with over 18 years of experience. He currently works with Independent Software Vendors (ISVs) to build scalable, innovative and secure cloud solutions. Outside of work, he enjoys playing cricket, traveling and cycling.