Vipul Srivastava's picture
1 2

Vipul Srivastava

vsrivastav-pm
·

AI & ML interests

None yet

Recent Activity

Organizations

None yet

vsrivastav-pm's activity

upvoted an article 1 day ago
view article
Article

Hugging Face models in Amazon Bedrock

14
view reply

@pagezyhf Hey Simon, wasn't sure where to post but i can confirm i was able to get myself unblocked.

Below are the steps

  • Goto Marketplace deployments
  • Goto Model Catalog
  • Pick DeepSeek-R1-Distill-Qwen-1.5B ( as an example )
  • Click on Deploy ( for prod, one should select the VPC, private subnets etc )
  • Once created, It should Appear as Registered + In Service on Managed deployments
  • Copy the Endpoint Name from the Model
  • Run the below code ( add endpoint name + specify region )
import boto3
import json

client = boto3.client('sagemaker-runtime', region_name='<specify region>')
endpoint_name = '<Fill me in>'

# Prepare input payload
input_payload = {
    "inputs": "What is Hugging Face doing in the field of generative AI?"
}

# Convert the payload to JSON
payload_json = json.dumps(input_payload)

response = client.invoke_endpoint(
    EndpointName=endpoint_name,
    Body=payload_json,
    ContentType='application/json'
)

result = response['Body'].read().decode('utf-8')
print(result)
view reply
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the Converse operation: This action doesn't support the model that you provided. Try again with a supported text or chat model.
  • Getting the above issue when running the below snippet of code, i am passing the actual arn when running it , is this doc upto date ?
        endpoint_arn = "arn:aws:sagemaker:<AWS::REGION>:<AWS::AccountId>:endpoint/<Endpoint_Name>"
        response = bedrock_runtime.converse(
                modelId=endpoint_arn,
                messages=[
                    {
                        "role": "user",
                        "content": [
                            {
                                "text": "What is Amazon doing in the field of generative AI?",
                            },
                        ]
                    },
                    ],
                inferenceConfig=inference_config,
                additionalModelRequestFields=additional_model_fields,
        )