├── references ├── workflow.png ├── anycompany_logo.jpg ├── JS.txt ├── Testimonials.json ├── Construction-Industry-DummyArticle-01.txt ├── Manufacturing-Industry-DummyArticle-01.txt ├── CSS.txt ├── Mining-Industry-DummyArticle-01.txt └── offerings.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── CONTRIBUTING.md ├── models ├── sdxl.ipynb └── llama3-8b-instruct-neuron-TGI.ipynb └── personalization-with-llms-TGI-version.ipynb /references/workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agentic-workflows-slm-on-inf/main/references/workflow.png -------------------------------------------------------------------------------- /references/anycompany_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agentic-workflows-slm-on-inf/main/references/anycompany_logo.jpg -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /references/JS.txt: -------------------------------------------------------------------------------- 1 | document.addEventListener('DOMContentLoaded', function() { 2 | const testimonials = document.querySelectorAll('.testimonial'); 3 | let currentTestimonial = 0; 4 | 5 | function showNextTestimonial() { 6 | testimonials[currentTestimonial].style.display = 'none'; 7 | currentTestimonial = (currentTestimonial + 1) % testimonials.length; 8 | testimonials[currentTestimonial].style.display = 'block'; 9 | } 10 | 11 | // Show the first testimonial 12 | testimonials[0].style.display = 'block'; 13 | 14 | // Change testimonial every 5 seconds 15 | setInterval(showNextTestimonial, 5000); 16 | }); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | 18 | -------------------------------------------------------------------------------- /references/Testimonials.json: -------------------------------------------------------------------------------- 1 | { 2 | "testimonials": [ 3 | { 4 | "text": "AnyCompany Consulting's expert consulting services have been invaluable in streamlining our operations and optimizing our construction processes, resulting in increased efficiency and cost savings", 5 | "author": "John Smith", 6 | "position": "CTO", 7 | "company": "Example Corp Solutions" 8 | }, 9 | { 10 | "text": "AnyCompany Consulting's top-notch consulting solutions have transformed our organization, enabling us to tackle complex challenges, fostering innovation, and propelling our growth to new heights.", 11 | "author": "Alejandro Rosalez", 12 | "position": "COO", 13 | "company": "AnyDepartment Stores" 14 | }, 15 | { 16 | "text": "AnyCompany Consulting's strategic advisory services have been instrumental in strengthening our governance frameworks, enhancing transparency, and ensuring compliance with regulatory requirements, facilitating seamless public service delivery.", 17 | "author": "Jane Doe", 18 | "position": "Governor", 19 | "company": "AnyGovernment" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Keeping it Small: Agentic Workflows with SLMs on AWS Inferentia 2 | 3 | ## Introduction 4 | 5 | This repository contains code and resources for the reInvent session: "Keeping it Small: Agentic Workflows with SLMs on AWS Inferentia". By using the resources in this repository, you will create a personalized website that balances the innovative capabilities of LLMs with adherence to human directives and human-curated assets for a consistent and responsible personalization experience for the customers of a fictional company named OneCompany Consulting. 6 | 7 | ## Overview 8 | 9 | To help you create OneCompany Consulting's website, we've broken each step of the website development process into several smaller, more specific sub-tasks that will each be performed by a specialized agent (LLM). This approach will ensure that your resulting website adheres to the company's guidelines, messaging, and related rules, while incorporating industry pain points, user experience (UX) and user interface (UI) design systems, and human-curated elements. 10 | 11 | ## Prerequisites 12 | 13 | To use this repository, you need the following: 14 | 15 | - An AWS account 16 | - AWS Command Line Interface (AWS CLI) installed 17 | - Python and the AWS SDK for Python (Boto3) set up 18 | - Amazon SageMaker Studio or Studio Domain 19 | - AWS Inferentia instances 20 | 21 | ## Usage 22 | 23 | The notebooks in this repository will guide you through the following processes: 24 | 25 | - Deploying a Llama3.1-8B model to a Amazon SageMaker endpoint on an AWS Inferentia instance. 26 | - Deploying a Stable Diffusion XL model to a Amazon SageMaker endpoint on an AWS Inferentia instance. 27 | - Generating a detailed website description and visual element descriptions using a personalizer LLM (Llama 3.1 8B) 28 | - Creating visual assets using an image generator LLM (Stable Diffusion XL) 29 | - Deploying the generated website assets to an Amazon S3 bucket 30 | 31 | ## Data and Sources of Truth 32 | 33 | The repository includes fictitious references and data sources created manually or generated using language models. These resources serve as examples and should be replaced with your own company guidelines, design systems, and industry-specific data in real-world scenarios. 34 | 35 | ## Clean up 36 | 37 | To clean up the resources created during the walkthrough, follow the instructions provided in the "Clean up" section of each notebook. 38 | 39 | ## Conclusion 40 | 41 | This repository demonstrates how to use an agentic approach to build a customized website for a customer of the fictional company, OneCompany Consulting. It leveraged LLMs such as Llama3.1-8B and Stable Diffusion XL (SDXL) to generate text and images to create a personalized website, and explains how to deploy each of these models on AWS Inferentia. 42 | 43 | ## Additional Resources 44 | 45 | [Optimum Neuron](https://huggingface.co/docs/optimum-neuron/en/index) 46 | [HuggingFace Text Generation Inference on Neuron](https://huggingface.co/docs/optimum-neuron/en/guides/neuronx_tgi) 47 | [AWS Neuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/index.html) 48 | 49 | ## Security 50 | 51 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 52 | 53 | ## License 54 | 55 | This library is licensed under the MIT-0 License. See the LICENSE file. 56 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /references/Construction-Industry-DummyArticle-01.txt: -------------------------------------------------------------------------------- 1 | Title: Construction Industry Pain Points in the United States Introduction: The construction industry in the United States is a significant contributor to the nation's economy, accounting for approximately 4.1% of the country's Gross Domestic Product (GDP). However, like any other industry, it faces a unique set of challenges or pain points that hinder its growth and efficiency. This document aims to highlight and discuss these pain points in detail. 1. Labor Shortage: One of the most significant challenges facing the construction industry is the shortage of skilled labor. The industry has been grappling with this issue for several years, with the problem only exacerbated by the COVID-19 pandemic. According to a survey by the Organization-X, 80% of construction firms report having a hard time filling hourly craft positions. This shortage not only delays project completion but also increases labor costs. 2. Rising Material Costs: Fluctuating and rising material costs are another major pain point for the construction industry. Prices for essential construction materials like lumber, steel, and copper have seen significant increases, leading to higher project costs. These cost fluctuations make it challenging for contractors to provide accurate bids and maintain profitability. 3. Regulatory Compliance: The construction industry is heavily regulated, with rules and regulations at the federal, state, and local levels. Compliance with these regulations can be complex and time-consuming, often leading to delays and increased costs. Additionally, non-compliance can result in hefty fines and legal issues, further impacting a company's bottom line. 4. Project Delays: Delays in construction projects are common and can be caused by various factors, including weather conditions, labor disputes, equipment breakdowns, and permit delays. These delays can lead to increased project costs, missed deadlines, and potential contract disputes. 5. Inefficient Communication: Effective communication is crucial in the construction industry, where multiple parties, including architects, engineers, contractors, and subcontractors, are involved in a project. However, inefficient communication and lack of collaboration often lead to misunderstandings, errors, and delays. 6. Technological Adaptation: While technology has the potential to significantly improve efficiency and productivity in the construction industry, many firms struggle with its adoption. The industry has been slow to embrace new technologies like Building Information Modeling (BIM), drones, and automation, which could help address some of the other pain points mentioned. 7. Sustainability and Environmental Concerns: There is increasing pressure on the construction industry to adopt more sustainable practices and reduce its environmental impact. However, implementing green building practices can be challenging due to higher upfront costs and the need for specialized knowledge and skills. Conclusion: The construction industry in the United States faces a myriad of challenges that impact its productivity, profitability, and sustainability. Addressing these pain points requires a multi-faceted approach, including investing in workforce development, adopting new technologies, improving communication and collaboration, and advocating for more favorable regulations. By addressing these challenges, the industry can pave the way for growth and success in the future. -------------------------------------------------------------------------------- /references/Manufacturing-Industry-DummyArticle-01.txt: -------------------------------------------------------------------------------- 1 | Challenges and Pain Points of the Manufacturing Industry in the United States 2 | 3 | 1. Skilled Labor Shortage: One of the primary challenges faced by the manufacturing industry in the United States is the shortage of skilled labor. As more and more baby boomers retire, there is a dearth of experienced workers who can efficiently operate and maintain machinery and assembly lines. The industry faces difficulties in finding qualified individuals who possess the necessary technical expertise and hands-on experience. This shortage hampers productivity, slows down production, and increases labor costs. 4 | 5 | 2. Rising Costs: The manufacturing industry in the United States faces significant cost pressures due to various factors, such as increased raw material prices, energy expenses, and regulatory compliance costs. As these costs rise, manufacturers find it challenging to maintain competitive pricing and keep their products competitive in the global market. Additionally, the fluctuating exchange rates and tariffs imposed by other countries further complicate the situation, impacting the overall profitability and sustainability of manufacturing businesses. 6 | 7 | 3. Supply Chain Disruptions: The manufacturing industry is highly reliant on efficient global supply chains. However, these supply chains are often disrupted by events like natural disasters, pandemics, geopolitical tensions, and logistical challenges. These disruptions can lead to shortages of critical materials, resulting in production delays, increased costs, and missed delivery deadlines. The unpredictability of these disruptions poses a significant challenge for manufacturers, who strive for consistent and efficient supply chain management. 8 | 9 | 4. Technological Advancements: While technological advancements bring numerous benefits to the industry, they also introduce challenges and pain points. Manufacturers must constantly invest in upgrading and adopting new technologies to remain competitive. This constant evolution requires substantial financial resources, technical knowledge, and workforce training. Additionally, the rapid pace of technological advancement can lead to obsolescence of equipment, making it challenging for manufacturers to keep up with the latest advancements and invest in the right technologies. 10 | 11 | 5. Regulatory Compliance: The manufacturing industry in the United States is subject to stringent regulations and compliance requirements enforced by various government agencies. Ensuring compliance with these regulations can be challenging, as they often involve complex paperwork, frequent audits, and hefty penalties in case of non-compliance. These regulations cover areas such as health and safety, labor standards, environmental impact, and product quality standards. Manufacturers face difficulties in navigating these regulations while ensuring compliance without impacting their operations and bottom line. 12 | 13 | 6. Market Volatility: The manufacturing industry faces intense competition and market volatility, both domestically and internationally. Companies must constantly adapt to changing consumer preferences, technological advancements, and macroeconomic trends. This market volatility can lead to reduced demand for specific products, increased competition, and price wars, making it challenging for manufacturers to sustain profitability and growth. 14 | 15 | 7. Innovation and Creativity: The manufacturing industry faces increasing pressure to innovate and create new products to stay competitive. However, innovation and creativity require significant investments in terms of research, development, and testing. Additionally, the risks associated with innovation are high, as not all new products or technologies may be successful. Manufacturers must strike a balance between investing in innovation and maintaining financial stability. 16 | 17 | Addressing these challenges and pain points requires a comprehensive approach, including workforce training and development, cost management, supply chain resilience, technological adoption, regulatory expertise, market adaptability, and strategic investment in innovation. By understanding and addressing these challenges, the manufacturing industry in the United States can move towards sustainable and profitable growth. -------------------------------------------------------------------------------- /references/CSS.txt: -------------------------------------------------------------------------------- 1 | /* Global Styles */ 2 | body { 3 | font-family: Arial, sans-serif; 4 | margin: 0; 5 | padding: 0; 6 | } 7 | 8 | /* Header Styles */ 9 | header { 10 | background-color: #0d2b4f; 11 | color: #fff; 12 | padding: 20px; 13 | display: flex; 14 | justify-content: space-between; 15 | align-items: center; 16 | } 17 | 18 | .logo img { 19 | max-height: 40px; 20 | } 21 | 22 | nav ul { 23 | list-style-type: none; 24 | margin: 0; 25 | padding: 0; 26 | display: flex; 27 | } 28 | 29 | nav li { 30 | margin-left: 20px; 31 | } 32 | 33 | nav a { 34 | color: #fff; 35 | text-decoration: none; 36 | transition: color 0.3s ease; 37 | } 38 | 39 | nav a:hover { 40 | color: #b3d1ff; 41 | } 42 | 43 | /* Hero Section Styles */ 44 | .hero { 45 | background-image: linear-gradient(to bottom, rgba(13, 43, 79, 0.7), rgba(13, 43, 79, 0.7)), url('hero-image.jpg'); 46 | background-size: cover; 47 | background-position: center 33%; 48 | color: #fff; 49 | padding: 100px 20px; 50 | text-align: center; 51 | } 52 | 53 | .hero h1 { 54 | font-size: 3rem; 55 | margin-bottom: 20px; 56 | } 57 | 58 | .hero p { 59 | font-size: 1.5rem; 60 | margin-bottom: 40px; 61 | } 62 | 63 | /* Offerings Section Styles */ 64 | .offerings { 65 | padding: 60px 20px; 66 | text-align: center; 67 | } 68 | 69 | .offerings h2 { 70 | font-size: 2rem; 71 | margin-bottom: 40px; 72 | } 73 | 74 | .offerings-grid { 75 | display: grid; 76 | grid-template-columns: repeat(3, 1fr); 77 | grid-gap: 40px; 78 | } 79 | 80 | .offering-card img { 81 | width: 128px; 82 | height: 128px; 83 | object-fit: contain; 84 | margin-bottom: 20px; 85 | } 86 | 87 | .offering-item h3 { 88 | font-size: 1.2rem; 89 | margin-bottom: 10px; 90 | } 91 | 92 | .offering-item p { 93 | font-size: 1rem; 94 | } 95 | 96 | /* Pain-points Section Styles */ 97 | .pain-points { 98 | background-color: #f5f5f5; 99 | padding: 60px 20px; 100 | text-align: center; 101 | } 102 | 103 | .pain-points h2 { 104 | font-size: 2rem; 105 | margin-bottom: 40px; 106 | } 107 | 108 | .pain-points-grid { 109 | display: grid; 110 | grid-template-columns: repeat(3, 1fr); 111 | grid-gap: 40px; 112 | } 113 | 114 | .pain-point-card img { 115 | width: 128px; 116 | height: 128px; 117 | object-fit: contain; 118 | margin-bottom: 20px; 119 | } 120 | 121 | .pain-point-item h3 { 122 | font-size: 1.2rem; 123 | margin-bottom: 10px; 124 | } 125 | 126 | .pain-point-item p { 127 | font-size: 1rem; 128 | } 129 | 130 | /* Testimonials Section Styles */ 131 | .testimonials { 132 | padding: 60px 20px; 133 | text-align: center; 134 | } 135 | 136 | .testimonials h2 { 137 | font-size: 2rem; 138 | margin-bottom: 40px; 139 | } 140 | 141 | .testimonial-container { 142 | background-color: #f5f5f5; 143 | padding: 40px; 144 | border-radius: 8px; 145 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); 146 | } 147 | 148 | .testimonial-text { 149 | font-size: 1.2rem; 150 | margin-bottom: 20px; 151 | } 152 | 153 | .testimonial-author { 154 | font-size: 1rem; 155 | font-style: italic; 156 | } 157 | 158 | /* CTA Section Styles */ 159 | .cta { 160 | background-color: #0d2b4f; 161 | color: #fff; 162 | padding: 60px 20px; 163 | text-align: center; 164 | } 165 | 166 | .cta h2 { 167 | font-size: 2rem; 168 | margin-bottom: 20px; 169 | } 170 | 171 | .cta p { 172 | font-size: 1.2rem; 173 | margin-bottom: 40px; 174 | } 175 | 176 | .cta-button { 177 | display: inline-block; 178 | background-color: #4caf50; 179 | color: #fff; 180 | text-decoration: none; 181 | padding: 12px 24px; 182 | border-radius: 4px; 183 | font-size: 1.2rem; 184 | transition: background-color 0.3s ease; 185 | } 186 | 187 | .cta-button:hover { 188 | background-color: #45a049; 189 | } 190 | 191 | /* Footer Styles */ 192 | footer { 193 | background-color: #0d2b4f; 194 | color: #fff; 195 | padding: 20px; 196 | text-align: center; 197 | font-size: 0.9rem; 198 | } 199 | 200 | footer a { 201 | color: #fff; 202 | text-decoration: none; 203 | transition: color 0.3s ease; 204 | } 205 | 206 | footer a:hover { 207 | color: #b3d1ff; 208 | } 209 | 210 | /* Responsive Styles */ 211 | @media (max-width: 768px) { 212 | .offerings-grid, 213 | .pain-points-grid { 214 | grid-template-columns: 1fr; 215 | } 216 | } -------------------------------------------------------------------------------- /references/Mining-Industry-DummyArticle-01.txt: -------------------------------------------------------------------------------- 1 | An In-depth Analysis and Discussion on Mining Industry 2 | 3 | The mining industry, a vital sector for global economic growth and development, faces a myriad of challenges that demand immediate attention and innovative solutions. These challenges encompass environmental concerns, social impacts, technological advancements, geopolitical risks, and regulatory complexities. This article delves into these critical issues, providing examples, statistics, and explanations to shed light on the current and future challenges of the mining industry. 4 | 5 | Environmental Challenges: 6 | 7 | Mining activities can significantly impact the environment, leading to soil erosion, deforestation, water pollution, and habitat destruction. For instance, a catastrophic tailings dam failure occurred at a mine in Country-A in Year-B, releasing millions of cubic meters of toxic waste into nearby rivers, affecting local communities and ecosystems. According to the United Nations Environment Programme (UNEP), mining-related activities contribute to 9% of global mercury emissions, posing severe health risks to nearby populations. 8 | 9 | To address these environmental challenges, the mining industry must adopt sustainable practices, such as responsible water management, waste reduction, and the use of renewable energy sources. For example, Company-X has implemented a water management program that reduces water consumption by 30% in its operations in Region-C. Additionally, the industry can explore alternative technologies, such as dry stack tailings management, to minimize the environmental footprint of mining activities. 10 | 11 | Social Challenges: 12 | 13 | Mining operations can have significant social impacts, including displacement of local communities, loss of cultural heritage, and human rights abuses. For instance, a mine in Region-D, operated by Company-Y, has been criticized for its environmental degradation and human rights violations, leading to protests and conflicts with local communities. According to a report by the International Council on Mining and Metals (ICMM), mining-related conflicts have increased by 50% in the past decade, with social and environmental issues being the primary drivers. 14 | 15 | To mitigate social challenges, the mining industry must engage in meaningful dialogue with local communities, respect their rights, and ensure that they benefit from mining activities. For example, Company-Z has implemented a community development program in Region-E that provides education, healthcare, and infrastructure development to local communities. Additionally, the industry can adopt best practices in social and environmental management, such as the ICMM's Sustainable Development Framework, to ensure that mining activities are conducted responsibly. 16 | 17 | Technological Advancements: 18 | 19 | Technological advancements have the potential to transform the mining industry, improving efficiency, reducing costs, and enhancing safety. For instance, autonomous vehicles and drones can improve safety and productivity in mining operations, while data analytics and artificial intelligence can optimize production and reduce waste. According to a report by Company-X, the use of digital technologies in mining can increase productivity by up to 20% and reduce costs by up to 15%. 20 | 21 | However, the adoption of new technologies also presents challenges, such as the need for skilled labor, data privacy and security concerns, and the risk of job displacement. To address these challenges, the mining industry must invest in training and development programs, collaborate with technology providers and academic institutions, and ensure that new technologies are implemented in a responsible and sustainable manner. 22 | 23 | Geopolitical Risks: 24 | 25 | Mining operations are often located in regions with political instability, regulatory uncertainty, and resource nationalism. For instance, a mine in Country-B was affected by a strike in Year-C, leading to a production halt and significant financial losses. According to a report by the World Bank, resource nationalism is on the rise, with countries implementing policies that restrict foreign investment and increase government control over natural resources. 26 | 27 | To mitigate geopolitical risks, the mining industry must engage in proactive stakeholder engagement, build strong relationships with local communities and governments, and ensure that mining activities are conducted in a transparent and accountable manner. Additionally, the industry can explore alternative financing models, such as public-private partnerships, to reduce dependence on traditional sources of financing and mitigate the risk of resource nationalism. 28 | 29 | Regulatory Complexities: 30 | 31 | The mining industry is subject to complex and evolving regulatory frameworks that vary across jurisdictions. For instance, the Extractive Industries Transparency Initiative (EITI) requires companies to disclose payments to governments, while the Dodd-Frank Act in the United States requires companies to disclose their use of conflict minerals. According to a report by the International Institute for Sustainable Development (IISD), the mining industry faces over 3,000 regulations related to environmental, social, and governance issues. 32 | 33 | To navigate regulatory complexities, the mining industry must invest in compliance and reporting systems, collaborate with regulators and civil society organizations, and ensure that mining activities are conducted in a transparent and accountable manner. Additionally, the industry can engage in policy advocacy and contribute to the development of responsible and sustainable mining policies and regulations. 34 | 35 | In conclusion, the mining industry faces a range of challenges that demand innovative solutions and proactive engagement with stakeholders. By adopting sustainable practices, engaging with local communities, investing in new technologies, mitigating geopolitical risks, and navigating regulatory complexities, the mining industry can contribute to economic growth and development while minimizing its environmental and social footprint. As decision-makers in the mining industry, it is critical to stay informed about these challenges and work collaboratively to develop responsible and sustainable mining practices. -------------------------------------------------------------------------------- /models/sdxl.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "1c1b5e70", 6 | "metadata": {}, 7 | "source": [ 8 | "# Deploy Stable Diffusion XL on AWS Inferentia2 " 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "dbaf46a1", 14 | "metadata": {}, 15 | "source": [ 16 | "In this notebook, we deploy a [Stable Diffusion XL](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) model using an Inferentia2 instance and optimum-neuron on Amazon SageMaker. [Optimum Neuron](https://huggingface.co/docs/optimum-neuron/en/index) is the interface betweeen the Transfomers library and AWS Purpose Built Accelerators - AWS Trainium and Inferentia." 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "id": "0648579e", 22 | "metadata": {}, 23 | "source": [ 24 | "## Install required libraries" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "id": "71f470ba", 31 | "metadata": { 32 | "tags": [] 33 | }, 34 | "outputs": [], 35 | "source": [ 36 | "!pip install --upgrade --quiet \"sagemaker\"" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "id": "0971797a", 42 | "metadata": {}, 43 | "source": [ 44 | "Note: you may need to restart the kernel to use updated packages." 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "id": "58f63e0f", 50 | "metadata": {}, 51 | "source": [ 52 | "## Configure SageMaker resources" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "id": "401dc6d4", 59 | "metadata": { 60 | "tags": [] 61 | }, 62 | "outputs": [], 63 | "source": [ 64 | "import sagemaker\n", 65 | "import boto3\n", 66 | "\n", 67 | "sess = sagemaker.Session()\n", 68 | "# Create an Amazon Sagemaker session bucket for uploading data, models and logs\n", 69 | "# Amazon Sagemaker will automatically create this bucket if it does not exist\n", 70 | "sagemaker_session_bucket=None\n", 71 | "if sagemaker_session_bucket is None and sess is not None:\n", 72 | " # If a bucket name is not provided, set to default bucket\n", 73 | " sagemaker_session_bucket = sess.default_bucket()\n", 74 | " \n", 75 | "try:\n", 76 | " role = sagemaker.get_execution_role()\n", 77 | "except ValueError:\n", 78 | " iam = boto3.client('iam')\n", 79 | " role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']\n", 80 | " \n", 81 | "sess = sagemaker.Session(default_bucket=sagemaker_session_bucket)\n", 82 | " \n", 83 | "print(f\"sagemaker role arn: {role}\")\n", 84 | "print(f\"sagemaker bucket: {sess.default_bucket()}\")\n", 85 | "print(f\"sagemaker session region: {sess.boto_region_name}\")\n", 86 | "assert sess.boto_region_name in [\"us-east-2\", \"us-east-1\"] , \"region must be us-east-2 or us-west-2, due to instance availability\"" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "id": "f7daa930", 92 | "metadata": {}, 93 | "source": [ 94 | "## Store a `model.tar.gz` in a s3 bucket" 95 | ] 96 | }, 97 | { 98 | "cell_type": "markdown", 99 | "id": "849d5ece-1f2b-4ff2-9991-7884ea131bff", 100 | "metadata": {}, 101 | "source": [ 102 | "We have pre-compiled the model, added an `inference` script, created a tar file and stored it in a s3 bucket.\n", 103 | "\n", 104 | "To read more about the detailed process, read [Deploy SDXL on AWS Inferentia2 with Amazon SageMaker](https://www.philschmid.de/inferentia2-stable-diffusion-xl) and the [developer documentation for deploying real time endpoints on sagemaker](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-deploy-models.html#deploy-models-studio)" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "id": "64bf58ef-6dc1-47cd-9e65-61e8186efaf9", 111 | "metadata": { 112 | "tags": [] 113 | }, 114 | "outputs": [], 115 | "source": [ 116 | "s3_model_uri = \"s3://sagemaker-examples-files-prod-us-east-2/models/neuron-sdxl-reinvent-2024/model.tar.gz\"" 117 | ] 118 | }, 119 | { 120 | "cell_type": "markdown", 121 | "id": "efa70d29", 122 | "metadata": {}, 123 | "source": [ 124 | "## Deploy the model" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": null, 130 | "id": "5c391b32", 131 | "metadata": { 132 | "tags": [] 133 | }, 134 | "outputs": [], 135 | "source": [ 136 | "from sagemaker.huggingface.model import HuggingFaceModel\n", 137 | " \n", 138 | "# Create Hugging Face Model Class\n", 139 | "huggingface_model = HuggingFaceModel(\n", 140 | " model_data=s3_model_uri, # path to your model.tar.gz on s3\n", 141 | " role=role, # iam role with permissions to create an Endpoint\n", 142 | " transformers_version=\"4.34.1\", # transformers version used\n", 143 | " pytorch_version=\"1.13.1\", # pytorch version used\n", 144 | " py_version='py310', # python version used\n", 145 | " model_server_workers=1, # number of workers for the model server\n", 146 | ")\n", 147 | "huggingface_model._is_compiled_model = True" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "id": "16c12b3d-ef57-4dcd-9e55-fa60aec74243", 154 | "metadata": { 155 | "tags": [] 156 | }, 157 | "outputs": [], 158 | "source": [ 159 | "# Deploy the endpoint\n", 160 | "predictor = huggingface_model.deploy(\n", 161 | " endpoint_name=\"Stable-Diffusion-XL\",\n", 162 | " initial_instance_count=1, # number of instances\n", 163 | " instance_type=\"ml.inf2.xlarge\", # AWS Inferentia Instance\n", 164 | " volume_size = 128\n", 165 | ")\n" 166 | ] 167 | }, 168 | { 169 | "cell_type": "markdown", 170 | "id": "aa4f3453-7656-4e0b-8ee7-c0e9554ab61a", 171 | "metadata": {}, 172 | "source": [ 173 | "### The above step takes about 10-15 minutes.\n", 174 | "\n", 175 | "While you wait for the model to be deployed, you can read the below resources - \n", 176 | "- [AWS Neuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/index.html)\n", 177 | "- [AWS Inferentia2](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/arch/neuron-hardware/inf2-arch.html)\n", 178 | "- [Amazon SageMaker Real Time Inference](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints.html)\n", 179 | "- [Amazon SageMaker with HuggingFace Optimum Neuron](https://huggingface.co/docs/optimum-neuron/en/guides/sagemaker)" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "id": "05000ce0", 185 | "metadata": {}, 186 | "source": [ 187 | "## Invoke the model with a sample prompt" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": null, 193 | "id": "14e0a49f", 194 | "metadata": {}, 195 | "outputs": [], 196 | "source": [ 197 | "from PIL import Image\n", 198 | "from io import BytesIO\n", 199 | "from IPython.display import display\n", 200 | "import base64\n", 201 | " \n", 202 | "# Helper decoder\n", 203 | "def decode_base64_image(image_string):\n", 204 | " base64_image = base64.b64decode(image_string)\n", 205 | " buffer = BytesIO(base64_image)\n", 206 | " return Image.open(buffer)\n", 207 | " \n", 208 | "# Display PIL images as grid\n", 209 | "def display_image(image=None,width=500,height=500):\n", 210 | " img = image.resize((width, height))\n", 211 | " display(img)" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": null, 217 | "id": "06904515", 218 | "metadata": {}, 219 | "outputs": [], 220 | "source": [ 221 | "prompt = \"A dog trying to catch a flying pizza at a street corner, comic book, well lit, night time\"\n", 222 | " \n", 223 | "# Run prediction\n", 224 | "response = predictor.predict(data={\n", 225 | " \"inputs\": prompt,\n", 226 | " \"parameters\": {\n", 227 | " \"num_inference_steps\" : 50,\n", 228 | " \"negative_prompt\" : \"disfigured, ugly, deformed\"\n", 229 | " }\n", 230 | " }\n", 231 | ")\n", 232 | " \n", 233 | "# Decode and display image\n", 234 | "display_image(decode_base64_image(response[\"generated_images\"][0]))" 235 | ] 236 | }, 237 | { 238 | "cell_type": "markdown", 239 | "id": "f7f1468f", 240 | "metadata": {}, 241 | "source": [ 242 | "If the above request times out, please retry and it should succeed." 243 | ] 244 | }, 245 | { 246 | "cell_type": "markdown", 247 | "id": "95eeb729-f190-4e74-8ecb-b1c4bb3625fc", 248 | "metadata": { 249 | "tags": [] 250 | }, 251 | "source": [ 252 | "
\n", 253 | "\n", 254 | "DO NOT DELETE THE ENDPOINT\n", 255 | "\n", 256 | "The endpoints will be used to invoke the models when building our application.\n", 257 | "
" 258 | ] 259 | }, 260 | { 261 | "cell_type": "markdown", 262 | "id": "51f41053", 263 | "metadata": {}, 264 | "source": [ 265 | "## Clean up the environment" 266 | ] 267 | }, 268 | { 269 | "cell_type": "code", 270 | "execution_count": null, 271 | "id": "ee49bbdf", 272 | "metadata": { 273 | "tags": [] 274 | }, 275 | "outputs": [], 276 | "source": [ 277 | "CLEANUP = False # Change to True when you are finished with the workshop\n", 278 | "\n", 279 | "if CLEANUP:\n", 280 | " predictor.delete_model()\n", 281 | " predictor.delete_endpoint()" 282 | ] 283 | } 284 | ], 285 | "metadata": { 286 | "kernelspec": { 287 | "display_name": "conda_python3", 288 | "language": "python", 289 | "name": "conda_python3" 290 | }, 291 | "language_info": { 292 | "codemirror_mode": { 293 | "name": "ipython", 294 | "version": 3 295 | }, 296 | "file_extension": ".py", 297 | "mimetype": "text/x-python", 298 | "name": "python", 299 | "nbconvert_exporter": "python", 300 | "pygments_lexer": "ipython3", 301 | "version": "3.10.14" 302 | } 303 | }, 304 | "nbformat": 4, 305 | "nbformat_minor": 5 306 | } -------------------------------------------------------------------------------- /references/offerings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Construction": "AnyCompany Consulting Construction Consulting Services Offerings\n\nIntroduction\n\nAnyCompany Consulting is a premier construction consulting firm dedicated to providing comprehensive and innovative solutions to the construction industry. With a team of highly skilled and experienced professionals, we offer a wide range of services tailored to meet the unique needs of our clients. Our mission is to empower construction companies, developers, and owners to achieve their goals through effective project management, strategic planning, and cutting-edge expertise.\n\nCompany Culture\n\nAt AnyCompany Consulting, we cultivate a collaborative and dynamic work environment that fosters growth, innovation, and excellence. We believe that our success is driven by the collective efforts of our diverse and talented team. We value integrity, transparency, and a commitment to continuous learning and professional development.\n\nOur core values are:\n\n1. Client-Centric Approach: We put our clients at the heart of everything we do, consistently striving to exceed their expectations and deliver exceptional value.\n2. Innovative Solutions: We embrace innovation and leverage the latest technologies and methodologies to provide cutting-edge solutions that drive efficiency and success.\n3. Expertise and Professionalism: Our team consists of highly skilled and experienced professionals who bring a wealth of knowledge and professionalism to every project.\n4. Teamwork and Collaboration: We promote a culture of teamwork and collaboration, fostering an environment where ideas are shared, and collective expertise is leveraged to achieve optimal results.\n5. Integrity and Ethics: We uphold the highest standards of integrity and ethics, maintaining transparency and accountability in all our dealings.\n\nOur Offerings\n\nAt AnyCompany Consulting, we offer a comprehensive suite of construction consulting services designed to support our clients throughout the entire project lifecycle. Our offerings include:\n\n1. Pre-Construction Services\n - Feasibility Studies\n - Site Selection and Evaluation\n - Environmental Impact Assessments\n - Regulatory Compliance Analysis\n - Constructability Reviews\n - Value Engineering\n - Cost Estimating and Budgeting\n - Procurement Strategies\n\n2. Project Management Services\n - Project Planning and Scheduling\n - Risk Management\n - Contract Administration\n - Quality Assurance and Quality Control (QA/QC)\n - Construction Monitoring and Inspections\n - Progress Reporting and Documentation\n - Change Order Management\n - Claims Analysis and Resolution\n - Project Closeout and Commissioning\n\n3. Construction Advisory Services\n - Construction Methods and Techniques\n - Lean Construction Implementation\n - Building Information Modeling (BIM) Integration\n - Sustainability and Green Building Consulting\n - Safety and Risk Management\n - Labor Compliance and Workforce Management\n - Dispute Resolution and Mediation\n\n4. Specialized Engineering Services\n - Structural Engineering Consulting\n - Mechanical, Electrical, and Plumbing (MEP) Consulting\n - Fire Protection and Life Safety Engineering\n - Environmental Engineering\n - Geotechnical Engineering\n - Forensic Engineering and Failure Analysis\n - Building Enclosure Consulting\n\n5. Construction Technology Solutions\n - Construction Data Analytics and Reporting\n - Construction Automation and Robotics\n - Internet of Things (IoT) and Smart Construction\n - Virtual and Augmented Reality (VR/AR) Applications\n - Unmanned Aerial Vehicles (UAVs) and Drone Technology\n\n6. Training and Professional Development\n - Construction Management Training Programs\n - Leadership and Team Building Workshops\n - Technical and Regulatory Compliance Training\n - Certification Preparation and Continuing Education\n\nOur Approach\n\nAt AnyCompany Consulting, we pride ourselves on our client-centric approach, tailoring our services to meet the specific needs and objectives of each project. Our consulting process is driven by a deep understanding of the construction industry, combined with a keen eye for detail and a commitment to delivering exceptional results.\n\nWe begin by collaborating closely with our clients to gain a comprehensive understanding of their project requirements, goals, and challenges. Our team of experts then develops a customized strategy that leverages our diverse expertise and industry-leading methodologies.\n\nThroughout the project lifecycle, we maintain open lines of communication with our clients, providing regular progress updates, addressing concerns, and proactively identifying and mitigating potential risks. Our goal is to foster a collaborative partnership, ensuring that our clients are fully informed and involved in the decision-making process.\n\nAt AnyCompany Consulting, we are committed to staying at the forefront of industry trends and advancements. We continuously invest in research and development, adopting cutting-edge technologies and refining our processes to deliver innovative and effective solutions.\n\nWhy Choose AnyCompany Consulting?\n\nAt AnyCompany Consulting, we are dedicated to providing our clients with unparalleled value and exceptional service. Our key differentiators include:\n\n1. Experienced and Diverse Team: Our team comprises seasoned professionals with a wide range of expertise, enabling us to tackle even the most complex projects with confidence and precision.\n\n2. Customized Solutions: We understand that every project is unique, and we tailor our solutions to meet the specific needs and objectives of our clients, ensuring optimal results.\n\n3. Innovative Approach: We embrace innovation and leverage the latest technologies and methodologies to drive efficiency, enhance performance, and deliver cutting-edge solutions.\n\n4. Proven Track Record: With a proven track record of delivering successful projects across various sectors and industries, we have earned a reputation for excellence and reliability.\n\n5. Commitment to Excellence: We are committed to upholding the highest standards of excellence in everything we do, from our processes to our deliverables, ensuring that our clients receive the highest quality of service.\n\n6. Collaborative Partnerships: We believe in fostering collaborative partnerships with our clients, working together as a team to achieve shared goals and overcome challenges.\n\nContact Us\n\nAt AnyCompany Consulting, we are passionate about helping our clients achieve success in their construction endeavors. If you are seeking a trusted and experienced construction consulting partner, we invite you to contact us today. Our team of experts is ready to discuss your project requirements and develop a tailored solution that meets your needs.\n\nTogether, we can unlock new possibilities and drive your construction projects to new heights of success.", 3 | "Manufacturing": "AnyCompany Consulting Manufacturing Consulting Services Offerings\n\nIntroduction\n\nAt AnyCompany Consulting, we are dedicated to providing leading-edge consulting services to the manufacturing industry. Our team of seasoned professionals leverages decades of combined experience and cutting-edge expertise to drive operational excellence, optimize processes, and unlock new opportunities for growth and profitability.\n\nOur Mission\n\nOur mission is to empower manufacturing organizations to achieve sustainable competitive advantage through innovative solutions, strategic guidance, and a relentless pursuit of operational excellence. We are committed to delivering tailored services that align with our clients' unique objectives, challenges, and industry dynamics.\n\nOur Expertise\n\nAnyCompany Consulting boasts a diverse team of experts with deep domain knowledge spanning various manufacturing sectors, including:\n\n- Automotive\n- Aerospace\n- Electronics\n- Machinery\n- Consumer Goods\n- Pharmaceuticals\n- Food and Beverage\n- Chemicals\n\nOur consultants bring a wealth of practical experience, enabling us to provide holistic solutions that address the complexities and nuances of your specific manufacturing environment.\n\nOur Offerings\n\nAt AnyCompany Consulting, we offer a comprehensive suite of consulting services designed to support manufacturing organizations throughout their operational lifecycle. Our offerings include:\n\n1. Operational Excellence\n - Lean Manufacturing Implementation\n - Six Sigma Methodologies\n - Continuous Improvement Programs\n - Process Optimization and Streamlining\n - Quality Management Systems\n - Supply Chain Optimization\n\n2. Production and Factory Operations\n - Production Planning and Scheduling\n - Plant Layout and Facility Design\n - Capacity Planning and Utilization\n - Inventory Management and Control\n - Maintenance and Reliability Engineering\n - Energy Efficiency and Sustainability\n\n3. Manufacturing Strategy and Transformation\n - Strategic Planning and Roadmapping\n - Digital Transformation Initiatives\n - Smart Manufacturing and Industry 4.0\n - Product Lifecycle Management (PLM)\n - Enterprise Resource Planning (ERP) Implementation\n - Change Management and Organizational Design\n\n4. Engineering and Product Development\n - New Product Introduction (NPI)\n - Design for Manufacturing (DFM)\n - Value Engineering and Cost Reduction\n - Prototyping and Simulation\n - Supplier Management and Collaboration\n - Regulatory Compliance and Certifications\n\n5. Automation and Robotics\n - Automation Strategy and Feasibility Studies\n - Robotic Process Automation (RPA)\n - Industrial Robotics and Automation Systems\n - Machine Vision and Sensing Technologies\n - Internet of Things (IoT) and Connected Manufacturing\n - Predictive Maintenance and Asset Management\n\n6. Workforce Development and Training\n - Skill Gap Analysis and Workforce Planning\n - Technical and Operational Training Programs\n - Leadership and Management Development\n - Safety and Compliance Training\n - Apprenticeship and Mentorship Programs\n\nOur Approach\n\nAt AnyCompany Consulting, we believe in a collaborative and tailored approach to consulting. We work closely with our clients to gain a deep understanding of their unique challenges, goals, and operational dynamics. Our consultants then develop customized solutions that leverage our expertise, industry best practices, and proven methodologies.\n\nThroughout the engagement, we maintain open communication and transparency, fostering a partnership built on trust and shared accountability. We provide regular progress updates, address concerns, and proactively identify and mitigate potential risks.\n\nOur commitment to delivering tangible results is unwavering. We measure success by the measurable improvements in operational performance, cost savings, and bottom-line impact achieved for our clients.\n\nWhy Choose AnyCompany Consulting?\n\nAt AnyCompany Consulting, we pride ourselves on our ability to deliver exceptional value and drive transformative change for our manufacturing clients. Here are some of the key reasons why organizations choose to partner with us:\n\n1. Proven Track Record: With a portfolio of successful projects across various manufacturing sectors, we have a proven track record of delivering measurable results and driving operational excellence.\n\n2. Industry-Leading Expertise: Our team comprises seasoned professionals with deep industry knowledge and hands-on experience, enabling us to provide practical, actionable solutions tailored to your specific needs.\n\n3. Innovative Mindset: We embrace innovation and stay at the forefront of emerging technologies, methodologies, and industry trends, ensuring our clients benefit from cutting-edge solutions.\n\n4. Holistic Approach: We take a holistic view of your manufacturing operations, considering the interconnectedness of processes, systems, and organizational dynamics to deliver comprehensive and sustainable solutions.\n\n5. Collaborative Partnerships: We foster collaborative partnerships with our clients, working together as a team to achieve shared goals and overcome challenges.\n\n6. Commitment to Excellence: We are committed to upholding the highest standards of excellence in everything we do, from our processes to our deliverables, ensuring our clients receive the highest quality of service.\n\nContact Us\n\nAt AnyCompany Consulting, we are passionate about driving manufacturing excellence and empowering organizations to achieve their full potential. If you are seeking a trusted and experienced manufacturing consulting partner, we invite you to contact us today. Our team of experts is ready to discuss your unique requirements and develop tailored solutions to propel your operations to new heights of success.\n\nTogether, we can unlock new possibilities and shape the future of manufacturing.", 4 | "Mining": "AnyCompany Consulting Mining Consulting Services Offerings\n\nIntroduction\n\nAt AnyCompany Consulting, we are a premier consulting firm dedicated to providing innovative and comprehensive solutions to the mining industry. Our team of seasoned professionals leverages decades of combined experience and cutting-edge expertise to drive operational excellence, optimize processes, and unlock new opportunities for growth and profitability.\n\nOur Mission\n\nOur mission is to empower mining organizations to achieve sustainable competitive advantage through strategic guidance, innovative solutions, and a relentless pursuit of operational excellence. We are committed to delivering tailored services that align with our clients' unique objectives, challenges, and industry dynamics.\n\nOur Expertise\n\nAnyCompany Consulting boasts a diverse team of experts with deep domain knowledge spanning various mining sectors, including:\n\n- Metals and Minerals\n- Coal\n- Precious Metals and Gemstones\n- Industrial Minerals\n- Energy Resources (Oil, Gas, and Renewable Energy)\n\nOur consultants bring a wealth of practical experience, enabling us to provide holistic solutions that address the complexities and nuances of your specific mining environment.\n\nOur Offerings\n\nAt AnyCompany Consulting, we offer a comprehensive suite of consulting services designed to support mining organizations throughout their operational lifecycle. Our offerings include:\n\n1. Exploration and Resource Evaluation\n - Geological Modeling and Resource Estimation\n - Geostatistical Analysis and Ore Body Modeling\n - Exploration Program Design and Management\n - Geophysical and Geochemical Surveys\n - Resource Classification and Reporting\n\n2. Mine Planning and Design\n - Mine Feasibility Studies\n - Mine Design and Layout\n - Mine Scheduling and Production Planning\n - Equipment Selection and Fleet Management\n - Mine Ventilation and Ground Control\n\n3. Mining Operations and Optimization\n - Mining Method Selection and Optimization\n - Productivity Improvement and Cost Reduction\n - Operational Risk Assessment and Mitigation\n - Materials Handling and Logistics Optimization\n - Maintenance and Reliability Engineering\n\n4. Environmental and Sustainability\n - Environmental Impact Assessments (EIAs)\n - Environmental Management and Compliance\n - Water Management and Treatment\n - Waste Management and Tailings Disposal\n - Mine Closure and Reclamation Planning\n\n5. Health, Safety, and Risk Management\n - Occupational Health and Safety (OHS) Audits\n - Risk Assessment and Mitigation Strategies\n - Emergency Response and Crisis Management\n - Safety Culture Development and Training\n\n6. Digital Transformation and Technology\n - Mine Automation and Robotics\n - Data Analytics and Business Intelligence\n - Internet of Things (IoT) and Connected Mining\n - Operational Technology (OT) and IT Integration\n - Simulation and Virtual Reality Applications\n\n7. Mining Strategy and Transformation\n - Strategic Planning and Roadmapping\n - Mergers, Acquisitions, and Divestments\n - Organizational Design and Change Management\n - Supply Chain Optimization and Procurement\n - Enterprise Resource Planning (ERP) Implementation\n\nOur Approach\n\nAt AnyCompany Consulting, we believe in a collaborative and tailored approach to consulting. We work closely with our clients to gain a deep understanding of their unique challenges, goals, and operational dynamics. Our consultants then develop customized solutions that leverage our expertise, industry best practices, and proven methodologies.\n\nThroughout the engagement, we maintain open communication and transparency, fostering a partnership built on trust and shared accountability. We provide regular progress updates, address concerns, and proactively identify and mitigate potential risks.\n\nOur commitment to delivering tangible results is unwavering. We measure success by the measurable improvements in operational performance, cost savings, and bottom-line impact achieved for our clients.\n\nWhy Choose AnyCompany Consulting?\n\nAt AnyCompany Consulting, we pride ourselves on our ability to deliver exceptional value and drive transformative change for our mining clients. Here are some of the key reasons why organizations choose to partner with us:\n\n1. Proven Track Record: With a portfolio of successful projects across various mining sectors, we have a proven track record of delivering measurable results and driving operational excellence.\n\n2. Industry-Leading Expertise: Our team comprises seasoned professionals with deep industry knowledge and hands-on experience, enabling us to provide practical, actionable solutions tailored to your specific needs.\n\n3. Innovative Mindset: We embrace innovation and stay at the forefront of emerging technologies, methodologies, and industry trends, ensuring our clients benefit from cutting-edge solutions.\n\n4. Holistic Approach: We take a holistic view of your mining operations, considering the interconnectedness of processes, systems, and organizational dynamics to deliver comprehensive and sustainable solutions.\n\n5. Collaborative Partnerships: We foster collaborative partnerships with our clients, working together as a team to achieve shared goals and overcome challenges.\n\n6. Commitment to Excellence: We are committed to upholding the highest standards of excellence in everything we do, from our processes to our deliverables, ensuring our clients receive the highest quality of service.\n\nContact Us\n\nAt AnyCompany Consulting, we are passionate about driving mining excellence and empowering organizations to achieve their full potential. If you are seeking a trusted and experienced mining consulting partner, we invite you to contact us today. Our team of experts is ready to discuss your unique requirements and develop tailored solutions to propel your operations to new heights of success.\n\nTogether, we can unlock new possibilities and shape the future of the mining industry." 5 | } -------------------------------------------------------------------------------- /models/llama3-8b-instruct-neuron-TGI.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "3dbb66af-32aa-457a-a000-edf44b7077a7", 6 | "metadata": {}, 7 | "source": [ 8 | "# Deploy Llama3.1-8b-Instruct on AWS Inferentia2 using Amazon SageMaker and Huggingface TGI container" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "1e054182-848f-4ff0-8e3c-505d385c5b2c", 14 | "metadata": {}, 15 | "source": [ 16 | "[Text Generation Inference (TGI)](https://huggingface.co/docs/optimum-neuron/guides/neuronx_tgi), is a purpose-built solution for deploying and serving Large Language Models (LLMs) for production workloads at scale. TGI enables high-performance text generation using Tensor Parallelism and continuous batching for the most popular open LLMs, including Llama, Mistral, and more. \n", 17 | "\n", 18 | "The integration of TGI into Amazon SageMaker, in combination with AWS Inferentia2, presents a powerful solution and viable alternative to GPUs for building production LLM applications. The seamless integration ensures easy deployment and maintenance of models, making LLMs more accessible and scalable for a wide range of production use cases.\n", 19 | "\n", 20 | "With the new TGI for AWS Inferentia2 on Amazon SageMaker, AWS customers can benefit from the same technologies that power highly-concurrent, low-latency LLM experiences like HuggingChat, OpenAssistant, and Serverless Endpoints for LLMs on the Hugging Face Hub.\n" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "id": "c95e9f73-1502-42fe-9d3a-aaea85b30636", 26 | "metadata": {}, 27 | "source": [ 28 | "In this notebook, you'll do the following:\n", 29 | "\n", 30 | "1. Setup the development environment\n", 31 | "2. Retrieve the TGI Neuronx Image\n", 32 | "3. Deploy [Llama3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) to Amazon SageMaker\n", 33 | "4. Run inference and chat with the model" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "id": "63f2b962", 39 | "metadata": {}, 40 | "source": [ 41 | "## Prerequisites\n", 42 | "\n", 43 | "This Jupyter Notebook can be run on a t3.medium instance (ml.t3.medium). However, to deploy `Llama3.1-8B`, you will use a `inf2.xl` instance behind a SageMaker endpoint." 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "id": "5da4446b-6c96-421c-be4a-b1b857af177b", 49 | "metadata": {}, 50 | "source": [ 51 | "## 1. Install, import the required libraries, and set some variables" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": null, 57 | "id": "a674e696-03c6-494c-a02b-32b6d9a6b265", 58 | "metadata": { 59 | "tags": [] 60 | }, 61 | "outputs": [], 62 | "source": [ 63 | "!pip install \"sagemaker==2.232.2\" transformers --upgrade --quiet" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "id": "b6ab19cd-a134-48f5-9c44-f0e85928eae0", 69 | "metadata": {}, 70 | "source": [ 71 | "Note: You might have to restart the kernel to use the installed packages" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "id": "cc208783-b051-43ce-8740-27113d2d5eef", 78 | "metadata": { 79 | "tags": [] 80 | }, 81 | "outputs": [], 82 | "source": [ 83 | "import sagemaker\n", 84 | "import boto3\n", 85 | "sess = sagemaker.Session()\n", 86 | "# sagemaker session bucket -> used for uploading data, models and logs\n", 87 | "# sagemaker will automatically create this bucket if it doesn't exist\n", 88 | "sagemaker_session_bucket=None\n", 89 | "if sagemaker_session_bucket is None and sess is not None:\n", 90 | " # set to default bucket if a bucket name is not given\n", 91 | " sagemaker_session_bucket = sess.default_bucket()\n", 92 | "\n", 93 | "try:\n", 94 | " role = sagemaker.get_execution_role()\n", 95 | "except ValueError:\n", 96 | " iam = boto3.client('iam')\n", 97 | " role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']\n", 98 | "\n", 99 | "sess = sagemaker.Session(default_bucket=sagemaker_session_bucket)\n", 100 | "\n", 101 | "print(f\"sagemaker role arn: {role}\")\n", 102 | "print(f\"sagemaker session region: {sess.boto_region_name}\")\n" 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "id": "b1de1fc3-ad34-4c96-a6a4-1b4e48936b37", 108 | "metadata": {}, 109 | "source": [ 110 | "## 2. Retrieve TGI Neuronx Image\n", 111 | "\n", 112 | "The new Hugging Face TGI Neuronx DLCs can be used to run inference on AWS Inferentia2. You can also use the get_huggingface_llm_image_uri method of the sagemaker SDK to retrieve the appropriate Hugging Face TGI Neuronx DLC URI based on your desired backend, session, region, and version. You can find all the available versions [here](https://github.com/aws/deep-learning-containers/releases?q=tgi+AND+neuronx&expanded=true).\n" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "id": "76f9ed4e-f7f6-4a46-9004-a96acc2825d1", 119 | "metadata": { 120 | "tags": [] 121 | }, 122 | "outputs": [], 123 | "source": [ 124 | "from sagemaker.huggingface import get_huggingface_llm_image_uri\n", 125 | "\n", 126 | "# retrieve the llm image uri\n", 127 | "#llm_image = get_huggingface_llm_image_uri(\n", 128 | "# \"huggingface-neuronx\",\n", 129 | "# version=\"0.0.25\"\n", 130 | "#)\n", 131 | "\n", 132 | "tgi_image_uri = \"763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.1.2-optimum0.0.25-neuronx-py310-ubuntu22.04-v1.0\"\n", 133 | "\n", 134 | "# print ecr image uri\n", 135 | "print(f\"tgi image uri: {tgi_image_uri}\")\n" 136 | ] 137 | }, 138 | { 139 | "cell_type": "markdown", 140 | "id": "6486a48f-ddf2-4d86-9425-2730c5f9a73e", 141 | "metadata": {}, 142 | "source": [ 143 | "## 3. Deploy Llama3.1 8B Instruct on Amazon SageMaker\n", 144 | "\n", 145 | "\n", 146 | "[Text Generation Inference (TGI)](https://github.com/huggingface/optimum-neuron/tree/main/text-generation-inference) on Inferentia2 supports popular open LLMs, including Llama, Mistral, and more. [Supported Architectures](https://huggingface.co/docs/optimum-neuron/en/package_reference/supported_models) has a list of supported models.\n", 147 | "\n", 148 | "\n", 149 | "### Compiling LLMs for Inferentia2\n", 150 | "\n", 151 | "To deploy models on AWS Inferentia2, we need to compile the model with a sequence length and batch size ahead of time. To make it easier for customers to utilize the full power of Inferentia2, we created a [neuron model cache](https://huggingface.co/aws-neuron/optimum-neuron-cache), which contains pre-compiled configurations for the most popular LLMs. A cached configuration is defined through a model architecture (Llama3), model size (8B), neuron SDK version (2.20), number of inferentia cores (2), batch size (4), and sequence length (4096).\n", 152 | "\n", 153 | "**This means that when deploying models with an architecture based on Llama3 and a configuration for which Neuron compiled artifacts exist; there will be no need to re-compile your model.**\n" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": null, 159 | "id": "82dc7f52-38e3-4d86-a88f-9a7ad9b3a597", 160 | "metadata": { 161 | "tags": [] 162 | }, 163 | "outputs": [], 164 | "source": [ 165 | "import json\n", 166 | "from sagemaker.huggingface import HuggingFaceModel\n", 167 | "\n", 168 | "# sagemaker config & model config\n", 169 | "instance_type = \"ml.inf2.xlarge\"\n", 170 | "#health_check_timeout = 3600\n", 171 | "\n", 172 | "# Define Model and Endpoint configuration parameter\n", 173 | "config = {\n", 174 | " \"HF_MODEL_ID\": \"NousResearch/Meta-Llama-3.1-8B-Instruct\",\n", 175 | " \"HF_NUM_CORES\": \"2\",\n", 176 | " \"HF_BATCH_SIZE\": \"1\",\n", 177 | " \"HF_SEQUENCE_LENGTH\": \"8192\",\n", 178 | " \"HF_AUTO_CAST_TYPE\": \"bf16\",\n", 179 | " \"MAX_BATCH_SIZE\": \"1\",\n", 180 | " #\"MAX_INPUT_LENGTH\": \"3584\",\n", 181 | " \"MAX_TOTAL_TOKENS\": \"8192\"\n", 182 | "}\n", 183 | "\n", 184 | "# create HuggingFaceModel with the image uri\n", 185 | "llm_model = HuggingFaceModel(\n", 186 | " role=role,\n", 187 | " image_uri=tgi_image_uri,\n", 188 | " env=config\n", 189 | ")\n", 190 | "llm_model._is_compiled_model = True" 191 | ] 192 | }, 193 | { 194 | "cell_type": "code", 195 | "execution_count": null, 196 | "id": "711369c6-edf8-4f28-9ab5-727005b43308", 197 | "metadata": { 198 | "scrolled": true, 199 | "tags": [] 200 | }, 201 | "outputs": [], 202 | "source": [ 203 | "# Deploy model to an endpoint\n", 204 | "llm = llm_model.deploy(\n", 205 | " endpoint_name=\"Llama3-1-8B\",\n", 206 | " initial_instance_count=1,\n", 207 | " instance_type=instance_type,\n", 208 | " container_startup_health_check_timeout=1800,\n", 209 | " volume_size=512\n", 210 | ")" 211 | ] 212 | }, 213 | { 214 | "cell_type": "markdown", 215 | "id": "381fe8ef-41d4-4620-9325-0a3d1d498efa", 216 | "metadata": {}, 217 | "source": [ 218 | "### The above step takes about 10-15 minutes.\n", 219 | "\n", 220 | "While you wait for the model to be deployed, you can read the below resources - \n", 221 | "- [AWS Neuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/index.html)\n", 222 | "- [AWS Inferentia2](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/arch/neuron-hardware/inf2-arch.html)\n", 223 | "- [Amazon SageMaker with HuggingFace Optimum Neuron](https://huggingface.co/docs/optimum-neuron/en/guides/sagemaker)" 224 | ] 225 | }, 226 | { 227 | "cell_type": "markdown", 228 | "id": "905e9422-d3b8-4574-bd99-3979c259a6a2", 229 | "metadata": {}, 230 | "source": [ 231 | "## Invoke the Endpoint" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": null, 237 | "id": "eb798b78-1612-4d1a-a111-1726e19c5a57", 238 | "metadata": { 239 | "tags": [] 240 | }, 241 | "outputs": [], 242 | "source": [ 243 | "from transformers import AutoTokenizer\n", 244 | "\n", 245 | "# load the tokenizer\n", 246 | "tokenizer = AutoTokenizer.from_pretrained(\n", 247 | " \"NousResearch/Meta-Llama-3.1-8B-Instruct\"\n", 248 | ")\n", 249 | "\n", 250 | "# Prompt to generate\n", 251 | "messages = [\n", 252 | " {\"role\": \"system\", \"content\": \"You are the AWS expert\"},\n", 253 | " {\"role\": \"user\", \"content\": \"Can you tell me an interesting fact about AWS?\"},\n", 254 | "]\n", 255 | "prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)\n", 256 | "\n", 257 | "# Generation arguments\n", 258 | "parameters = {\n", 259 | " \"do_sample\": True,\n", 260 | " \"top_p\": 0.6,\n", 261 | " \"temperature\": 0.9,\n", 262 | " \"max_new_tokens\": 1024,\n", 263 | " \"return_full_text\": False,\n", 264 | "}\n", 265 | "\n", 266 | "res = llm.predict({\"inputs\": prompt, \"parameters\": parameters})\n", 267 | "print(res[0][\"generated_text\"].strip().replace(\"\", \"\"))" 268 | ] 269 | }, 270 | { 271 | "cell_type": "markdown", 272 | "id": "40e29d3b-2a2d-442a-8b69-9e2843e5a835", 273 | "metadata": { 274 | "tags": [] 275 | }, 276 | "source": [ 277 | "
\n", 278 | "\n", 279 | "DO NOT DELETE THE ENDPOINT\n", 280 | "\n", 281 | "The endpoints will be used to invoke the models when building our application.\n", 282 | "
" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": null, 288 | "id": "43848396-def4-43f0-81b1-d35b11d2d423", 289 | "metadata": { 290 | "tags": [] 291 | }, 292 | "outputs": [], 293 | "source": [ 294 | "CLEANUP = False # Change to True when you are finished with the workshop\n", 295 | "\n", 296 | "if CLEANUP:\n", 297 | " llm.delete_model()\n", 298 | " llm.delete_endpoint()" 299 | ] 300 | } 301 | ], 302 | "metadata": { 303 | "availableInstances": [ 304 | { 305 | "_defaultOrder": 0, 306 | "_isFastLaunch": true, 307 | "category": "General purpose", 308 | "gpuNum": 0, 309 | "hideHardwareSpecs": false, 310 | "memoryGiB": 4, 311 | "name": "ml.t3.medium", 312 | "vcpuNum": 2 313 | }, 314 | { 315 | "_defaultOrder": 1, 316 | "_isFastLaunch": false, 317 | "category": "General purpose", 318 | "gpuNum": 0, 319 | "hideHardwareSpecs": false, 320 | "memoryGiB": 8, 321 | "name": "ml.t3.large", 322 | "vcpuNum": 2 323 | }, 324 | { 325 | "_defaultOrder": 2, 326 | "_isFastLaunch": false, 327 | "category": "General purpose", 328 | "gpuNum": 0, 329 | "hideHardwareSpecs": false, 330 | "memoryGiB": 16, 331 | "name": "ml.t3.xlarge", 332 | "vcpuNum": 4 333 | }, 334 | { 335 | "_defaultOrder": 3, 336 | "_isFastLaunch": false, 337 | "category": "General purpose", 338 | "gpuNum": 0, 339 | "hideHardwareSpecs": false, 340 | "memoryGiB": 32, 341 | "name": "ml.t3.2xlarge", 342 | "vcpuNum": 8 343 | }, 344 | { 345 | "_defaultOrder": 4, 346 | "_isFastLaunch": true, 347 | "category": "General purpose", 348 | "gpuNum": 0, 349 | "hideHardwareSpecs": false, 350 | "memoryGiB": 8, 351 | "name": "ml.m5.large", 352 | "vcpuNum": 2 353 | }, 354 | { 355 | "_defaultOrder": 5, 356 | "_isFastLaunch": false, 357 | "category": "General purpose", 358 | "gpuNum": 0, 359 | "hideHardwareSpecs": false, 360 | "memoryGiB": 16, 361 | "name": "ml.m5.xlarge", 362 | "vcpuNum": 4 363 | }, 364 | { 365 | "_defaultOrder": 6, 366 | "_isFastLaunch": false, 367 | "category": "General purpose", 368 | "gpuNum": 0, 369 | "hideHardwareSpecs": false, 370 | "memoryGiB": 32, 371 | "name": "ml.m5.2xlarge", 372 | "vcpuNum": 8 373 | }, 374 | { 375 | "_defaultOrder": 7, 376 | "_isFastLaunch": false, 377 | "category": "General purpose", 378 | "gpuNum": 0, 379 | "hideHardwareSpecs": false, 380 | "memoryGiB": 64, 381 | "name": "ml.m5.4xlarge", 382 | "vcpuNum": 16 383 | }, 384 | { 385 | "_defaultOrder": 8, 386 | "_isFastLaunch": false, 387 | "category": "General purpose", 388 | "gpuNum": 0, 389 | "hideHardwareSpecs": false, 390 | "memoryGiB": 128, 391 | "name": "ml.m5.8xlarge", 392 | "vcpuNum": 32 393 | }, 394 | { 395 | "_defaultOrder": 9, 396 | "_isFastLaunch": false, 397 | "category": "General purpose", 398 | "gpuNum": 0, 399 | "hideHardwareSpecs": false, 400 | "memoryGiB": 192, 401 | "name": "ml.m5.12xlarge", 402 | "vcpuNum": 48 403 | }, 404 | { 405 | "_defaultOrder": 10, 406 | "_isFastLaunch": false, 407 | "category": "General purpose", 408 | "gpuNum": 0, 409 | "hideHardwareSpecs": false, 410 | "memoryGiB": 256, 411 | "name": "ml.m5.16xlarge", 412 | "vcpuNum": 64 413 | }, 414 | { 415 | "_defaultOrder": 11, 416 | "_isFastLaunch": false, 417 | "category": "General purpose", 418 | "gpuNum": 0, 419 | "hideHardwareSpecs": false, 420 | "memoryGiB": 384, 421 | "name": "ml.m5.24xlarge", 422 | "vcpuNum": 96 423 | }, 424 | { 425 | "_defaultOrder": 12, 426 | "_isFastLaunch": false, 427 | "category": "General purpose", 428 | "gpuNum": 0, 429 | "hideHardwareSpecs": false, 430 | "memoryGiB": 8, 431 | "name": "ml.m5d.large", 432 | "vcpuNum": 2 433 | }, 434 | { 435 | "_defaultOrder": 13, 436 | "_isFastLaunch": false, 437 | "category": "General purpose", 438 | "gpuNum": 0, 439 | "hideHardwareSpecs": false, 440 | "memoryGiB": 16, 441 | "name": "ml.m5d.xlarge", 442 | "vcpuNum": 4 443 | }, 444 | { 445 | "_defaultOrder": 14, 446 | "_isFastLaunch": false, 447 | "category": "General purpose", 448 | "gpuNum": 0, 449 | "hideHardwareSpecs": false, 450 | "memoryGiB": 32, 451 | "name": "ml.m5d.2xlarge", 452 | "vcpuNum": 8 453 | }, 454 | { 455 | "_defaultOrder": 15, 456 | "_isFastLaunch": false, 457 | "category": "General purpose", 458 | "gpuNum": 0, 459 | "hideHardwareSpecs": false, 460 | "memoryGiB": 64, 461 | "name": "ml.m5d.4xlarge", 462 | "vcpuNum": 16 463 | }, 464 | { 465 | "_defaultOrder": 16, 466 | "_isFastLaunch": false, 467 | "category": "General purpose", 468 | "gpuNum": 0, 469 | "hideHardwareSpecs": false, 470 | "memoryGiB": 128, 471 | "name": "ml.m5d.8xlarge", 472 | "vcpuNum": 32 473 | }, 474 | { 475 | "_defaultOrder": 17, 476 | "_isFastLaunch": false, 477 | "category": "General purpose", 478 | "gpuNum": 0, 479 | "hideHardwareSpecs": false, 480 | "memoryGiB": 192, 481 | "name": "ml.m5d.12xlarge", 482 | "vcpuNum": 48 483 | }, 484 | { 485 | "_defaultOrder": 18, 486 | "_isFastLaunch": false, 487 | "category": "General purpose", 488 | "gpuNum": 0, 489 | "hideHardwareSpecs": false, 490 | "memoryGiB": 256, 491 | "name": "ml.m5d.16xlarge", 492 | "vcpuNum": 64 493 | }, 494 | { 495 | "_defaultOrder": 19, 496 | "_isFastLaunch": false, 497 | "category": "General purpose", 498 | "gpuNum": 0, 499 | "hideHardwareSpecs": false, 500 | "memoryGiB": 384, 501 | "name": "ml.m5d.24xlarge", 502 | "vcpuNum": 96 503 | }, 504 | { 505 | "_defaultOrder": 20, 506 | "_isFastLaunch": false, 507 | "category": "General purpose", 508 | "gpuNum": 0, 509 | "hideHardwareSpecs": true, 510 | "memoryGiB": 0, 511 | "name": "ml.geospatial.interactive", 512 | "supportedImageNames": [ 513 | "sagemaker-geospatial-v1-0" 514 | ], 515 | "vcpuNum": 0 516 | }, 517 | { 518 | "_defaultOrder": 21, 519 | "_isFastLaunch": true, 520 | "category": "Compute optimized", 521 | "gpuNum": 0, 522 | "hideHardwareSpecs": false, 523 | "memoryGiB": 4, 524 | "name": "ml.c5.large", 525 | "vcpuNum": 2 526 | }, 527 | { 528 | "_defaultOrder": 22, 529 | "_isFastLaunch": false, 530 | "category": "Compute optimized", 531 | "gpuNum": 0, 532 | "hideHardwareSpecs": false, 533 | "memoryGiB": 8, 534 | "name": "ml.c5.xlarge", 535 | "vcpuNum": 4 536 | }, 537 | { 538 | "_defaultOrder": 23, 539 | "_isFastLaunch": false, 540 | "category": "Compute optimized", 541 | "gpuNum": 0, 542 | "hideHardwareSpecs": false, 543 | "memoryGiB": 16, 544 | "name": "ml.c5.2xlarge", 545 | "vcpuNum": 8 546 | }, 547 | { 548 | "_defaultOrder": 24, 549 | "_isFastLaunch": false, 550 | "category": "Compute optimized", 551 | "gpuNum": 0, 552 | "hideHardwareSpecs": false, 553 | "memoryGiB": 32, 554 | "name": "ml.c5.4xlarge", 555 | "vcpuNum": 16 556 | }, 557 | { 558 | "_defaultOrder": 25, 559 | "_isFastLaunch": false, 560 | "category": "Compute optimized", 561 | "gpuNum": 0, 562 | "hideHardwareSpecs": false, 563 | "memoryGiB": 72, 564 | "name": "ml.c5.9xlarge", 565 | "vcpuNum": 36 566 | }, 567 | { 568 | "_defaultOrder": 26, 569 | "_isFastLaunch": false, 570 | "category": "Compute optimized", 571 | "gpuNum": 0, 572 | "hideHardwareSpecs": false, 573 | "memoryGiB": 96, 574 | "name": "ml.c5.12xlarge", 575 | "vcpuNum": 48 576 | }, 577 | { 578 | "_defaultOrder": 27, 579 | "_isFastLaunch": false, 580 | "category": "Compute optimized", 581 | "gpuNum": 0, 582 | "hideHardwareSpecs": false, 583 | "memoryGiB": 144, 584 | "name": "ml.c5.18xlarge", 585 | "vcpuNum": 72 586 | }, 587 | { 588 | "_defaultOrder": 28, 589 | "_isFastLaunch": false, 590 | "category": "Compute optimized", 591 | "gpuNum": 0, 592 | "hideHardwareSpecs": false, 593 | "memoryGiB": 192, 594 | "name": "ml.c5.24xlarge", 595 | "vcpuNum": 96 596 | }, 597 | { 598 | "_defaultOrder": 29, 599 | "_isFastLaunch": true, 600 | "category": "Accelerated computing", 601 | "gpuNum": 1, 602 | "hideHardwareSpecs": false, 603 | "memoryGiB": 16, 604 | "name": "ml.g4dn.xlarge", 605 | "vcpuNum": 4 606 | }, 607 | { 608 | "_defaultOrder": 30, 609 | "_isFastLaunch": false, 610 | "category": "Accelerated computing", 611 | "gpuNum": 1, 612 | "hideHardwareSpecs": false, 613 | "memoryGiB": 32, 614 | "name": "ml.g4dn.2xlarge", 615 | "vcpuNum": 8 616 | }, 617 | { 618 | "_defaultOrder": 31, 619 | "_isFastLaunch": false, 620 | "category": "Accelerated computing", 621 | "gpuNum": 1, 622 | "hideHardwareSpecs": false, 623 | "memoryGiB": 64, 624 | "name": "ml.g4dn.4xlarge", 625 | "vcpuNum": 16 626 | }, 627 | { 628 | "_defaultOrder": 32, 629 | "_isFastLaunch": false, 630 | "category": "Accelerated computing", 631 | "gpuNum": 1, 632 | "hideHardwareSpecs": false, 633 | "memoryGiB": 128, 634 | "name": "ml.g4dn.8xlarge", 635 | "vcpuNum": 32 636 | }, 637 | { 638 | "_defaultOrder": 33, 639 | "_isFastLaunch": false, 640 | "category": "Accelerated computing", 641 | "gpuNum": 4, 642 | "hideHardwareSpecs": false, 643 | "memoryGiB": 192, 644 | "name": "ml.g4dn.12xlarge", 645 | "vcpuNum": 48 646 | }, 647 | { 648 | "_defaultOrder": 34, 649 | "_isFastLaunch": false, 650 | "category": "Accelerated computing", 651 | "gpuNum": 1, 652 | "hideHardwareSpecs": false, 653 | "memoryGiB": 256, 654 | "name": "ml.g4dn.16xlarge", 655 | "vcpuNum": 64 656 | }, 657 | { 658 | "_defaultOrder": 35, 659 | "_isFastLaunch": false, 660 | "category": "Accelerated computing", 661 | "gpuNum": 1, 662 | "hideHardwareSpecs": false, 663 | "memoryGiB": 61, 664 | "name": "ml.p3.2xlarge", 665 | "vcpuNum": 8 666 | }, 667 | { 668 | "_defaultOrder": 36, 669 | "_isFastLaunch": false, 670 | "category": "Accelerated computing", 671 | "gpuNum": 4, 672 | "hideHardwareSpecs": false, 673 | "memoryGiB": 244, 674 | "name": "ml.p3.8xlarge", 675 | "vcpuNum": 32 676 | }, 677 | { 678 | "_defaultOrder": 37, 679 | "_isFastLaunch": false, 680 | "category": "Accelerated computing", 681 | "gpuNum": 8, 682 | "hideHardwareSpecs": false, 683 | "memoryGiB": 488, 684 | "name": "ml.p3.16xlarge", 685 | "vcpuNum": 64 686 | }, 687 | { 688 | "_defaultOrder": 38, 689 | "_isFastLaunch": false, 690 | "category": "Accelerated computing", 691 | "gpuNum": 8, 692 | "hideHardwareSpecs": false, 693 | "memoryGiB": 768, 694 | "name": "ml.p3dn.24xlarge", 695 | "vcpuNum": 96 696 | }, 697 | { 698 | "_defaultOrder": 39, 699 | "_isFastLaunch": false, 700 | "category": "Memory Optimized", 701 | "gpuNum": 0, 702 | "hideHardwareSpecs": false, 703 | "memoryGiB": 16, 704 | "name": "ml.r5.large", 705 | "vcpuNum": 2 706 | }, 707 | { 708 | "_defaultOrder": 40, 709 | "_isFastLaunch": false, 710 | "category": "Memory Optimized", 711 | "gpuNum": 0, 712 | "hideHardwareSpecs": false, 713 | "memoryGiB": 32, 714 | "name": "ml.r5.xlarge", 715 | "vcpuNum": 4 716 | }, 717 | { 718 | "_defaultOrder": 41, 719 | "_isFastLaunch": false, 720 | "category": "Memory Optimized", 721 | "gpuNum": 0, 722 | "hideHardwareSpecs": false, 723 | "memoryGiB": 64, 724 | "name": "ml.r5.2xlarge", 725 | "vcpuNum": 8 726 | }, 727 | { 728 | "_defaultOrder": 42, 729 | "_isFastLaunch": false, 730 | "category": "Memory Optimized", 731 | "gpuNum": 0, 732 | "hideHardwareSpecs": false, 733 | "memoryGiB": 128, 734 | "name": "ml.r5.4xlarge", 735 | "vcpuNum": 16 736 | }, 737 | { 738 | "_defaultOrder": 43, 739 | "_isFastLaunch": false, 740 | "category": "Memory Optimized", 741 | "gpuNum": 0, 742 | "hideHardwareSpecs": false, 743 | "memoryGiB": 256, 744 | "name": "ml.r5.8xlarge", 745 | "vcpuNum": 32 746 | }, 747 | { 748 | "_defaultOrder": 44, 749 | "_isFastLaunch": false, 750 | "category": "Memory Optimized", 751 | "gpuNum": 0, 752 | "hideHardwareSpecs": false, 753 | "memoryGiB": 384, 754 | "name": "ml.r5.12xlarge", 755 | "vcpuNum": 48 756 | }, 757 | { 758 | "_defaultOrder": 45, 759 | "_isFastLaunch": false, 760 | "category": "Memory Optimized", 761 | "gpuNum": 0, 762 | "hideHardwareSpecs": false, 763 | "memoryGiB": 512, 764 | "name": "ml.r5.16xlarge", 765 | "vcpuNum": 64 766 | }, 767 | { 768 | "_defaultOrder": 46, 769 | "_isFastLaunch": false, 770 | "category": "Memory Optimized", 771 | "gpuNum": 0, 772 | "hideHardwareSpecs": false, 773 | "memoryGiB": 768, 774 | "name": "ml.r5.24xlarge", 775 | "vcpuNum": 96 776 | }, 777 | { 778 | "_defaultOrder": 47, 779 | "_isFastLaunch": false, 780 | "category": "Accelerated computing", 781 | "gpuNum": 1, 782 | "hideHardwareSpecs": false, 783 | "memoryGiB": 16, 784 | "name": "ml.g5.xlarge", 785 | "vcpuNum": 4 786 | }, 787 | { 788 | "_defaultOrder": 48, 789 | "_isFastLaunch": false, 790 | "category": "Accelerated computing", 791 | "gpuNum": 1, 792 | "hideHardwareSpecs": false, 793 | "memoryGiB": 32, 794 | "name": "ml.g5.2xlarge", 795 | "vcpuNum": 8 796 | }, 797 | { 798 | "_defaultOrder": 49, 799 | "_isFastLaunch": false, 800 | "category": "Accelerated computing", 801 | "gpuNum": 1, 802 | "hideHardwareSpecs": false, 803 | "memoryGiB": 64, 804 | "name": "ml.g5.4xlarge", 805 | "vcpuNum": 16 806 | }, 807 | { 808 | "_defaultOrder": 50, 809 | "_isFastLaunch": false, 810 | "category": "Accelerated computing", 811 | "gpuNum": 1, 812 | "hideHardwareSpecs": false, 813 | "memoryGiB": 128, 814 | "name": "ml.g5.8xlarge", 815 | "vcpuNum": 32 816 | }, 817 | { 818 | "_defaultOrder": 51, 819 | "_isFastLaunch": false, 820 | "category": "Accelerated computing", 821 | "gpuNum": 1, 822 | "hideHardwareSpecs": false, 823 | "memoryGiB": 256, 824 | "name": "ml.g5.16xlarge", 825 | "vcpuNum": 64 826 | }, 827 | { 828 | "_defaultOrder": 52, 829 | "_isFastLaunch": false, 830 | "category": "Accelerated computing", 831 | "gpuNum": 4, 832 | "hideHardwareSpecs": false, 833 | "memoryGiB": 192, 834 | "name": "ml.g5.12xlarge", 835 | "vcpuNum": 48 836 | }, 837 | { 838 | "_defaultOrder": 53, 839 | "_isFastLaunch": false, 840 | "category": "Accelerated computing", 841 | "gpuNum": 4, 842 | "hideHardwareSpecs": false, 843 | "memoryGiB": 384, 844 | "name": "ml.g5.24xlarge", 845 | "vcpuNum": 96 846 | }, 847 | { 848 | "_defaultOrder": 54, 849 | "_isFastLaunch": false, 850 | "category": "Accelerated computing", 851 | "gpuNum": 8, 852 | "hideHardwareSpecs": false, 853 | "memoryGiB": 768, 854 | "name": "ml.g5.48xlarge", 855 | "vcpuNum": 192 856 | }, 857 | { 858 | "_defaultOrder": 55, 859 | "_isFastLaunch": false, 860 | "category": "Accelerated computing", 861 | "gpuNum": 8, 862 | "hideHardwareSpecs": false, 863 | "memoryGiB": 1152, 864 | "name": "ml.p4d.24xlarge", 865 | "vcpuNum": 96 866 | }, 867 | { 868 | "_defaultOrder": 56, 869 | "_isFastLaunch": false, 870 | "category": "Accelerated computing", 871 | "gpuNum": 8, 872 | "hideHardwareSpecs": false, 873 | "memoryGiB": 1152, 874 | "name": "ml.p4de.24xlarge", 875 | "vcpuNum": 96 876 | }, 877 | { 878 | "_defaultOrder": 57, 879 | "_isFastLaunch": false, 880 | "category": "Accelerated computing", 881 | "gpuNum": 0, 882 | "hideHardwareSpecs": false, 883 | "memoryGiB": 32, 884 | "name": "ml.trn1.2xlarge", 885 | "vcpuNum": 8 886 | }, 887 | { 888 | "_defaultOrder": 58, 889 | "_isFastLaunch": false, 890 | "category": "Accelerated computing", 891 | "gpuNum": 0, 892 | "hideHardwareSpecs": false, 893 | "memoryGiB": 512, 894 | "name": "ml.trn1.32xlarge", 895 | "vcpuNum": 128 896 | }, 897 | { 898 | "_defaultOrder": 59, 899 | "_isFastLaunch": false, 900 | "category": "Accelerated computing", 901 | "gpuNum": 0, 902 | "hideHardwareSpecs": false, 903 | "memoryGiB": 512, 904 | "name": "ml.trn1n.32xlarge", 905 | "vcpuNum": 128 906 | } 907 | ], 908 | "instance_type": "ml.t3.medium", 909 | "kernelspec": { 910 | "display_name": "conda_python3", 911 | "language": "python", 912 | "name": "conda_python3" 913 | }, 914 | "language_info": { 915 | "codemirror_mode": { 916 | "name": "ipython", 917 | "version": 3 918 | }, 919 | "file_extension": ".py", 920 | "mimetype": "text/x-python", 921 | "name": "python", 922 | "nbconvert_exporter": "python", 923 | "pygments_lexer": "ipython3", 924 | "version": "3.10.14" 925 | } 926 | }, 927 | "nbformat": 4, 928 | "nbformat_minor": 5 929 | } -------------------------------------------------------------------------------- /personalization-with-llms-TGI-version.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "359ef86573837a2a", 6 | "metadata": {}, 7 | "source": [ 8 | "# Let's Build Personalized Website using Agentic Workflows and Inferentia" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "331553a2", 14 | "metadata": {}, 15 | "source": [ 16 | "In this notebook, you will create a website using Generative AI. You will use a *Personalizer* agent to create custom text (Llama 3.1 8B) and an *Artist* agent to create custom images (Stable Diffusion XL). \n", 17 | "\n", 18 | "Note: Please confirm that you have an Amazon SageMaker Endpoint deployed for each of the models you will use in this notebook. " 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "95d29723-29ce-4057-9ea7-1c76033682fa", 24 | "metadata": {}, 25 | "source": [ 26 | "\"Schematic" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "id": "39b18ebf", 32 | "metadata": {}, 33 | "source": [ 34 | "The above figure shows the workflow steps using LLMs. At first, we start by selecting the example user profile. (Step-1) Then the profile is used to find the three applicable pain points from the references that we syntehthically created. The label and a short description of the painpoints to be used later. (Step-2) Using the full profile, painpoints and complete list of offerings, LLM find the most applicable three offerings and label them and advertise them briefly which will be used by the downstream work.(Step-3) Using these definitions, LLM describes the images and icons within a cohesive manner following the design guidelines provided in the system prompt. (Step-4) Now, we have all the content to completely and detailly describe the website design. Based on descriptions, (Step-5) images are generated and stores and (Step-6) the template of the website assets updated. At this stage you can download all the files in the folder and see the resulting wbesite.\n", 35 | "\n", 36 | "To see the amendments and possibilities within this framework, we suggest your read our blog post ['Reinvent personalization with generative AI on Amazon Bedrock using task decomposition for agentic workflows'](https://aws.amazon.com/blogs/machine-learning/reinvent-personalization-with-generative-ai-on-amazon-bedrock-using-task-decomposition-for-agentic-workflows/)\n" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "id": "caa8ba93", 42 | "metadata": {}, 43 | "source": [ 44 | "## I) Preparations" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "id": "3bd55ef5", 51 | "metadata": {}, 52 | "outputs": [], 53 | "source": [ 54 | "#!pip3 install boto3 numpy matplotlib shutil PIL re -q\n", 55 | "#!pip3 install ipywidgets -q" 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "id": "dcac26309b11cf46", 61 | "metadata": {}, 62 | "source": [ 63 | "### a) Import Libraries" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "id": "c1208d2cf05499b3", 70 | "metadata": { 71 | "ExecuteTime": { 72 | "end_time": "2024-01-22T22:50:21.868106Z", 73 | "start_time": "2024-01-22T22:50:21.806873Z" 74 | }, 75 | "tags": [] 76 | }, 77 | "outputs": [], 78 | "source": [ 79 | "import warnings\n", 80 | "warnings.filterwarnings('ignore')\n", 81 | "\n", 82 | "import base64\n", 83 | "import boto3\n", 84 | "import io\n", 85 | "import os\n", 86 | "import json\n", 87 | "import re\n", 88 | "import importlib\n", 89 | "import shutil\n", 90 | "import re\n", 91 | "import numpy as np\n", 92 | "import matplotlib.pyplot as plt\n", 93 | "from ipywidgets import widgets\n", 94 | "from IPython.core.display import display, HTML\n", 95 | "from PIL import Image" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "id": "f7dfa7e8-8dca-4066-88a9-015823c84f12", 102 | "metadata": { 103 | "tags": [] 104 | }, 105 | "outputs": [], 106 | "source": [ 107 | "sm_client = boto3.client(\"sagemaker\")\n", 108 | "smr_client = boto3.client(\"sagemaker-runtime\")" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "id": "325db3d1-363c-4e21-b217-b587c58dd804", 114 | "metadata": {}, 115 | "source": [ 116 | "### b) Define Useful functions\n", 117 | "Let's define some functions that'll be used in the process of gathering the content for the website." 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": null, 123 | "id": "e670a8e0-a6e2-44cc-883c-77dd31eafb72", 124 | "metadata": { 125 | "tags": [] 126 | }, 127 | "outputs": [], 128 | "source": [ 129 | "# 'build_profile' explains the customer profile in natural language. \n", 130 | "def build_profile(UserProfile):\n", 131 | " profile = f\"Your customer is {UserProfile['Name']} located in {UserProfile['Location']}. They are in {UserProfile['Industry']} industry. Their mission statement: `{UserProfile['Mission']}.'\"\n", 132 | " return profile\n", 133 | "\n", 134 | "# 'get_labels_and_desc' is used to extract patterns for \"labels\" and \"description/ads\" for offerings and pain-points.\n", 135 | "def get_labels_and_desc(pattern, text): \n", 136 | " matches = re.findall(pattern, text)\n", 137 | " myList = [] #(label, description)\n", 138 | " for match in matches:\n", 139 | " title = match[0]\n", 140 | " description = match[1]\n", 141 | " myList.append((title,description))\n", 142 | " return myList\n", 143 | "\n", 144 | "\n", 145 | "# Display PIL images as grid\n", 146 | "def display_image(image=None,width=500,height=500):\n", 147 | " img = image.resize((width, height))\n", 148 | " display(img)\n", 149 | "\n", 150 | "# 'decode_base64_image' is a common function to print images from decoding base-64\n", 151 | "def decode_base64_image(image_string):\n", 152 | " base64_image = base64.b64decode(image_string)\n", 153 | " buffer = io.BytesIO(base64_image)\n", 154 | " return Image.open(buffer)" 155 | ] 156 | }, 157 | { 158 | "cell_type": "markdown", 159 | "id": "be33a6ed", 160 | "metadata": { 161 | "ExecuteTime": { 162 | "end_time": "2024-01-22T22:47:57.456102Z", 163 | "start_time": "2024-01-22T22:47:57.408222Z" 164 | } 165 | }, 166 | "source": [ 167 | "### c) Define variables with SageMaker Model endpoints" 168 | ] 169 | }, 170 | { 171 | "cell_type": "markdown", 172 | "id": "c04dfc84-5bf6-4335-977e-6f1f0a9f078a", 173 | "metadata": {}, 174 | "source": [ 175 | " Copy - Paste your endpoints below.\n", 176 | "\n", 177 | "You can find the created endpoints printed while deploying them in ./model folder. If you lost it, you can see all endpoints on `AWS Console` --> `Amazon SageMaker` --> `Endpoints`" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "id": "6aa5e8cd-4807-4187-b57f-559b7e65238d", 184 | "metadata": { 185 | "tags": [] 186 | }, 187 | "outputs": [], 188 | "source": [ 189 | "model_llama3p1_endpoint = 'Llama3-1-8B' # Your Llama3-1-8B endpoint\n", 190 | "model_stablediffV1_endpoint = 'Stable-Diffusion-XL' # Your Stable-Diffusion-XL endpoint" 191 | ] 192 | }, 193 | { 194 | "cell_type": "markdown", 195 | "id": "202f050a-b4d4-44c6-aa84-f559b35afd3e", 196 | "metadata": {}, 197 | "source": [ 198 | "#### Check the status of the SageMaker endpoints" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "id": "2602b106-85ed-486e-8d36-29d854baaf78", 205 | "metadata": { 206 | "scrolled": true, 207 | "tags": [] 208 | }, 209 | "outputs": [], 210 | "source": [ 211 | "resp = sm_client.describe_endpoint(EndpointName=model_llama3p1_endpoint)\n", 212 | "print(f\"Status for {model_llama3p1_endpoint}: {resp['EndpointStatus']}\")" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": null, 218 | "id": "19514fd2-eb57-49ca-9e4a-fd8ab8adee44", 219 | "metadata": { 220 | "tags": [] 221 | }, 222 | "outputs": [], 223 | "source": [ 224 | "resp = sm_client.describe_endpoint(EndpointName=model_stablediffV1_endpoint)\n", 225 | "print(f\"Status for {model_stablediffV1_endpoint}: {resp['EndpointStatus']}\")" 226 | ] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "id": "67196a08-02df-417b-91e5-1643fadc7136", 231 | "metadata": {}, 232 | "source": [ 233 | "### d) Setting the Example User Profiles\n", 234 | "Define a few sample profiles. These profiles define an Industry, a name for the company, location and a mission statement for the company." 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": null, 240 | "id": "09ff9bf6-2463-485a-9501-6904d14b6c6a", 241 | "metadata": { 242 | "tags": [] 243 | }, 244 | "outputs": [], 245 | "source": [ 246 | "Profiles = {\n", 247 | " 'Construction-Example': {\n", 248 | " 'Name': 'Example Corp Construction Inc',\n", 249 | " 'Industry': 'Construction',\n", 250 | " 'Location': 'New York City, NY',\n", 251 | " 'Mission': 'Building a sustainable future for New York'\n", 252 | " },\n", 253 | " 'Manufacturing-Example': {\n", 254 | " 'Name': 'Example Corp Manuf LLC',\n", 255 | " 'Industry': 'Manufacturing',\n", 256 | " 'Location': 'San Jose, CA',\n", 257 | " 'Mission': 'Building the next generation Electric Vehicles'\n", 258 | " },\n", 259 | " 'Mining-Example': {\n", 260 | " 'Name': 'Example Corp Mining Inc',\n", 261 | " 'Industry': 'Mining',\n", 262 | " 'Location': 'Bisbee, AZ',\n", 263 | " 'Mission': 'Extracting the value for America'\n", 264 | " }\n", 265 | "}" 266 | ] 267 | }, 268 | { 269 | "cell_type": "markdown", 270 | "id": "3345cd69", 271 | "metadata": {}, 272 | "source": [ 273 | "Creating the dropdown select widget" 274 | ] 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "id": "fdb083af", 280 | "metadata": { 281 | "tags": [] 282 | }, 283 | "outputs": [], 284 | "source": [ 285 | "dropdown = widgets.Dropdown(\n", 286 | " options=['Manufacturing', 'Construction', 'Mining'],\n", 287 | " value='Manufacturing',\n", 288 | " description='Select your example industry:',\n", 289 | " )" 290 | ] 291 | }, 292 | { 293 | "cell_type": "markdown", 294 | "id": "f17b9c83", 295 | "metadata": {}, 296 | "source": [ 297 | "##### Now, we are good to start with the workflow!" 298 | ] 299 | }, 300 | { 301 | "cell_type": "markdown", 302 | "id": "2112d766", 303 | "metadata": {}, 304 | "source": [ 305 | "## II) Personalized Content Workflow\n", 306 | "## Part-I: Knowing your customer" 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "id": "3b77eaa6-165b-4c86-ac04-9a32a46a962e", 312 | "metadata": {}, 313 | "source": [ 314 | "### Step-0) Select your customer profile and getting related material" 315 | ] 316 | }, 317 | { 318 | "cell_type": "code", 319 | "execution_count": null, 320 | "id": "aa35177c-81d3-44e3-a68c-a587995c2551", 321 | "metadata": { 322 | "tags": [] 323 | }, 324 | "outputs": [], 325 | "source": [ 326 | "display(dropdown)" 327 | ] 328 | }, 329 | { 330 | "cell_type": "markdown", 331 | "id": "0f6f7f32-d862-4687-abe2-2486ec44fc76", 332 | "metadata": {}, 333 | "source": [ 334 | "Read some pre-defined offerings for each Industry. In practice, this will be a document that has the offerings of your company." 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": null, 340 | "id": "a10ef5f1-df72-4df6-88af-e4bc59955c65", 341 | "metadata": { 342 | "tags": [] 343 | }, 344 | "outputs": [], 345 | "source": [ 346 | "with open(\"./references/offerings.json\", \"r\") as file:\n", 347 | " offerings = json.load(file)" 348 | ] 349 | }, 350 | { 351 | "cell_type": "code", 352 | "execution_count": null, 353 | "id": "5f8f72bf-12fe-4231-b44d-4f4edccc9ebf", 354 | "metadata": { 355 | "tags": [] 356 | }, 357 | "outputs": [], 358 | "source": [ 359 | "customer= Profiles[dropdown.value+'-Example']\n", 360 | "offering = re.sub(r'\\n#?', ' ', offerings[customer['Industry']])\n", 361 | "project = dropdown.value + \"_Website_Test\" # we will use this for the created website folder" 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": null, 367 | "id": "756949bb-4862-494b-b2b3-689dfc967ecc", 368 | "metadata": { 369 | "tags": [] 370 | }, 371 | "outputs": [], 372 | "source": [ 373 | "print(f\"Selected Customer:\\n{customer}\")" 374 | ] 375 | }, 376 | { 377 | "cell_type": "markdown", 378 | "id": "373ebf30-bbb3-4ac0-9b29-ced37cc10792", 379 | "metadata": {}, 380 | "source": [ 381 | "Natural Language description of customer profile" 382 | ] 383 | }, 384 | { 385 | "cell_type": "code", 386 | "execution_count": null, 387 | "id": "69555c15-b24c-402b-b454-f1e20140e721", 388 | "metadata": { 389 | "tags": [] 390 | }, 391 | "outputs": [], 392 | "source": [ 393 | "customer['Description'] = build_profile(customer)\n", 394 | "print(customer['Description'])" 395 | ] 396 | }, 397 | { 398 | "cell_type": "markdown", 399 | "id": "a6e7358b-dbc9-4f3b-b009-e6740289d0c3", 400 | "metadata": {}, 401 | "source": [ 402 | "Read some pre-defined testimonials for each Industry." 403 | ] 404 | }, 405 | { 406 | "cell_type": "code", 407 | "execution_count": null, 408 | "id": "c6aa45ff-017c-4723-ba42-da9b0bda9886", 409 | "metadata": { 410 | "tags": [] 411 | }, 412 | "outputs": [], 413 | "source": [ 414 | "with open('./references/Testimonials.json', 'r') as file:\n", 415 | " testimonials = json.load(file)" 416 | ] 417 | }, 418 | { 419 | "cell_type": "markdown", 420 | "id": "350661cc-f978-4b99-8bc0-6beb3fb2716e", 421 | "metadata": {}, 422 | "source": [ 423 | "### STEP-1) Getting the painpoints of your customer's industry\n", 424 | "We now read a file corresponding to the pain-points and challenges corresponding to the industry you have chosen above. In a real use case, you might have a collection of documents with these details and you can leverage RAG to get a blurb of challenges that are relevant for your company.\n", 425 | "\n", 426 | "In this scenario, we just read the entire file that has multiple challenges." 427 | ] 428 | }, 429 | { 430 | "cell_type": "code", 431 | "execution_count": null, 432 | "id": "bdab9a97-a2e1-44c6-a098-e7d70b367b8c", 433 | "metadata": { 434 | "tags": [] 435 | }, 436 | "outputs": [], 437 | "source": [ 438 | "query = f\"{customer['Description']}\\nList the industry pain-points and challenges\"\n", 439 | "print(f\"Here is your customer:\\n{query}\")" 440 | ] 441 | }, 442 | { 443 | "cell_type": "markdown", 444 | "id": "dc1924c2", 445 | "metadata": {}, 446 | "source": [ 447 | "Select a file corresponding to the customer profile you selected in the above step. \n", 448 | "\n", 449 | "`Manufacturing` --> `references/Manufacturing-Industry-DummyArticle-01.txt`\n", 450 | "\n", 451 | "`Mining` --> `references/Mining-Industry-DummyArticle-01.txt`\n", 452 | "\n", 453 | "`Construction` --> `references/Construction-Industry-DummyArticle-01.txt`" 454 | ] 455 | }, 456 | { 457 | "cell_type": "code", 458 | "execution_count": null, 459 | "id": "3fd820d5-2c23-4267-89b6-c704e282c235", 460 | "metadata": { 461 | "scrolled": true, 462 | "tags": [] 463 | }, 464 | "outputs": [], 465 | "source": [ 466 | "with open('references/Mining-Industry-DummyArticle-01.txt', 'r') as file:\n", 467 | " contexts_painpoints = file.read()\n", 468 | "\n", 469 | "print(f\"These are the applicable pain-points/challenges:\\n{contexts_painpoints}\")" 470 | ] 471 | }, 472 | { 473 | "cell_type": "markdown", 474 | "id": "c7d5070d-2ccf-47eb-90ba-dd2a78815012", 475 | "metadata": {}, 476 | "source": [ 477 | "We now create a prompt with the 'painpoints' from above as context. Please ensure that the number of tokens in the context (and prompt) <= 512 + sequence length with which the llama 3.1 8B model was compiled for. Else, you'll run into an error." 478 | ] 479 | }, 480 | { 481 | "cell_type": "code", 482 | "execution_count": null, 483 | "id": "4e42c5c0-44b0-472f-b955-36ad6c08f0f7", 484 | "metadata": { 485 | "tags": [] 486 | }, 487 | "outputs": [], 488 | "source": [ 489 | "prompt = f\"\"\"\n", 490 | "<|begin_of_text|>\n", 491 | "<|start_header_id|>system<|end_header_id|>\n", 492 | "You are an experienced business consultant.\n", 493 | "<|eot_id|><|start_header_id|>user<|end_header_id|>\n", 494 | "*** Research Document ***\n", 495 | "{contexts_painpoints}\n", 496 | "*** End of Research Document ***\n", 497 | "\n", 498 | "\n", 499 | "Question: {customer['Description']} Based on the above research, list top-3 challenges and explain we understand their challanges. Do not use any company name.\n", 500 | "Provide your response in bullet points without any preamble (e.g. \u2022 a pain-point: one sentence description, \u2022 pain-point: one sentence description, etc.). \n", 501 | "\n", 502 | "\"\"\"\n", 503 | "params = {\"max_new_tokens\": 512, \"do_sample\": False}" 504 | ] 505 | }, 506 | { 507 | "cell_type": "markdown", 508 | "id": "a8b7874c-e6b1-48b0-94ef-e1bec4e73859", 509 | "metadata": {}, 510 | "source": [ 511 | "Invoke the LLM" 512 | ] 513 | }, 514 | { 515 | "cell_type": "code", 516 | "execution_count": null, 517 | "id": "b32bb5c2-e171-49b4-bd7d-75b1f9bdc303", 518 | "metadata": { 519 | "tags": [] 520 | }, 521 | "outputs": [], 522 | "source": [ 523 | "%%time\n", 524 | "response_model= smr_client.invoke_endpoint(\n", 525 | " EndpointName=model_llama3p1_endpoint,\n", 526 | " Body=json.dumps({\"inputs\": prompt, \"parameters\": params}),\n", 527 | " ContentType=\"application/json\",\n", 528 | ")\n", 529 | "response_painpoints = json.load(response_model['Body'])" 530 | ] 531 | }, 532 | { 533 | "cell_type": "markdown", 534 | "id": "e608dc44", 535 | "metadata": {}, 536 | "source": [ 537 | "Here we list the painpoints identified and described by the LLM" 538 | ] 539 | }, 540 | { 541 | "cell_type": "code", 542 | "execution_count": null, 543 | "id": "1a4e4021-7a94-4c3b-b84b-6a53a3eb97fc", 544 | "metadata": { 545 | "tags": [] 546 | }, 547 | "outputs": [], 548 | "source": [ 549 | "# Extracting the top_painpoints\n", 550 | "top_pain_points_text= response_painpoints[0]['generated_text'].split(prompt)[1].split('<|eot_id|>')[0]\n", 551 | "top_painpoints = get_labels_and_desc(pattern=r'\u2022\\s*(.*?):\\s*(.*?)\\.', text = top_pain_points_text)\n", 552 | "# Printing the top_painpoints\n", 553 | "print(\"Top-painpoints: \\n\")\n", 554 | "for i, (key, value) in enumerate(top_painpoints):\n", 555 | " print(f\"{i+1}) {key}: {value}\")" 556 | ] 557 | }, 558 | { 559 | "cell_type": "markdown", 560 | "id": "7c2349b1-cca8-4f1c-8e7f-227dccbec480", 561 | "metadata": {}, 562 | "source": [ 563 | "### STEP-2: Finding the personalized offerings using LLM\n", 564 | "\n", 565 | "We now use the pre-defined offerings as context to generate content corresponding to top offerings that will be advertised on the website." 566 | ] 567 | }, 568 | { 569 | "cell_type": "code", 570 | "execution_count": null, 571 | "id": "c9ee3040-42b2-462c-a161-9b3ec34449e9", 572 | "metadata": { 573 | "tags": [] 574 | }, 575 | "outputs": [], 576 | "source": [ 577 | "prompt = f\"\"\"\n", 578 | "<|begin_of_text|>\n", 579 | "<|start_header_id|>system<|end_header_id|>\n", 580 | "You are an experienced business consultant.\n", 581 | "<|eot_id|><|start_header_id|>user<|end_header_id|>\n", 582 | "*** Offerings Document ***\n", 583 | "{offering}\n", 584 | "*** Offerings Document ***\n", 585 | "\n", 586 | "\n", 587 | "Question: {customer['Description']} Their top-3 painpoints are {top_painpoints}.\n", 588 | "\n", 589 | "List and briefly advertise the top-3 offerings for {customer['Name']} based on the offerings document above.\n", 590 | "Provide your list in bullet points without any preamble (e.g. \u2022 an offering: short description, \u2022 an offering: short description, ...). \n", 591 | "<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n", 592 | "\n", 593 | "\"\"\"\n", 594 | "params = {\"max_new_tokens\": 384, \"do_sample\": False}" 595 | ] 596 | }, 597 | { 598 | "cell_type": "markdown", 599 | "id": "55ec34ce-9f78-46b4-bd69-5717b41f31db", 600 | "metadata": {}, 601 | "source": [ 602 | "Invoke the model." 603 | ] 604 | }, 605 | { 606 | "cell_type": "code", 607 | "execution_count": null, 608 | "id": "1dae77cc-1eaf-481c-803a-69462101102f", 609 | "metadata": { 610 | "tags": [] 611 | }, 612 | "outputs": [], 613 | "source": [ 614 | "%%time\n", 615 | "response_model = smr_client.invoke_endpoint(\n", 616 | " EndpointName=model_llama3p1_endpoint,\n", 617 | " Body=json.dumps({\"inputs\": prompt, \"parameters\": params}),\n", 618 | " ContentType=\"application/json\",\n", 619 | ")\n", 620 | "response_offerings = json.load(response_model['Body'])" 621 | ] 622 | }, 623 | { 624 | "cell_type": "code", 625 | "execution_count": null, 626 | "id": "c566a48a-f29a-43e9-8ba4-718dc62b029b", 627 | "metadata": { 628 | "tags": [] 629 | }, 630 | "outputs": [], 631 | "source": [ 632 | "# Extracting the top offerings\n", 633 | "top_offerings_text= response_offerings[0]['generated_text'].split(prompt)[1].split('<|eot_id|>')[0].replace('\\n',', ')\n", 634 | "top_offerings = get_labels_and_desc(pattern=r'\u2022\\s*(.*?):\\s*(.*?)\\.', text = top_offerings_text)\n", 635 | "# Printing the top_painpoints\n", 636 | "print(\"Top-offerings: \\n\")\n", 637 | "for i, (key, value) in enumerate(top_offerings):\n", 638 | " print(f\"{i+1}) {key}: {value}\")" 639 | ] 640 | }, 641 | { 642 | "cell_type": "markdown", 643 | "id": "64237857-24ba-4634-9aa8-791bd39dbd0c", 644 | "metadata": {}, 645 | "source": [ 646 | "### STEP-3: Art Design and Description\n", 647 | "\n", 648 | "We now create a prompt that is used to generate descriptions for images and icons that will be embedded in the website. Note that the prompt asks the model to generate the output in a structured format." 649 | ] 650 | }, 651 | { 652 | "cell_type": "code", 653 | "execution_count": null, 654 | "id": "40257a52-26da-4c8f-b178-85d335ff4006", 655 | "metadata": { 656 | "tags": [] 657 | }, 658 | "outputs": [], 659 | "source": [ 660 | "prompt = f\"\"\"\n", 661 | "<|begin_of_text|>\n", 662 | "<|start_header_id|>system<|end_header_id|>\n", 663 | "You are a UI/UX art designer personalizing visual website content such as hero image and icons tailored to customer profile, personalized offerings and pain-points. \n", 664 | "Your task is to describe a hero image and six icons. For the Hero Image, design an attention-grabbing image that relates to the customer's industry, location, and mission. For icons, design simple, memorable icons that visually represent the concepts.\n", 665 | "\n", 666 | "Customer Profile:\n", 667 | "- Industry: {customer['Industry']}\n", 668 | "- Location: {customer['Location']}\n", 669 | "- Company Motto/Mission: {customer['Mission']}\n", 670 | "\n", 671 | "For the Hero Image:\n", 672 | "- Describe a scene that represents the customer's industry and mission\n", 673 | "- Include elements that reflect the customer location\n", 674 | "- Mention 1-2 key visual elements\n", 675 | "\n", 676 | "For each icon:\n", 677 | "- Describe a simple, recognizable shape or symbol\n", 678 | "- Concisely describe the key visual element\n", 679 | "- Call our that this is an 'icon'\n", 680 | "\n", 681 | "Each icon should be distinct yet part of a cohesive set in style and color.\n", 682 | "\n", 683 | "<|eot_id|><|start_header_id|>user<|end_header_id|>\n", 684 | "\n", 685 | "Complete the below visual descriptions.\n", 686 | "\n", 687 | "** Hero Image[Description in 1-2 sentences]**: A spectacular image ...\n", 688 | "** {top_painpoints[0][0]} Icon [Description in one sentence]**: A simple icon...\n", 689 | "** {top_painpoints[1][0]} Icon [Description in one sentence]**: A simple icon...\n", 690 | "** {top_painpoints[2][0]} Icon [Description in one sentence]**: A simple icon...\n", 691 | "** {top_offerings[0][0]} Icon [Description in one sentence]**: A simple icon...\n", 692 | "** {top_offerings[1][0]} Icon [Description in one sentence]**: A simple icon...\n", 693 | "** {top_offerings[2][0]} Icon [Description in one sentence]**: A simple icon...\n", 694 | "\n", 695 | "Use the format above, without any preamble.\n", 696 | "\n", 697 | "<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n", 698 | "\"\"\"\n", 699 | "params = {\"max_new_tokens\": 512, \"do_sample\": False}" 700 | ] 701 | }, 702 | { 703 | "cell_type": "markdown", 704 | "id": "d7d69e13-bef5-4f98-b048-96233e97d049", 705 | "metadata": {}, 706 | "source": [ 707 | "Invoke the model." 708 | ] 709 | }, 710 | { 711 | "cell_type": "code", 712 | "execution_count": null, 713 | "id": "55844632-04bc-4ee7-b54a-2b8ca2bd4fba", 714 | "metadata": { 715 | "scrolled": true, 716 | "tags": [] 717 | }, 718 | "outputs": [], 719 | "source": [ 720 | "%%time\n", 721 | "response_model = smr_client.invoke_endpoint(\n", 722 | " EndpointName=model_llama3p1_endpoint,\n", 723 | " Body=json.dumps({\"inputs\": prompt, \"parameters\": params}),\n", 724 | " ContentType=\"application/json\",\n", 725 | ")\n", 726 | "response_art= json.load(response_model['Body'])" 727 | ] 728 | }, 729 | { 730 | "cell_type": "code", 731 | "execution_count": null, 732 | "id": "1952d8e4-ff5d-4909-9333-6e1ca754bfda", 733 | "metadata": { 734 | "tags": [] 735 | }, 736 | "outputs": [], 737 | "source": [ 738 | "# Creating the variable for the art descriptions that will help us to create a better prompt later\n", 739 | "\n", 740 | "art_descriptions = response_art[0]['generated_text'].split(prompt)[1].split('<|eot_id|>')[0].replace('\\n',', ').replace(', ,', '').replace('**,','**').split(\"**\")[1:]\n" 741 | ] 742 | }, 743 | { 744 | "cell_type": "code", 745 | "execution_count": null, 746 | "id": "9f67e10a-14f7-432b-8b98-4e6e295cb794", 747 | "metadata": { 748 | "tags": [] 749 | }, 750 | "outputs": [], 751 | "source": [ 752 | "final_art_descriptions = {}\n", 753 | "for i in range(0,int(len(art_descriptions)),2):\n", 754 | " label = art_descriptions[i].split(\":\")[0].strip()\n", 755 | " description = art_descriptions[i+1].split(\":\")[1].strip()\n", 756 | " final_art_descriptions.update({label:{'Description':description, 'FileName':label.replace(\" \",\"_\")+'.jpg'}})" 757 | ] 758 | }, 759 | { 760 | "cell_type": "code", 761 | "execution_count": null, 762 | "id": "9b67e1b9-efdf-4091-993a-6a69706e54fa", 763 | "metadata": { 764 | "tags": [] 765 | }, 766 | "outputs": [], 767 | "source": [ 768 | "print(f\"Here the json that provides all information regarding our arts:\\n {json.dumps(final_art_descriptions, indent=4)}\")" 769 | ] 770 | }, 771 | { 772 | "cell_type": "markdown", 773 | "id": "9ec42c7f-1edf-440d-b283-9b385bcd725a", 774 | "metadata": {}, 775 | "source": [ 776 | "### STEP-4: Completing the description of personalized website: Call to action, hero labels and more\n", 777 | "\n", 778 | "Use the LLM one final time to generate a catchy slogan and call-to-action." 779 | ] 780 | }, 781 | { 782 | "cell_type": "code", 783 | "execution_count": null, 784 | "id": "1a83b714-ec61-494f-b031-dfe0cdd8c3b7", 785 | "metadata": { 786 | "tags": [] 787 | }, 788 | "outputs": [], 789 | "source": [ 790 | "prompt = f\"\"\"\n", 791 | "<|begin_of_text|>\n", 792 | "<|start_header_id|>system<|end_header_id|>\n", 793 | "You are creating engaging website content for AnyCompany Consulting, which is a business consulting company. \n", 794 | "Your task is to generate four specific pieces of text based on the customer profile and offerings provided.\n", 795 | "\n", 796 | "Customer Profile:\n", 797 | "- Industry: {customer['Industry']}\n", 798 | "- Location: {customer['Location']}\n", 799 | "- Company Motto/Mission: {customer['Mission']}\n", 800 | "\n", 801 | "Hero image: {final_art_descriptions['Hero Image']['Description']}\n", 802 | "\n", 803 | "Industry painpoints:\n", 804 | "- {top_painpoints[0][0]}\n", 805 | "- {top_painpoints[1][0]}\n", 806 | "- {top_painpoints[2][0]}\n", 807 | "\n", 808 | "AnyCompany Consulting offerings:\n", 809 | "- {top_offerings[0][0]}\n", 810 | "- {top_offerings[1][0]}\n", 811 | "- {top_offerings[2][0]}\n", 812 | "\n", 813 | "<|eot_id|><|start_header_id|>user<|end_header_id|>\n", 814 | "\n", 815 | "Generate the following four pieces of text:\n", 816 | "1. Hero Label: A short, attention-grabbing phrase to work with AnyCompany Consulting (5-7 words)\n", 817 | "2. Hero Text: A brief explanation expanding on the label (15-20 words)\n", 818 | "3. Call-to-Action Button: A short, action-oriented phrase (3-5 words)\n", 819 | "4. Call-to-Action Explanation: A motivating statement to encourage engagement with AnyCompany Consulting (15-20 words)\n", 820 | "\n", 821 | "Use this exact format for your response:\n", 822 | "\n", 823 | "** Hero Label **\n", 824 | "** Hero Text **\n", 825 | "** Call-to-Action Button **\n", 826 | "** Call-to-Action Explanation **\n", 827 | "\n", 828 | "Ensure each piece of text relates to the customer's industry, pain points, and the consulting offerings. \n", 829 | "Focus on engaging the customer and encouraging them to work with AnyCompany Consulting.\n", 830 | "Provide your response using the exact format above, without any preamble.\n", 831 | "<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n", 832 | "\"\"\"\n", 833 | "params = {\"max_new_tokens\": 512, \"do_sample\": False}" 834 | ] 835 | }, 836 | { 837 | "cell_type": "markdown", 838 | "id": "fba14b7f-007c-4f36-91e8-e767b551b869", 839 | "metadata": {}, 840 | "source": [ 841 | "Invoke the model." 842 | ] 843 | }, 844 | { 845 | "cell_type": "code", 846 | "execution_count": null, 847 | "id": "69b43311-499e-49a2-bf62-c41838507144", 848 | "metadata": { 849 | "scrolled": true, 850 | "tags": [] 851 | }, 852 | "outputs": [], 853 | "source": [ 854 | "%%time\n", 855 | "response_model = smr_client.invoke_endpoint(\n", 856 | " EndpointName=model_llama3p1_endpoint,\n", 857 | " Body=json.dumps({\"inputs\": prompt, \"parameters\": params}),\n", 858 | " ContentType=\"application/json\",\n", 859 | ")\n", 860 | "response_text= json.load(response_model['Body'])" 861 | ] 862 | }, 863 | { 864 | "cell_type": "code", 865 | "execution_count": null, 866 | "id": "de4231db-184b-4a07-803e-ee9eb11a9ba2", 867 | "metadata": { 868 | "tags": [] 869 | }, 870 | "outputs": [], 871 | "source": [ 872 | "text_descriptions_lst = response_text[0]['generated_text'].split(prompt)[1].split('<|eot_id|>')[0]\\\n", 873 | " .replace('\\n',', ').replace(', ,', '').replace('**, ','**').split('**')\n", 874 | "text_descriptions_lst = [x for x in text_descriptions_lst if x is not '']\n", 875 | "text_descriptions = {\"HeroLabel\":text_descriptions_lst[0], \"HeroText\":text_descriptions_lst[1], \"CTALabel\":text_descriptions_lst[2] ,\"CTAText\":text_descriptions_lst[3]}" 876 | ] 877 | }, 878 | { 879 | "cell_type": "markdown", 880 | "id": "86f98db0", 881 | "metadata": {}, 882 | "source": [ 883 | "Here is the description of the website which will be used by the downstream LLMs" 884 | ] 885 | }, 886 | { 887 | "cell_type": "code", 888 | "execution_count": null, 889 | "id": "5008ce66-dd49-4e40-9e1b-4c735700e095", 890 | "metadata": { 891 | "tags": [] 892 | }, 893 | "outputs": [], 894 | "source": [ 895 | "print(f\"Here is the art and their descriptions:\\n {json.dumps(text_descriptions, indent=4)}\")" 896 | ] 897 | }, 898 | { 899 | "cell_type": "markdown", 900 | "id": "19d7eaa5-3534-4b0e-9dfc-1683a5783a2b", 901 | "metadata": {}, 902 | "source": [ 903 | "### STEP-5: Image Creation based on Descriptions" 904 | ] 905 | }, 906 | { 907 | "cell_type": "markdown", 908 | "id": "f2f5cb25-c691-457c-be07-532579a75599", 909 | "metadata": {}, 910 | "source": [ 911 | "We now create images and icons for the website using Stable Diffusion. The descriptions that were generated in the previous step are used as prompts to the Stable Diffusion model. We successively call the APIs and then save the files." 912 | ] 913 | }, 914 | { 915 | "cell_type": "code", 916 | "execution_count": null, 917 | "id": "7f453a0f-74d0-4e61-8e11-c25e5150f168", 918 | "metadata": { 919 | "tags": [] 920 | }, 921 | "outputs": [], 922 | "source": [ 923 | "%%time\n", 924 | "# Hint!: You can optimize this process by changing the endpoints for low resolution icons and high resolution images\n", 925 | "from sagemaker.huggingface.model import HuggingFacePredictor\n", 926 | "predictor_SDv1 = HuggingFacePredictor(model_stablediffV1_endpoint)\n", 927 | "\n", 928 | "images = []\n", 929 | "image_files = []\n", 930 | "for art, content in final_art_descriptions.items():\n", 931 | " if 'Icon' in art:\n", 932 | " inf_steps = 30\n", 933 | " else:\n", 934 | " inf_steps = 50\n", 935 | "\n", 936 | " params = {\n", 937 | " \"num_inference_steps\" : inf_steps,\n", 938 | " \"negative_prompt\" : \"disfigured, ugly, deformed, unprofessional\"\n", 939 | " }\n", 940 | " \n", 941 | " prompt = content['Description']\n", 942 | " response = predictor_SDv1.predict(data={\"inputs\": prompt,\"parameters\":params})\n", 943 | "\n", 944 | " image = decode_base64_image(response[\"generated_images\"][0])\n", 945 | " image_files.append(content['FileName'])\n", 946 | "\n", 947 | " # Save the image\n", 948 | " image.save(f\"{content['FileName']}\")\n", 949 | " images.append(np.array(image))" 950 | ] 951 | }, 952 | { 953 | "cell_type": "code", 954 | "execution_count": null, 955 | "id": "ae17de99-ea8c-4c87-8dfb-ead45b5ef69d", 956 | "metadata": { 957 | "tags": [] 958 | }, 959 | "outputs": [], 960 | "source": [ 961 | "print(\"Number of visual assets created: {}\".format(len(image_files)))" 962 | ] 963 | }, 964 | { 965 | "cell_type": "code", 966 | "execution_count": null, 967 | "id": "4843ea20-a727-47a6-ae04-8c1f95a47f38", 968 | "metadata": { 969 | "tags": [] 970 | }, 971 | "outputs": [], 972 | "source": [ 973 | "#Here we copy our 'company logo' next to our visual files assets\n", 974 | "shutil.copy(\"./references/anycompany_logo.jpg\", \"./anycompany_logo.jpg\")" 975 | ] 976 | }, 977 | { 978 | "cell_type": "markdown", 979 | "id": "d78a5af5-34f4-4f3c-bc87-bf567ed2c9bf", 980 | "metadata": {}, 981 | "source": [ 982 | "Let's plot the images generated" 983 | ] 984 | }, 985 | { 986 | "cell_type": "code", 987 | "execution_count": null, 988 | "id": "d30cdd8f-a310-44a8-9816-d9cbd58d60b1", 989 | "metadata": { 990 | "scrolled": true, 991 | "tags": [] 992 | }, 993 | "outputs": [], 994 | "source": [ 995 | "# Plot the images\n", 996 | "fig, axs = plt.subplots(1, len(images), figsize=(30, 20))\n", 997 | "\n", 998 | "for i, (image, ax, filename) in enumerate(zip(images, axs, image_files)):\n", 999 | " ax.imshow(image)\n", 1000 | " ax.set_title(filename, fontsize=16)\n", 1001 | " ax.axis('off')\n", 1002 | "\n", 1003 | "plt.tight_layout()\n", 1004 | "plt.show()" 1005 | ] 1006 | }, 1007 | { 1008 | "cell_type": "markdown", 1009 | "id": "db50077f-3e5b-41f8-90a9-e60e2f46d3c4", 1010 | "metadata": {}, 1011 | "source": [ 1012 | "### STEP-6: Generating the website html (Updating the template)" 1013 | ] 1014 | }, 1015 | { 1016 | "cell_type": "markdown", 1017 | "id": "1e49c09f-47da-4b48-a251-55963da574ec", 1018 | "metadata": {}, 1019 | "source": [ 1020 | "The html file combines the images and text generated above to create the website. You can also consider using a code generation model to generate the html file. For the purpose of this session, we use an existing html template." 1021 | ] 1022 | }, 1023 | { 1024 | "cell_type": "code", 1025 | "execution_count": null, 1026 | "id": "c12b144c-413e-45e2-b06c-49d686d42b08", 1027 | "metadata": { 1028 | "tags": [] 1029 | }, 1030 | "outputs": [], 1031 | "source": [ 1032 | "\n", 1033 | "CSS_section = open('./references/CSS.txt', 'r').read()\n", 1034 | "CSS_section = CSS_section.replace(\"hero-image.jpg\", final_art_descriptions['Hero Image']['FileName'])\n", 1035 | "JS_section = open('./references/JS.txt', 'r').read()\n" 1036 | ] 1037 | }, 1038 | { 1039 | "cell_type": "markdown", 1040 | "id": "b6877c34", 1041 | "metadata": {}, 1042 | "source": [ 1043 | "Here, we parametrized our template and utilized a direct injection of LLM generated content into our template. However, you can also use LLMs at this stage to even change the template itself. In our referenced blog post, we used LLMs to build the website without using template but only guidelines.\n" 1044 | ] 1045 | }, 1046 | { 1047 | "cell_type": "code", 1048 | "execution_count": null, 1049 | "id": "184df90f", 1050 | "metadata": { 1051 | "tags": [] 1052 | }, 1053 | "outputs": [], 1054 | "source": [ 1055 | "# Parametrized website template\n", 1056 | "full_html = f\"\"\"\n", 1057 | "\n", 1058 | "\n", 1059 | "\n", 1060 | " \n", 1061 | " \n", 1062 | " AnyCompany Consulting Personalized Page\n", 1063 | " \n", 1066 | "\n", 1067 | "\n", 1068 | "
\n", 1069 | "
\n", 1070 | " \"AnyCompany\n", 1071 | "
\n", 1072 | " \n", 1082 | "
\n", 1083 | "
\n", 1084 | "
\n", 1085 | "

{text_descriptions['HeroLabel']}

\n", 1086 | "

{text_descriptions['HeroText']}

\n", 1087 | "
\n", 1088 | "
\n", 1089 | "

Our Tailored Solutions for Your {customer['Industry']} Needs

\n", 1090 | "
\n", 1091 | "
\n", 1092 | " \"{top_offerings[0][0]}\"\n", 1093 | "

{top_offerings[0][0]}

\n", 1094 | "

{top_offerings[0][1]}

\n", 1095 | "
\n", 1096 | "
\n", 1097 | " \"{top_offerings[1][0]}\"\n", 1098 | "

{top_offerings[1][0]}

\n", 1099 | "

{top_offerings[1][1]}

\n", 1100 | "
\n", 1101 | "
\n", 1102 | " \"{top_offerings[2][0]}\"\n", 1103 | "

{top_offerings[2][0]}

\n", 1104 | "

{top_offerings[2][1]}

\n", 1105 | "
\n", 1106 | "
\n", 1107 | "
\n", 1108 | "
\n", 1109 | "

Addressing Your {customer['Industry']} Challenges

\n", 1110 | "
\n", 1111 | "
\n", 1112 | " \"{top_painpoints[0][0]}\"\n", 1113 | "

{top_painpoints[0][0]}

\n", 1114 | "

{top_painpoints[0][1]}

\n", 1115 | "
\n", 1116 | "
\n", 1117 | " \"{top_painpoints[1][0]}\"\n", 1118 | "

{top_painpoints[1][0]}

\n", 1119 | "

{top_painpoints[1][1]}

\n", 1120 | "
\n", 1121 | "
\n", 1122 | " \"{top_painpoints[2][0]}\"\n", 1123 | "

{top_painpoints[2][0]}

\n", 1124 | "

{top_painpoints[2][1]}

\n", 1125 | "
\n", 1126 | "
\n", 1127 | "
\n", 1128 | "
\n", 1129 | "

What Our Clients Say

\n", 1130 | "
\n", 1131 | "
\n", 1132 | "

{testimonials['testimonials'][0]['text']}

\n", 1133 | "

- {testimonials['testimonials'][0]['author']}, {testimonials['testimonials'][0]['position']} from {testimonials['testimonials'][0]['company']}

\n", 1134 | "
\n", 1135 | "
\n", 1136 | "

{testimonials['testimonials'][1]['text']}

\n", 1137 | "

- {testimonials['testimonials'][1]['author']}, {testimonials['testimonials'][1]['position']} from {testimonials['testimonials'][1]['company']}

\n", 1138 | "
\n", 1139 | "
\n", 1140 | "

{testimonials['testimonials'][2]['text']}

\n", 1141 | "

- {testimonials['testimonials'][2]['author']}, {testimonials['testimonials'][2]['position']} from {testimonials['testimonials'][2]['company']}

\n", 1142 | "
\n", 1143 | "
\n", 1144 | "
\n", 1145 | "
\n", 1146 | "

{text_descriptions['CTALabel']}

\n", 1147 | "

{text_descriptions['CTAText']}

\n", 1148 | " Get Started\n", 1149 | "
\n", 1150 | "
\n", 1151 | " \n", 1157 | " \n", 1160 | "\n", 1161 | "\n", 1162 | "\"\"\"" 1163 | ] 1164 | }, 1165 | { 1166 | "cell_type": "markdown", 1167 | "id": "1d3130d5-c579-449c-873f-4d96c37bb2ef", 1168 | "metadata": {}, 1169 | "source": [ 1170 | "### STEP-FINAL: Putting the assets into a single folder" 1171 | ] 1172 | }, 1173 | { 1174 | "cell_type": "markdown", 1175 | "id": "5907b15d-1d9a-4ab9-8fa7-f27947c4b525", 1176 | "metadata": {}, 1177 | "source": [ 1178 | "Create the folder for the project" 1179 | ] 1180 | }, 1181 | { 1182 | "cell_type": "code", 1183 | "execution_count": null, 1184 | "id": "45657a3b-ac82-45de-8b82-8f755d255ed2", 1185 | "metadata": { 1186 | "tags": [] 1187 | }, 1188 | "outputs": [], 1189 | "source": [ 1190 | "try:\n", 1191 | " os.mkdir(project)\n", 1192 | " print(f\"Project Folder: {project}\" + '_reInvent')\n", 1193 | "except Exception as e:\n", 1194 | " print(f\"An error occurred: {e}\")" 1195 | ] 1196 | }, 1197 | { 1198 | "cell_type": "code", 1199 | "execution_count": null, 1200 | "id": "00768801-d471-4b85-b089-2b62a7afdcdd", 1201 | "metadata": { 1202 | "tags": [] 1203 | }, 1204 | "outputs": [], 1205 | "source": [ 1206 | "with open('main.html', 'w', encoding='utf-8') as file:\n", 1207 | " file.write(full_html)" 1208 | ] 1209 | }, 1210 | { 1211 | "cell_type": "code", 1212 | "execution_count": null, 1213 | "id": "5168e46a-a580-4c91-8fa5-24e7103e1313", 1214 | "metadata": { 1215 | "tags": [] 1216 | }, 1217 | "outputs": [], 1218 | "source": [ 1219 | "project_files = image_files.copy()\n", 1220 | "project_files.append('main.html')\n", 1221 | "project_files.append('anycompany_logo.jpg')" 1222 | ] 1223 | }, 1224 | { 1225 | "cell_type": "markdown", 1226 | "id": "7d5dbe13-75d7-4af9-8934-aa5809c7f2f5", 1227 | "metadata": {}, 1228 | "source": [ 1229 | "Copy the generated files and the html file to the project folder." 1230 | ] 1231 | }, 1232 | { 1233 | "cell_type": "code", 1234 | "execution_count": null, 1235 | "id": "48a7dc3f-ce9d-45ac-a06d-9f4e02bbe868", 1236 | "metadata": { 1237 | "scrolled": true, 1238 | "tags": [] 1239 | }, 1240 | "outputs": [], 1241 | "source": [ 1242 | "for file in project_files:\n", 1243 | " destination = project + \"/\" + file\n", 1244 | " shutil.move(file, destination)" 1245 | ] 1246 | }, 1247 | { 1248 | "cell_type": "code", 1249 | "execution_count": null, 1250 | "id": "be2e8e6d-8906-4f95-93a5-3ca80b545f87", 1251 | "metadata": { 1252 | "tags": [] 1253 | }, 1254 | "outputs": [], 1255 | "source": [ 1256 | "shutil.make_archive(project, 'zip', project)" 1257 | ] 1258 | }, 1259 | { 1260 | "cell_type": "markdown", 1261 | "id": "b9227d45-ed4c-422a-a1df-e1f6f589489a", 1262 | "metadata": {}, 1263 | "source": [ 1264 | "### !! You can now download the folder (zip file) and view the html in a browser. You have successfully generated a website using Generative AI !!" 1265 | ] 1266 | } 1267 | ], 1268 | "metadata": { 1269 | "availableInstances": [ 1270 | { 1271 | "_defaultOrder": 0, 1272 | "_isFastLaunch": true, 1273 | "category": "General purpose", 1274 | "gpuNum": 0, 1275 | "hideHardwareSpecs": false, 1276 | "memoryGiB": 4, 1277 | "name": "ml.t3.medium", 1278 | "vcpuNum": 2 1279 | }, 1280 | { 1281 | "_defaultOrder": 1, 1282 | "_isFastLaunch": false, 1283 | "category": "General purpose", 1284 | "gpuNum": 0, 1285 | "hideHardwareSpecs": false, 1286 | "memoryGiB": 8, 1287 | "name": "ml.t3.large", 1288 | "vcpuNum": 2 1289 | }, 1290 | { 1291 | "_defaultOrder": 2, 1292 | "_isFastLaunch": false, 1293 | "category": "General purpose", 1294 | "gpuNum": 0, 1295 | "hideHardwareSpecs": false, 1296 | "memoryGiB": 16, 1297 | "name": "ml.t3.xlarge", 1298 | "vcpuNum": 4 1299 | }, 1300 | { 1301 | "_defaultOrder": 3, 1302 | "_isFastLaunch": false, 1303 | "category": "General purpose", 1304 | "gpuNum": 0, 1305 | "hideHardwareSpecs": false, 1306 | "memoryGiB": 32, 1307 | "name": "ml.t3.2xlarge", 1308 | "vcpuNum": 8 1309 | }, 1310 | { 1311 | "_defaultOrder": 4, 1312 | "_isFastLaunch": true, 1313 | "category": "General purpose", 1314 | "gpuNum": 0, 1315 | "hideHardwareSpecs": false, 1316 | "memoryGiB": 8, 1317 | "name": "ml.m5.large", 1318 | "vcpuNum": 2 1319 | }, 1320 | { 1321 | "_defaultOrder": 5, 1322 | "_isFastLaunch": false, 1323 | "category": "General purpose", 1324 | "gpuNum": 0, 1325 | "hideHardwareSpecs": false, 1326 | "memoryGiB": 16, 1327 | "name": "ml.m5.xlarge", 1328 | "vcpuNum": 4 1329 | }, 1330 | { 1331 | "_defaultOrder": 6, 1332 | "_isFastLaunch": false, 1333 | "category": "General purpose", 1334 | "gpuNum": 0, 1335 | "hideHardwareSpecs": false, 1336 | "memoryGiB": 32, 1337 | "name": "ml.m5.2xlarge", 1338 | "vcpuNum": 8 1339 | }, 1340 | { 1341 | "_defaultOrder": 7, 1342 | "_isFastLaunch": false, 1343 | "category": "General purpose", 1344 | "gpuNum": 0, 1345 | "hideHardwareSpecs": false, 1346 | "memoryGiB": 64, 1347 | "name": "ml.m5.4xlarge", 1348 | "vcpuNum": 16 1349 | }, 1350 | { 1351 | "_defaultOrder": 8, 1352 | "_isFastLaunch": false, 1353 | "category": "General purpose", 1354 | "gpuNum": 0, 1355 | "hideHardwareSpecs": false, 1356 | "memoryGiB": 128, 1357 | "name": "ml.m5.8xlarge", 1358 | "vcpuNum": 32 1359 | }, 1360 | { 1361 | "_defaultOrder": 9, 1362 | "_isFastLaunch": false, 1363 | "category": "General purpose", 1364 | "gpuNum": 0, 1365 | "hideHardwareSpecs": false, 1366 | "memoryGiB": 192, 1367 | "name": "ml.m5.12xlarge", 1368 | "vcpuNum": 48 1369 | }, 1370 | { 1371 | "_defaultOrder": 10, 1372 | "_isFastLaunch": false, 1373 | "category": "General purpose", 1374 | "gpuNum": 0, 1375 | "hideHardwareSpecs": false, 1376 | "memoryGiB": 256, 1377 | "name": "ml.m5.16xlarge", 1378 | "vcpuNum": 64 1379 | }, 1380 | { 1381 | "_defaultOrder": 11, 1382 | "_isFastLaunch": false, 1383 | "category": "General purpose", 1384 | "gpuNum": 0, 1385 | "hideHardwareSpecs": false, 1386 | "memoryGiB": 384, 1387 | "name": "ml.m5.24xlarge", 1388 | "vcpuNum": 96 1389 | }, 1390 | { 1391 | "_defaultOrder": 12, 1392 | "_isFastLaunch": false, 1393 | "category": "General purpose", 1394 | "gpuNum": 0, 1395 | "hideHardwareSpecs": false, 1396 | "memoryGiB": 8, 1397 | "name": "ml.m5d.large", 1398 | "vcpuNum": 2 1399 | }, 1400 | { 1401 | "_defaultOrder": 13, 1402 | "_isFastLaunch": false, 1403 | "category": "General purpose", 1404 | "gpuNum": 0, 1405 | "hideHardwareSpecs": false, 1406 | "memoryGiB": 16, 1407 | "name": "ml.m5d.xlarge", 1408 | "vcpuNum": 4 1409 | }, 1410 | { 1411 | "_defaultOrder": 14, 1412 | "_isFastLaunch": false, 1413 | "category": "General purpose", 1414 | "gpuNum": 0, 1415 | "hideHardwareSpecs": false, 1416 | "memoryGiB": 32, 1417 | "name": "ml.m5d.2xlarge", 1418 | "vcpuNum": 8 1419 | }, 1420 | { 1421 | "_defaultOrder": 15, 1422 | "_isFastLaunch": false, 1423 | "category": "General purpose", 1424 | "gpuNum": 0, 1425 | "hideHardwareSpecs": false, 1426 | "memoryGiB": 64, 1427 | "name": "ml.m5d.4xlarge", 1428 | "vcpuNum": 16 1429 | }, 1430 | { 1431 | "_defaultOrder": 16, 1432 | "_isFastLaunch": false, 1433 | "category": "General purpose", 1434 | "gpuNum": 0, 1435 | "hideHardwareSpecs": false, 1436 | "memoryGiB": 128, 1437 | "name": "ml.m5d.8xlarge", 1438 | "vcpuNum": 32 1439 | }, 1440 | { 1441 | "_defaultOrder": 17, 1442 | "_isFastLaunch": false, 1443 | "category": "General purpose", 1444 | "gpuNum": 0, 1445 | "hideHardwareSpecs": false, 1446 | "memoryGiB": 192, 1447 | "name": "ml.m5d.12xlarge", 1448 | "vcpuNum": 48 1449 | }, 1450 | { 1451 | "_defaultOrder": 18, 1452 | "_isFastLaunch": false, 1453 | "category": "General purpose", 1454 | "gpuNum": 0, 1455 | "hideHardwareSpecs": false, 1456 | "memoryGiB": 256, 1457 | "name": "ml.m5d.16xlarge", 1458 | "vcpuNum": 64 1459 | }, 1460 | { 1461 | "_defaultOrder": 19, 1462 | "_isFastLaunch": false, 1463 | "category": "General purpose", 1464 | "gpuNum": 0, 1465 | "hideHardwareSpecs": false, 1466 | "memoryGiB": 384, 1467 | "name": "ml.m5d.24xlarge", 1468 | "vcpuNum": 96 1469 | }, 1470 | { 1471 | "_defaultOrder": 20, 1472 | "_isFastLaunch": false, 1473 | "category": "General purpose", 1474 | "gpuNum": 0, 1475 | "hideHardwareSpecs": true, 1476 | "memoryGiB": 0, 1477 | "name": "ml.geospatial.interactive", 1478 | "supportedImageNames": [ 1479 | "sagemaker-geospatial-v1-0" 1480 | ], 1481 | "vcpuNum": 0 1482 | }, 1483 | { 1484 | "_defaultOrder": 21, 1485 | "_isFastLaunch": true, 1486 | "category": "Compute optimized", 1487 | "gpuNum": 0, 1488 | "hideHardwareSpecs": false, 1489 | "memoryGiB": 4, 1490 | "name": "ml.c5.large", 1491 | "vcpuNum": 2 1492 | }, 1493 | { 1494 | "_defaultOrder": 22, 1495 | "_isFastLaunch": false, 1496 | "category": "Compute optimized", 1497 | "gpuNum": 0, 1498 | "hideHardwareSpecs": false, 1499 | "memoryGiB": 8, 1500 | "name": "ml.c5.xlarge", 1501 | "vcpuNum": 4 1502 | }, 1503 | { 1504 | "_defaultOrder": 23, 1505 | "_isFastLaunch": false, 1506 | "category": "Compute optimized", 1507 | "gpuNum": 0, 1508 | "hideHardwareSpecs": false, 1509 | "memoryGiB": 16, 1510 | "name": "ml.c5.2xlarge", 1511 | "vcpuNum": 8 1512 | }, 1513 | { 1514 | "_defaultOrder": 24, 1515 | "_isFastLaunch": false, 1516 | "category": "Compute optimized", 1517 | "gpuNum": 0, 1518 | "hideHardwareSpecs": false, 1519 | "memoryGiB": 32, 1520 | "name": "ml.c5.4xlarge", 1521 | "vcpuNum": 16 1522 | }, 1523 | { 1524 | "_defaultOrder": 25, 1525 | "_isFastLaunch": false, 1526 | "category": "Compute optimized", 1527 | "gpuNum": 0, 1528 | "hideHardwareSpecs": false, 1529 | "memoryGiB": 72, 1530 | "name": "ml.c5.9xlarge", 1531 | "vcpuNum": 36 1532 | }, 1533 | { 1534 | "_defaultOrder": 26, 1535 | "_isFastLaunch": false, 1536 | "category": "Compute optimized", 1537 | "gpuNum": 0, 1538 | "hideHardwareSpecs": false, 1539 | "memoryGiB": 96, 1540 | "name": "ml.c5.12xlarge", 1541 | "vcpuNum": 48 1542 | }, 1543 | { 1544 | "_defaultOrder": 27, 1545 | "_isFastLaunch": false, 1546 | "category": "Compute optimized", 1547 | "gpuNum": 0, 1548 | "hideHardwareSpecs": false, 1549 | "memoryGiB": 144, 1550 | "name": "ml.c5.18xlarge", 1551 | "vcpuNum": 72 1552 | }, 1553 | { 1554 | "_defaultOrder": 28, 1555 | "_isFastLaunch": false, 1556 | "category": "Compute optimized", 1557 | "gpuNum": 0, 1558 | "hideHardwareSpecs": false, 1559 | "memoryGiB": 192, 1560 | "name": "ml.c5.24xlarge", 1561 | "vcpuNum": 96 1562 | }, 1563 | { 1564 | "_defaultOrder": 29, 1565 | "_isFastLaunch": true, 1566 | "category": "Accelerated computing", 1567 | "gpuNum": 1, 1568 | "hideHardwareSpecs": false, 1569 | "memoryGiB": 16, 1570 | "name": "ml.g4dn.xlarge", 1571 | "vcpuNum": 4 1572 | }, 1573 | { 1574 | "_defaultOrder": 30, 1575 | "_isFastLaunch": false, 1576 | "category": "Accelerated computing", 1577 | "gpuNum": 1, 1578 | "hideHardwareSpecs": false, 1579 | "memoryGiB": 32, 1580 | "name": "ml.g4dn.2xlarge", 1581 | "vcpuNum": 8 1582 | }, 1583 | { 1584 | "_defaultOrder": 31, 1585 | "_isFastLaunch": false, 1586 | "category": "Accelerated computing", 1587 | "gpuNum": 1, 1588 | "hideHardwareSpecs": false, 1589 | "memoryGiB": 64, 1590 | "name": "ml.g4dn.4xlarge", 1591 | "vcpuNum": 16 1592 | }, 1593 | { 1594 | "_defaultOrder": 32, 1595 | "_isFastLaunch": false, 1596 | "category": "Accelerated computing", 1597 | "gpuNum": 1, 1598 | "hideHardwareSpecs": false, 1599 | "memoryGiB": 128, 1600 | "name": "ml.g4dn.8xlarge", 1601 | "vcpuNum": 32 1602 | }, 1603 | { 1604 | "_defaultOrder": 33, 1605 | "_isFastLaunch": false, 1606 | "category": "Accelerated computing", 1607 | "gpuNum": 4, 1608 | "hideHardwareSpecs": false, 1609 | "memoryGiB": 192, 1610 | "name": "ml.g4dn.12xlarge", 1611 | "vcpuNum": 48 1612 | }, 1613 | { 1614 | "_defaultOrder": 34, 1615 | "_isFastLaunch": false, 1616 | "category": "Accelerated computing", 1617 | "gpuNum": 1, 1618 | "hideHardwareSpecs": false, 1619 | "memoryGiB": 256, 1620 | "name": "ml.g4dn.16xlarge", 1621 | "vcpuNum": 64 1622 | }, 1623 | { 1624 | "_defaultOrder": 35, 1625 | "_isFastLaunch": false, 1626 | "category": "Accelerated computing", 1627 | "gpuNum": 1, 1628 | "hideHardwareSpecs": false, 1629 | "memoryGiB": 61, 1630 | "name": "ml.p3.2xlarge", 1631 | "vcpuNum": 8 1632 | }, 1633 | { 1634 | "_defaultOrder": 36, 1635 | "_isFastLaunch": false, 1636 | "category": "Accelerated computing", 1637 | "gpuNum": 4, 1638 | "hideHardwareSpecs": false, 1639 | "memoryGiB": 244, 1640 | "name": "ml.p3.8xlarge", 1641 | "vcpuNum": 32 1642 | }, 1643 | { 1644 | "_defaultOrder": 37, 1645 | "_isFastLaunch": false, 1646 | "category": "Accelerated computing", 1647 | "gpuNum": 8, 1648 | "hideHardwareSpecs": false, 1649 | "memoryGiB": 488, 1650 | "name": "ml.p3.16xlarge", 1651 | "vcpuNum": 64 1652 | }, 1653 | { 1654 | "_defaultOrder": 38, 1655 | "_isFastLaunch": false, 1656 | "category": "Accelerated computing", 1657 | "gpuNum": 8, 1658 | "hideHardwareSpecs": false, 1659 | "memoryGiB": 768, 1660 | "name": "ml.p3dn.24xlarge", 1661 | "vcpuNum": 96 1662 | }, 1663 | { 1664 | "_defaultOrder": 39, 1665 | "_isFastLaunch": false, 1666 | "category": "Memory Optimized", 1667 | "gpuNum": 0, 1668 | "hideHardwareSpecs": false, 1669 | "memoryGiB": 16, 1670 | "name": "ml.r5.large", 1671 | "vcpuNum": 2 1672 | }, 1673 | { 1674 | "_defaultOrder": 40, 1675 | "_isFastLaunch": false, 1676 | "category": "Memory Optimized", 1677 | "gpuNum": 0, 1678 | "hideHardwareSpecs": false, 1679 | "memoryGiB": 32, 1680 | "name": "ml.r5.xlarge", 1681 | "vcpuNum": 4 1682 | }, 1683 | { 1684 | "_defaultOrder": 41, 1685 | "_isFastLaunch": false, 1686 | "category": "Memory Optimized", 1687 | "gpuNum": 0, 1688 | "hideHardwareSpecs": false, 1689 | "memoryGiB": 64, 1690 | "name": "ml.r5.2xlarge", 1691 | "vcpuNum": 8 1692 | }, 1693 | { 1694 | "_defaultOrder": 42, 1695 | "_isFastLaunch": false, 1696 | "category": "Memory Optimized", 1697 | "gpuNum": 0, 1698 | "hideHardwareSpecs": false, 1699 | "memoryGiB": 128, 1700 | "name": "ml.r5.4xlarge", 1701 | "vcpuNum": 16 1702 | }, 1703 | { 1704 | "_defaultOrder": 43, 1705 | "_isFastLaunch": false, 1706 | "category": "Memory Optimized", 1707 | "gpuNum": 0, 1708 | "hideHardwareSpecs": false, 1709 | "memoryGiB": 256, 1710 | "name": "ml.r5.8xlarge", 1711 | "vcpuNum": 32 1712 | }, 1713 | { 1714 | "_defaultOrder": 44, 1715 | "_isFastLaunch": false, 1716 | "category": "Memory Optimized", 1717 | "gpuNum": 0, 1718 | "hideHardwareSpecs": false, 1719 | "memoryGiB": 384, 1720 | "name": "ml.r5.12xlarge", 1721 | "vcpuNum": 48 1722 | }, 1723 | { 1724 | "_defaultOrder": 45, 1725 | "_isFastLaunch": false, 1726 | "category": "Memory Optimized", 1727 | "gpuNum": 0, 1728 | "hideHardwareSpecs": false, 1729 | "memoryGiB": 512, 1730 | "name": "ml.r5.16xlarge", 1731 | "vcpuNum": 64 1732 | }, 1733 | { 1734 | "_defaultOrder": 46, 1735 | "_isFastLaunch": false, 1736 | "category": "Memory Optimized", 1737 | "gpuNum": 0, 1738 | "hideHardwareSpecs": false, 1739 | "memoryGiB": 768, 1740 | "name": "ml.r5.24xlarge", 1741 | "vcpuNum": 96 1742 | }, 1743 | { 1744 | "_defaultOrder": 47, 1745 | "_isFastLaunch": false, 1746 | "category": "Accelerated computing", 1747 | "gpuNum": 1, 1748 | "hideHardwareSpecs": false, 1749 | "memoryGiB": 16, 1750 | "name": "ml.g5.xlarge", 1751 | "vcpuNum": 4 1752 | }, 1753 | { 1754 | "_defaultOrder": 48, 1755 | "_isFastLaunch": false, 1756 | "category": "Accelerated computing", 1757 | "gpuNum": 1, 1758 | "hideHardwareSpecs": false, 1759 | "memoryGiB": 32, 1760 | "name": "ml.g5.2xlarge", 1761 | "vcpuNum": 8 1762 | }, 1763 | { 1764 | "_defaultOrder": 49, 1765 | "_isFastLaunch": false, 1766 | "category": "Accelerated computing", 1767 | "gpuNum": 1, 1768 | "hideHardwareSpecs": false, 1769 | "memoryGiB": 64, 1770 | "name": "ml.g5.4xlarge", 1771 | "vcpuNum": 16 1772 | }, 1773 | { 1774 | "_defaultOrder": 50, 1775 | "_isFastLaunch": false, 1776 | "category": "Accelerated computing", 1777 | "gpuNum": 1, 1778 | "hideHardwareSpecs": false, 1779 | "memoryGiB": 128, 1780 | "name": "ml.g5.8xlarge", 1781 | "vcpuNum": 32 1782 | }, 1783 | { 1784 | "_defaultOrder": 51, 1785 | "_isFastLaunch": false, 1786 | "category": "Accelerated computing", 1787 | "gpuNum": 1, 1788 | "hideHardwareSpecs": false, 1789 | "memoryGiB": 256, 1790 | "name": "ml.g5.16xlarge", 1791 | "vcpuNum": 64 1792 | }, 1793 | { 1794 | "_defaultOrder": 52, 1795 | "_isFastLaunch": false, 1796 | "category": "Accelerated computing", 1797 | "gpuNum": 4, 1798 | "hideHardwareSpecs": false, 1799 | "memoryGiB": 192, 1800 | "name": "ml.g5.12xlarge", 1801 | "vcpuNum": 48 1802 | }, 1803 | { 1804 | "_defaultOrder": 53, 1805 | "_isFastLaunch": false, 1806 | "category": "Accelerated computing", 1807 | "gpuNum": 4, 1808 | "hideHardwareSpecs": false, 1809 | "memoryGiB": 384, 1810 | "name": "ml.g5.24xlarge", 1811 | "vcpuNum": 96 1812 | }, 1813 | { 1814 | "_defaultOrder": 54, 1815 | "_isFastLaunch": false, 1816 | "category": "Accelerated computing", 1817 | "gpuNum": 8, 1818 | "hideHardwareSpecs": false, 1819 | "memoryGiB": 768, 1820 | "name": "ml.g5.48xlarge", 1821 | "vcpuNum": 192 1822 | }, 1823 | { 1824 | "_defaultOrder": 55, 1825 | "_isFastLaunch": false, 1826 | "category": "Accelerated computing", 1827 | "gpuNum": 8, 1828 | "hideHardwareSpecs": false, 1829 | "memoryGiB": 1152, 1830 | "name": "ml.p4d.24xlarge", 1831 | "vcpuNum": 96 1832 | }, 1833 | { 1834 | "_defaultOrder": 56, 1835 | "_isFastLaunch": false, 1836 | "category": "Accelerated computing", 1837 | "gpuNum": 8, 1838 | "hideHardwareSpecs": false, 1839 | "memoryGiB": 1152, 1840 | "name": "ml.p4de.24xlarge", 1841 | "vcpuNum": 96 1842 | }, 1843 | { 1844 | "_defaultOrder": 57, 1845 | "_isFastLaunch": false, 1846 | "category": "Accelerated computing", 1847 | "gpuNum": 0, 1848 | "hideHardwareSpecs": false, 1849 | "memoryGiB": 32, 1850 | "name": "ml.trn1.2xlarge", 1851 | "vcpuNum": 8 1852 | }, 1853 | { 1854 | "_defaultOrder": 58, 1855 | "_isFastLaunch": false, 1856 | "category": "Accelerated computing", 1857 | "gpuNum": 0, 1858 | "hideHardwareSpecs": false, 1859 | "memoryGiB": 512, 1860 | "name": "ml.trn1.32xlarge", 1861 | "vcpuNum": 128 1862 | }, 1863 | { 1864 | "_defaultOrder": 59, 1865 | "_isFastLaunch": false, 1866 | "category": "Accelerated computing", 1867 | "gpuNum": 0, 1868 | "hideHardwareSpecs": false, 1869 | "memoryGiB": 512, 1870 | "name": "ml.trn1n.32xlarge", 1871 | "vcpuNum": 128 1872 | } 1873 | ], 1874 | "instance_type": "ml.t3.medium", 1875 | "kernelspec": { 1876 | "display_name": "Python 3 (Data Science 4.0)", 1877 | "language": "python", 1878 | "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-2:429704687514:image/sagemaker-data-science-311-v1" 1879 | }, 1880 | "language_info": { 1881 | "codemirror_mode": { 1882 | "name": "ipython", 1883 | "version": 3 1884 | }, 1885 | "file_extension": ".py", 1886 | "mimetype": "text/x-python", 1887 | "name": "python", 1888 | "nbconvert_exporter": "python", 1889 | "pygments_lexer": "ipython3", 1890 | "version": "3.11.9" 1891 | } 1892 | }, 1893 | "nbformat": 4, 1894 | "nbformat_minor": 5 1895 | } 1896 | --------------------------------------------------------------------------------