Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 3, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 3, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 3, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 3, 2025

      All the WWE 2K25 locker codes that are currently active

      June 3, 2025

      PSA: You don’t need to spend $400+ to upgrade your Xbox Series X|S storage

      June 3, 2025

      UK civil servants saved 24 minutes per day using Microsoft Copilot, saving two weeks each per year according to a new report

      June 3, 2025

      These solid-state fans will revolutionize cooling in our PCs and laptops

      June 3, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Community News: Latest PECL Releases (06.03.2025)

      June 3, 2025
      Recent

      Community News: Latest PECL Releases (06.03.2025)

      June 3, 2025

      A Comprehensive Guide to Azure Firewall

      June 3, 2025

      Test Job Failures Precisely with Laravel’s assertFailedWith Method

      June 3, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      All the WWE 2K25 locker codes that are currently active

      June 3, 2025
      Recent

      All the WWE 2K25 locker codes that are currently active

      June 3, 2025

      PSA: You don’t need to spend $400+ to upgrade your Xbox Series X|S storage

      June 3, 2025

      UK civil servants saved 24 minutes per day using Microsoft Copilot, saving two weeks each per year according to a new report

      June 3, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Machine Learning»DeepSeek-R1 model now available in Amazon Bedrock Marketplace and Amazon SageMaker JumpStart

    DeepSeek-R1 model now available in Amazon Bedrock Marketplace and Amazon SageMaker JumpStart

    January 31, 2025

    Today, we are announcing that DeepSeek AI’s first-generation frontier model, DeepSeek-R1, is available through Amazon SageMaker JumpStart and Amazon Bedrock Marketplace to deploy for inference. You can now use DeepSeek-R1 to build, experiment, and responsibly scale your generative AI ideas on AWS.

    In this post, we demonstrate how to get started with DeepSeek-R1 on Amazon Bedrock and SageMaker JumpStart.

    Overview of DeepSeek-R1

    DeepSeek-R1 is a large language model (LLM) developed by DeepSeek-AI that uses reinforcement learning to enhance reasoning capabilities through a multi-stage training process from a DeepSeek-V3-Base foundation. A key distinguishing feature is its reinforcement learning (RL) step, which was used to refine the model’s responses beyond the standard pre-training and fine-tuning process. By incorporating RL, DeepSeek-R1 can adapt more effectively to user feedback and objectives, ultimately enhancing both relevance and clarity. In addition, DeepSeek-R1 employs a chain-of-thought (CoT) approach, meaning it’s equipped to break down complex queries and reason through them in a step-by-step manner. This guided reasoning process allows the model to produce more accurate, transparent, and detailed answers. This model combines RL-based fine-tuning with CoT capabilities, aiming to generate structured responses while focusing on interpretability and user interaction. With its wide-ranging capabilities DeepSeek-R1 has captured the industry’s attention as a versatile text-generation model that can be integrated into various workflows such as agents, logical reasoning and data interpretation tasks

    DeepSeek-R1 uses a Mixture of Experts (MoE) architecture and is 671 billion parameters in size. The MoE architecture allows activation of 37 billion parameters, enabling efficient inference by routing queries to the most relevant expert “clusters.” This approach allows the model to specialize in different problem domains while maintaining overall efficiency. DeepSeek-R1 requires at least 800 GB of HBM memory in FP8 format for inference. In this post, we will use an ml.p5e.48xlarge instance to deploy the model. ml.p5e.48xlarge comes with 8 Nvidia H200 GPUs providing 1128 GB of GPU memory.

    You can deploy DeepSeek-R1 model either through SageMaker JumpStart or Bedrock Marketplace. Because DeepSeek-R1 is an emerging model, we recommend deploying this model with guardrails in place. In this blog, we will use Amazon Bedrock Guardrails to introduce safeguards, prevent harmful content, and evaluate models against key safety criteria. At the time of writing this blog, for DeepSeek-R1 deployments on SageMaker JumpStart and Bedrock Marketplace, Bedrock Guardrails supports only the ApplyGuardrail API. You can create multiple guardrails tailored to different use cases and apply them to the DeepSeek-R1 model, improving user experiences and standardizing safety controls across your generative AI applications.

    Prerequisites

    To deploy the DeepSeek-R1 model, you need access to an ml.p5e instance. To check if you have quotas for P5e, open the Service Quotas console and under AWS Services, choose Amazon SageMaker, and confirm you’re using ml.p5e.48xlarge for endpoint usage. Make sure that you have at least one ml.P5e.48xlarge instance in the AWS Region you are deploying. To request a limit increase, create a limit increase request and reach out to your account team.

    Because you will be deploying this model with Amazon Bedrock Guardrails, make sure you have the correct AWS Identity and Access Management (IAM) permissions to use Amazon Bedrock Guardrails. For instructions, see Set up permissions to use guardrails for content filtering.

    Implementing guardrails with the ApplyGuardrail API

    Amazon Bedrock Guardrails allows you to introduce safeguards, prevent harmful content, and evaluate models against key safety criteria. You can implement safety measures for the DeepSeek-R1 model using the Amazon Bedrock ApplyGuardrail API. This allows you to apply guardrails to evaluate user inputs and model responses deployed on Amazon Bedrock Marketplace and SageMaker JumpStart. You can create a guardrail using the Amazon Bedrock console or the API. For the example code to create the guardrail, see the GitHub repo.

    The general flow involves the following steps: First, the system receives an input for the model. This input is then processed through the ApplyGuardrail API. If the input passes the guardrail check, it’s sent to the model for inference. After receiving the model’s output, another guardrail check is applied. If the output passes this final check, it’s returned as the final result. However, if either the input or output is intervened by the guardrail, a message is returned indicating the nature of the intervention and whether it occurred at the input or output stage. The examples showcased in the following sections demonstrate inference using this API.

    Deploy DeepSeek-R1 in Amazon Bedrock Marketplace

    Amazon Bedrock Marketplace gives you access to over 100 popular, emerging, and specialized foundation models (FMs) through Amazon Bedrock. To access DeepSeek-R1 in Amazon Bedrock, complete the following steps:

    1. On the Amazon Bedrock console, choose Model catalog under Foundation models in the navigation pane.
      At the time of writing this post, you can use the InvokeModel API to invoke the model. It doesn’t support Converse APIs and other Amazon Bedrock tooling.
    2. Filter for DeepSeek as a provider and choose the DeepSeek-R1 model.

      The model detail page provides essential information about the model’s capabilities, pricing structure, and implementation guidelines. You can find detailed usage instructions, including sample API calls and code snippets for integration. The model supports various text generation tasks, including content creation, code generation, and question answering, using its reinforcement learning optimization and CoT reasoning capabilities.
      The page also includes deployment options and licensing information to help you get started with DeepSeek-R1 in your applications.
    3. To begin using DeepSeek-R1, choose Deploy.

      You will be prompted to configure the deployment details for DeepSeek-R1. The model ID will be pre-populated.
    4. For Endpoint name, enter an endpoint name (between 1–50 alphanumeric characters).
    5. For Number of instances, enter a number of instances (between 1–100).
    6. For Instance type, choose your instance type. For optimal performance with DeepSeek-R1, a GPU-based instance type like ml.p5e.48xlarge is recommended.
      Optionally, you can configure advanced security and infrastructure settings, including virtual private cloud (VPC) networking, service role permissions, and encryption settings. For most use cases, the default settings will work well. However, for production deployments, you might want to review these settings to align with your organization’s security and compliance requirements.
    7. Choose Deploy to begin using the model.

      When the deployment is complete, you can test DeepSeek-R1’s capabilities directly in the Amazon Bedrock playground.
    8. Choose Open in playground to access an interactive interface where you can experiment with different prompts and adjust model parameters like temperature and maximum length.
      When using R1 with Bedrock’s InvokeModel and Playground Console, use DeepSeek’s chat template for optimal results. For example, <|begin▁of▁sentence|><|User|>content for inference<|Assistant|> .

    This is an excellent way to explore the model’s reasoning and text generation abilities before integrating it into your applications. The playground provides immediate feedback, helping you understand how the model responds to various inputs and letting you fine-tune your prompts for optimal results.

    You can quickly test the model in the playground through the UI. However, to invoke the deployed model programmatically with any Amazon Bedrock APIs, you need to get the endpoint ARN.

    Run inference using guardrails with the deployed DeepSeek-R1 endpoint

    The following code example demonstrates how to perform inference using a deployed DeepSeek-R1 model through Amazon Bedrock using the invoke_model and ApplyGuardrail API. You can create a guardrail using the Amazon Bedrock console or the API. For the example code to create the guardrail, see the GitHub repo. After you have created the guardrail, use the following code to implement guardrails. The script initializes the bedrock_runtime client, configures inference parameters, and sends a request to generate text based on a user prompt.

    import boto3
    import json
    
    # Initialize Bedrock client
    bedrock_runtime = boto3.client("bedrock-runtime")
    
    # Configuration
    MODEL_ID = "your-model-id"  # Bedrock model ID
    GUARDRAIL_ID = "your-guardrail-id"
    GUARDRAIL_VERSION = "your-guardrail-version"
    
    def invoke_with_guardrails(prompt, max_tokens=1000, temperature=0.6, top_p=0.9):
        """
        Invoke Bedrock model with input and output guardrails
        """
        # Apply input guardrails
        input_guardrail = bedrock_runtime.apply_guardrail(
            guardrailIdentifier=GUARDRAIL_ID,
            guardrailVersion=GUARDRAIL_VERSION,
            source='INPUT',
            content=[{"text": {"text": prompt}}]
        )
        
        if input_guardrail['action'] == 'GUARDRAIL_INTERVENED':
            return f"Input blocked: {input_guardrail['outputs'][0]['text']}"
    
        # Prepare model input
        request_body = {
            "inputs": f"""You are an AI assistant. Do as the user asks.
    ### Instruction: {prompt}
    ### Response: <think>""",
            "parameters": {
                "max_new_tokens": max_tokens,
                "top_p": top_p,
                "temperature": temperature
            }
        }
    
        # Invoke model
        response = bedrock_runtime.invoke_model(
            modelId=MODEL_ID,
            body=json.dumps(request_body)
        )
        
        # Parse model response
        model_output = json.loads(response['body'].read())['generated_text']
    
        # Apply output guardrails
        output_guardrail = bedrock_runtime.apply_guardrail(
            guardrailIdentifier=GUARDRAIL_ID,
            guardrailVersion=GUARDRAIL_VERSION,
            source='OUTPUT',
            content=[{"text": {"text": model_output}}]
        )
    
        if output_guardrail['action'] == 'GUARDRAIL_INTERVENED':
            return f"Output blocked: {output_guardrail['outputs'][0]['text']}"
        
        return model_output
    
    # Example usage
    if __name__ == "__main__":
        prompt = "What's 1+1?"
        result = invoke_with_guardrails(prompt)
        print(result)

    Deploy DeepSeek-R1 with SageMaker JumpStart

    SageMaker JumpStart is a machine learning (ML) hub with FMs, built-in algorithms, and prebuilt ML solutions that you can deploy with just a few clicks. With SageMaker JumpStart, you can customize pre-trained models to your use case, with your data, and deploy them into production using either the UI or SDK.

    Deploying DeepSeek-R1 model through SageMaker JumpStart offers two convenient approaches: using the intuitive SageMaker JumpStart UI or implementing programmatically through the SageMaker Python SDK. Let’s explore both methods to help you choose the approach that best suits your needs.

    Hostinger

    Deploy DeepSeek-R1 through SageMaker JumpStart UI

    Complete the following steps to deploy DeepSeek-R1 using SageMaker JumpStart:

    1. On the SageMaker console, choose Studio in the navigation pane.
    2. First-time users will be prompted to create a domain.
    3. On the SageMaker Studio console, choose JumpStart in the navigation pane.

      The model browser displays available models, with details like the provider name and model capabilities.
    4. Search for DeepSeek-R1 to view the DeepSeek-R1 model card.
      Each model card shows key information, including:
      • Model name
      • Provider name
      • Task category (for example, Text Generation)
      • Bedrock Ready badge (if applicable), indicating that this model can be registered with Amazon Bedrock, allowing you to use Amazon Bedrock APIs to invoke the model
    5. Choose the model card to view the model details page.

      The model details page includes the following information:
      • The model name and provider information
      • Deploy button to deploy the model
      • About and Notebooks tabs with detailed information

      The About tab includes important details, such as:

      • Model description
      • License information
      • Technical specifications
      • Usage guidelines

      Before you deploy the model, it’s recommended to review the model details and license terms to confirm compatibility with your use case.

    6. Choose Deploy to proceed with deployment.
    7. For Endpoint name, use the automatically generated name or create a custom one.
    8. For Instance type¸ choose an instance type (default: ml.p5e.48xlarge).
    9. For Initial instance count, enter the number of instances (default: 1).
      Selecting appropriate instance types and counts is crucial for cost and performance optimization. Monitor your deployment to adjust these settings as needed.Under Inference type, Real-time inference is selected by default. This is optimized for sustained traffic and low latency.
    10. Review all configurations for accuracy. For this model, we strongly recommend adhering to SageMaker JumpStart default settings and making sure that network isolation remains in place.
    11. Choose Deploy to deploy the model.

    The deployment process can take several minutes to complete.

    When deployment is complete, your endpoint status will change to InService. At this point, the model is ready to accept inference requests through the endpoint. You can monitor the deployment progress on the SageMaker console Endpoints page, which will display relevant metrics and status information. When the deployment is complete, you can invoke the model using a SageMaker runtime client and integrate it with your applications.

    Deploy DeepSeek-R1 using the SageMaker Python SDK

    To get started with DeepSeek-R1 using the SageMaker Python SDK, you will need to install the SageMaker Python SDK and make sure you have the necessary AWS permissions and environment setup. The following is a step-by-step code example that demonstrates how to deploy and use DeepSeek-R1 for inference programmatically. The code for deploying the model is provided in the Github here . You can clone the notebook and run from SageMaker Studio.

    !pip install --force-reinstall --no-cache-dir sagemaker==2.235.2
    
    from sagemaker.serve.builder.model_builder import ModelBuilder 
    from sagemaker.serve.builder.schema_builder import SchemaBuilder 
    from sagemaker.jumpstart.model import ModelAccessConfig 
    from sagemaker.session import Session 
    import logging 
    
    sagemaker_session = Session()
     
    artifacts_bucket_name = sagemaker_session.default_bucket() 
    execution_role_arn = sagemaker_session.get_caller_identity_arn()
     
    js_model_id = "deepseek-llm-r1"
    
    gpu_instance_type = "ml.p5e.48xlarge"
     
    response = "Hello, I'm a language model, and I'm here to help you with your English."
    
     sample_input = {
     "inputs": "Hello, I'm a language model,",
     "parameters": {"max_new_tokens": 128, "top_p": 0.9, "temperature": 0.6},
     }
      
     sample_output = [{"generated_text": response}]
      
     schema_builder = SchemaBuilder(sample_input, sample_output)
      
     model_builder = ModelBuilder( 
     model=js_model_id, 
     schema_builder=schema_builder, 
     sagemaker_session=sagemaker_session, 
     role_arn=execution_role_arn, 
     log_level=logging.ERROR ) 
     
     model= model_builder.build() 
     predictor = model.deploy(model_access_configs={js_model_id:ModelAccessConfig(accept_eula=True)}, accept_eula=True) 
     
     
     predictor.predict(sample_input)

    You can run additional requests against the predictor:

    new_input = {
        "inputs": "What is Amazon doing in Generative AI?",
        "parameters": {"max_new_tokens": 64, "top_p": 0.8, "temperature": 0.7},
    }
    
    prediction = predictor.predict(new_input)
    print(prediction)

    Implement guardrails and run inference with your SageMaker JumpStart predictor

    Similar to Amazon Bedrock, you can also use the ApplyGuardrail API with your SageMaker JumpStart predictor. You can create a guardrail using the Amazon Bedrock console or the API, and implement it as shown in the following code:

    import boto3
    import json
    bedrock_runtime = boto3.client('bedrock-runtime')
    sagemaker_runtime = boto3.client('sagemaker-runtime')
    
    # Add your guardrail identifier and version created from Bedrock Console or AWSCLI
    guardrail_id = "" # Your Guardrail ID
    guardrail_version = "" # Your Guardrail Version
    endpoint_name = "" # Endpoint Name
    
    prompt = "What's 1+1 equal?"
    
    # Apply guardrail to input before sending to model
    input_guardrail_response = bedrock_runtime.apply_guardrail(
        guardrailIdentifier=guardrail_id,
        guardrailVersion=guardrail_version,
        source='INPUT',
        content=[{ "text": { "text": prompt }}]
    )
    
    # If input guardrail passes, proceed with model inference
    if input_guardrail_response['action'] != 'GUARDRAIL_INTERVENED':
        # Prepare the input for the SageMaker endpoint
        template = f"""You are an AI assistant. Do as the user asks.
    ### Instruction: {prompt}
    ### Response: <think>"""
        
        input_payload = {
            "inputs": template,
            "parameters": {
                "max_new_tokens": 1000,
                "top_p": 0.9,
                "temperature": 0.6
            }
        }
        
        # Convert the payload to JSON string
        input_payload_json = json.dumps(input_payload)
        
        # Invoke the SageMaker endpoint
        response = sagemaker_runtime.invoke_endpoint(
            EndpointName=endpoint_name,
            ContentType='application/json',
            Body=input_payload_json
        )
        
        # Get the response from the model
        model_response = json.loads(response['Body'].read().decode())
        
        # Apply guardrail to output
        output_guardrail_response = bedrock_runtime.apply_guardrail(
            guardrailIdentifier=guardrail_id,
            guardrailVersion=guardrail_version,
            source='OUTPUT',
            content=[{ "text": { "text": model_response['generated_text'] }}]
        )
        
        # Check if output passes guardrails
        if output_guardrail_response['action'] != 'GUARDRAIL_INTERVENED':
            print(model_response['generated_text'])
        else:
            print("Output blocked: ", output_guardrail_response['outputs'][0]['text'])
    else:
        print("Input blocked: ", input_guardrail_response['outputs'][0]['text'])

    Clean up

    To avoid unwanted charges, complete the steps in this section to clean up your resources.

    Delete the Amazon Bedrock Marketplace deployment

    If you deployed the model using Amazon Bedrock Marketplace, complete the following steps:

    1. On the Amazon Bedrock console, under Foundation models in the navigation pane, choose Marketplace deployments.
    2. In the Managed deployments section, locate the endpoint you want to delete.
    3. Select the endpoint, and on the Actions menu, choose Delete.
    4. Verify the endpoint details to make sure you’re deleting the correct deployment:
      1. Endpoint name
      2. Model name
      3. Endpoint status
    5. Choose Delete to delete the endpoint.
    6. In the deletion confirmation dialog, review the warning message, enter confirm, and choose Delete to permanently remove the endpoint.

    Delete the SageMaker JumpStart predictor

    The SageMaker JumpStart model you deployed will incur costs if you leave it running. Use the following code to delete the endpoint if you want to stop incurring charges. For more details, see Delete Endpoints and Resources.

    predictor.delete_model()
    predictor.delete_endpoint()

    Conclusion

    In this post, we explored how you can access and deploy the DeepSeek-R1 model using Bedrock Marketplace and SageMaker JumpStart. Visit SageMaker JumpStart in SageMaker Studio or Amazon Bedrock Marketplace now to get started. For more information, refer to Use Amazon Bedrock tooling with Amazon SageMaker JumpStart models, SageMaker JumpStart pretrained models, Amazon SageMaker JumpStart Foundation Models, Amazon Bedrock Marketplace, and Getting started with Amazon SageMaker JumpStart.


    About the Authors

    Vivek Gangasani is a Lead Specialist Solutions Architect for Inference at AWS. He helps emerging generative AI companies build innovative solutions using AWS services and accelerated compute. Currently, he is focused on developing strategies for fine-tuning and optimizing the inference performance of large language models. In his free time, Vivek enjoys hiking, watching movies, and trying different cuisines.

    Niithiyn Vijeaswaran is a Generative AI Specialist Solutions Architect with the Third-Party Model Science team at AWS. His area of focus is AWS AI accelerators (AWS Neuron). He holds a Bachelor’s degree in Computer Science and Bioinformatics.

    Jonathan Evans is a Specialist Solutions Architect working on generative AI with the Third-Party Model Science team at AWS.

    Banu Nagasundaram leads product, engineering, and strategic partnerships for Amazon SageMaker JumpStart, SageMaker’s machine learning and generative AI hub. She is passionate about building solutions that help customers accelerate their AI journey and unlock business value.

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleBaidu Research Introduces EICopilot: An Intelligent Agent-based Chatbot to Retrieve and Interpret Enterprise Information from Massive Graph Databases
    Next Article interior design services in hyderabad

    Related Posts

    Machine Learning

    How to Evaluate Jailbreak Methods: A Case Study with the StrongREJECT Benchmark

    June 3, 2025
    Machine Learning

    This AI Paper Introduces LLaDA-V: A Purely Diffusion-Based Multimodal Large Language Model for Visual Instruction Tuning and Multimodal Reasoning

    June 3, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    New Phishing Kit Xiū gǒu Targets Users Across Five Countries With 2,000 Fake Sites

    Development

    6 Steps to Successfully Change Your Career Path

    Development

    This AI Paper from Databricks and MIT Propose Perplexity-Based Data Pruning: Improving 3B Parameter Model Performance and Enhancing Language Models

    Development

    Chromecast chaos – 2nd gen devices go belly-up as Google struggles to fix certificate issue

    Development

    Highlights

    Linux

    Tra le scelte di Ubuntu sulle Coreutils e il nuovo driver NVIDIA NOVA, Rust non dà segni di rallentamento

    March 20, 2025

    È vero, è dall’inizio dell’anno che raccontiamo la tempesta in corso nel kernel Linux a…

    CVE-2025-46577 – GoldenDB Database SQL Injection Vulnerability

    April 27, 2025

    Chinese APT Lotus Panda Targets Governments With New Sagerunex Backdoor Variants

    March 16, 2025

    Which programming languages are most popular now (and what does that even mean)?

    August 30, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.