<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Girish Balachandran on Medium]]></title>
        <description><![CDATA[Stories by Girish Balachandran on Medium]]></description>
        <link>https://medium.com/@girishbalachandran?source=rss-b7219949241c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*hG0BmUxgGDSqmcHweTa3fg.jpeg</url>
            <title>Stories by Girish Balachandran on Medium</title>
            <link>https://medium.com/@girishbalachandran?source=rss-b7219949241c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 01:46:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@girishbalachandran/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Running DeepSeek-R1 models in Amazon Bedrock]]></title>
            <link>https://medium.com/@girishbalachandran/running-deepseek-r1-models-in-amazon-bedrock-13def92db25d?source=rss-b7219949241c------2</link>
            <guid isPermaLink="false">https://medium.com/p/13def92db25d</guid>
            <category><![CDATA[deepseek-r1]]></category>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[code-samples]]></category>
            <category><![CDATA[generative-ai-solution]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Girish Balachandran]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 09:44:58 GMT</pubDate>
            <atom:updated>2025-03-16T03:38:33.597Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KZGlopocDnVRzKZzXU71g.png" /><figcaption>Generated by Amazon Nova Canvas</figcaption></figure><p>Yesterday (March 10, 2025), Amazon <a href="https://aws.amazon.com/blogs/aws/deepseek-r1-now-available-as-a-fully-managed-serverless-model-in-amazon-bedrock/">announced</a> the availability of DeepSeek-R1 model as a fully managed serverless model in Amazon Bedrock.</p><p>I decide to try it out in my AWS account and use the Bedrock Converse API to access the Bedrock APIs.</p><p>Here is the full code for the application.</p><pre>import json<br>import boto3 <br>from botocore.exceptions import ClientError<br><br>session = boto3.Session()<br><br>#Create a Bedrock runtime client<br>bedrock = session.client(service_name=&#39;bedrock-runtime&#39;) <br><br>#Set the foundation model ID<br>bedrock_model_id = &quot;us.deepseek.r1-v1:0&quot; <br><br>system_prompt = &quot;You are a helpful assistant&quot;<br>system_messages = [<br>    {<br>        &quot;text&quot;: system_prompt<br>    }<br>]<br><br>user_prompt = &quot;How will you calculate the factors of 1729?&quot;<br>user_messages = [<br>    {<br>        &quot;role&quot;: &quot;user&quot;,<br>        &quot;content&quot;: [{&quot;text&quot;: user_prompt}],<br>    }<br>]<br><br>try:<br>    #Send the message to the model, using a basic inference configuration.<br>    response = bedrock.converse(<br>        modelId=bedrock_model_id,<br>        system=system_messages,<br>        messages=user_messages,<br>        inferenceConfig={<br>            &quot;maxTokens&quot;: 30000, <br>            &quot;temperature&quot;: 0.8, <br>            &quot;topP&quot;: 0.9<br>        },<br>    )<br><br>    contents = response[&quot;output&quot;][&quot;message&quot;][&quot;content&quot;]<br><br>    reasoning = None<br>    final_answer = None<br><br>    # Process each content to find reasoning and response text<br>    for content in contents:<br>        if &quot;reasoningContent&quot; in content:<br>            reasoning = content[&quot;reasoningContent&quot;][&quot;reasoningText&quot;][&quot;text&quot;]<br>        if &quot;text&quot; in content:<br>            final_answer = content[&quot;text&quot;]<br><br>    print(&quot;Reasoning: &quot; + reasoning)<br>    print(&quot;Final Answer: &quot; + final_answer)<br><br>except (ClientError, Exception) as e:<br>    print(f&quot;ERROR: Can&#39;t invoke &#39;{bedrock_model_id}&#39;. Reason: {e}&quot;)<br>    exit(1)</pre><p>In the API response, you find the final answer and reasoning available as 2 separate entries in the response JSON.</p><p>I asked the question <strong><em>How will you calculate the factors of 1729?</em></strong></p><p>Here is how I got the output with detailed reasoning and the final answer. The way it has reasoned and found the answer is an interesting read!</p><pre>Reasoning: Okay, let&#39;s see. I need to figure out the factors of 1729. <br>Hmm, factors are numbers that divide into 1729 without leaving a remainder. <br>So, starting from 1, I know 1 and 1729 itself are always factors. <br>Then I check 2. Wait, 1729 is an odd number, so it&#39;s not divisible by 2. <br>Next, 3. Let me add the digits: 1+7+2+9 = 19. <br>19 isn&#39;t divisible by 3, so 3 isn&#39;t a factor.<br>Moving on to 5. The last digit is 9, which isn&#39;t 0 or 5, so 5 isn&#39;t a factor. <br>How about 7? Let&#39;s divide 1729 by 7. 7 goes into 17 twice (14), <br>subtract 14 from 17, remainder 3. Bring down the 2 to make 32. <br>7 into 32 is 4 times (28), remainder 4. <br>Bring down the 9 to make 49. 7 into 49 is exactly 7. <br>So, 1729 divided by 7 is 247. So, 7 and 247 are factors. <br>Now I need to factorize 247 further. <br>Let&#39;s check if 247 is divisible by 7 again. 7 times 35 is 245, <br>which leaves a remainder of 2. So, not divisible by 7. <br>Next prime is 11. 11 times 22 is 242, subtract that from 247, <br>remainder 5. Not divisible. Then 13. Let&#39;s see: 13 times 19 is 247. <br>Yes! So, 13 and 19 are factors. <br>So putting it all together, the factors are 1, 7, 13, 19, 91 <br>(which is 7*13), 133 (7*19), 247 (13*19), and 1729.<br> <br>Wait, are there any other factors? Let me check if I missed any primes between 19 and 247. <br>But since 13 and 19 multiply to 247, and 7 is already used, <br>I think that&#39;s all. So those are the factors.</pre><pre>Final Answer:<br><br>To find the factors of 1729, follow these steps:<br><br>1. **Check small primes**:<br>   - **7**: \(1729 ÷ 7 = 247\) (no remainder). So, **7** and **247** are factors.<br>   - Factorize **247** further:<br>     - **13**: \(247 ÷ 13 = 19\) (no remainder). So, **13** and **19** are factors.<br><br>2. **Combine factors**:<br>   The prime factorization is \(7 \times 13 \times 19\). Multiplying these in pairs gives additional factors:<br>   - \(7 \times 13 = 91\)<br>   - \(7 \times 19 = 133\)<br>   - \(13 \times 19 = 247\)<br><br>3. **List all factors**:<br>   Include **1** and **1729** itself.<br><br>**Final Answer**:<br>The factors of 1729 are<br>**1, 7, 13, 19, 91, 133, 247, and 1729**.<br><br>This number is also known as the **Hardy-Ramanujan number**, the smallest integer expressible as the sum of two cubes in two different ways:<br>\(1729 = 1^3 + 12^3 = 9^3 + 10^3\).</pre><p>Happy to see that it identified the significance of the number 1729 as well :)</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13def92db25d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>