Posts

aws bedrock using qwen.qwen3-coder-next is easy

Image
To work with AWS bedrock, we can consume the qwen.qwen3-coder-next mdoel using API key. Let's dive right in.  Using uv package manager, run  uv init  uv venv uv add openai And you need the following code when using "qwen.qwen3-coder-next" instead of the antrophic library. from openai import OpenAI client = OpenAI () response = client . chat . completions . create (     model = " qwen.qwen3-coder-next " ,     messages =[{ " role " : " user " , " content " : " What is Amazon Bedrock? " }], ) print ( response . choices [ 0 ]. message . content ) You would need to setup your environment variables.  set OPENAI_API_KEY="YOUR-API-KEY" set OPENAI_BASE_URL=https://bedrock-mantle.ap-southeast-2.api.aws/v1 set OPENAI_PROJECT_ID=default And then just run  python main.py   

mcp server configuration for vscode

We can quickly configure vscode to use github mcp by creating a fille under .vscode/mcp.json. This file should contain the followings:- {   " inputs " : [     {       " type " : " promptString " ,       " id " : " github_token " ,       " description " : " GitHub Personal Access Token " ,       " password " : true     }   ],   " servers " : {     " github " : {       " command " : " docker " ,       " args " : [         " run " , " -i " , " --rm " ,         " -e " , " GITHUB_PERSONAL_ACCESS_TOKEN " ,         " ghcr.io/github/github-mcp-server "       ],       " env " : {         " GITHUB_PERSONAL_ACCESS_TOKEN " : " ${input:github_token} "       }     }   } } And then you are good to prompt away

Azure AI Foundry setting up RAG with Azure Search AI

Image
To enable RAG in our agent, we need Azure foundry embedding model and a gpt-4-o model to test it out. This will empower our agent with inhouse knowledge.  Lets deploy our Azure Foundry instance first. Pretty straight forward. Ensure we have deployed 2 model - embedding-3-small as shown below We also need a storage account where we place our document to be indexed by Azure AI Search later.  Next, we will create an Azure AI Search service. This will allow us to index document in our storage account. We can also configure a schedule if we wanted to:-  Then we can import our document to build up our knowledge base.  Here, we will configure our vector searches and now you know why we are creating the embedding model. Next we will setup our agent and then add knowlege to it. So we create an agent.  Under the section, knowledge (on the left tab), that's where we provide a knowledge and index to it. Once we have configure it, we can prompt our agent accordingly.

Azure foundry client code for using response API

OpenAI Respose API is supported by the framework and we can easily use the following code to call it.  from azure . ai . projects import AIProjectClient from azure . identity import DefaultAzureCredential project_client = AIProjectClient (     endpoint = " https://<your-resource>.services.ai.azure.com/api/projects/<your-project> " ,     credential = DefaultAzureCredential () ) # Get an OpenAI-compatible client scoped to this project openai_client = project_client . get_openai_client () # First turn response = openai_client . responses . create (     model = " gpt-4o " ,   # your deployment name     input = " What's the speed of light? " ) print ( response . output_text ) # Next turn — chain via previous_response_id, just send the new input response2 = openai_client . responses . create (     model = " gpt-4o " ,     input = " And what about sound? " ,     previous_response_id = respo...

model training underfitting, overfitting and more

Image
Common challenges in a model training are  1. overfitting - high train accuracy, terrible production performance  Red flag signals Train accuracy 98%+, val accuracy 65–70% Train loss keeps falling, val loss starts rising (divergence point) Large gap between train F1 and val F1 Model memorises noise — shuffling labels barely changes train loss Primary metrics to watch Train/val loss gap Generalisation gap Val accuracy Learning curves Val F1 Watch the gap , not the absolute numbers. Train acc 98% is fine if val acc is also 94%. The gap is the signal. Primary metrics to watch Train/val loss gap Generalisation gap Val accuracy Learning curves Val F1 Watch the gap , not the absolute numbers. Train acc 98% is fine if val acc is also 94%. The gap is the signal. This is what a overfitting learning curve graph looks like. As you can see the generalization gap higher than 0.15 is a red flag. In our case, it is 0.426.  One more thing to note is the red line will diverge and ...