AWS AI/ML Services සිංහලෙන් | Cloud AI Tutorial | AWS Machine Learning Guide Sri Lanka

ආයුබෝවන් යාළුවනේ! අද අපි කතා කරන්න යන්නේ මේ දවස්වල ලෝකයේ ගොඩක් දෙනෙක් කතා කරන, තොරතුරු තාක්ෂණ ක්ෂේත්රයේ විශාල විප්ලවයක් ඇති කරමින් ඉන්න "Artificial Intelligence (AI)" සහ "Machine Learning (ML)" ගැන. විශේෂයෙන්ම, Cloud එකේ රජ්ජුරුවෝ කියන AWS (Amazon Web Services) මේ සඳහා දීලා තියෙන Services ගොඩ ගැන අපි ගැඹුරින් බලමු.
AWS AI/ML Services කියන්නේ අපේ applications වලට AI capabilities එකතු කරගන්න පුළුවන් Tools සහ Platforms ගොඩක්. Data scientists ලට වගේම, සාමාන්ය Developers ලටත් මේවා ගොඩක් ප්රයෝජනවත්. මේ Guide එකෙන් අපි, AWS AI/ML Service Landscape එක, Services තෝරාගන්න ඕන කොහොමද, ඒවා එකිනෙක සම්බන්ධ කරගන්නේ කොහොමද, සහ Cost එක ගැනත් කතා කරනවා. එහෙනම්, අපි පටන් ගමු!
AWS AI/ML Services වර්ගීකරණය (Categorizing AWS AI/ML Services)
AWS මේ Services ප්රධාන වශයෙන් වර්ග තුනකට බෙදා දක්වනවා. මේ සෑම වර්ගයකින්ම විවිධ මට්ටමේ Customization සහ Control ලබා දෙනවා.
Pre-trained AI Services (පුහුණු කරන ලද AI සේවා)
මේවා "ready-to-use" Services. ඔබට Data Science expertise එකක් නැතත්, ඔබේ application වලට AI capabilities එකතු කරගන්න පුළුවන්. AWS විසින් මේ Models විශාල Data ප්රමාණයක් යොදාගෙන පුහුණු කරලා තියෙන්නේ, ඒ නිසා ඔබට අවශ්ය වන්නේ API calls මගින් ඒවාට Access ගැනීම පමණයි.
- Amazon Rekognition: Images and videos analyze කරලා, objects, scenes, faces, සහ activities හඳුනාගන්න පුළුවන්. Facial recognition, content moderation වගේ දේවලට මේක පාවිච්චි කරනවා.
- Amazon Polly: Text-to-speech Service එකක්. ලිඛිත පෙළ ස්වභාවික කටහඬවල් වලට හරවනවා. විවිධ භාෂා සහ accents Support කරනවා.
- Amazon Translate: භාෂා පරිවර්තනය සඳහා. Text translate කරන්න පුළුවන්. Real-time වගේම Batch processing වලටත් Support කරනවා.
- Amazon Comprehend: Text analyze කරලා insights ගන්නවා. Sentiment analysis (භාවමය විශ්ලේෂණය), key phrase extraction, entity recognition (ආයතන, ස්ථාන, පුද්ගලයන් හඳුනාගැනීම) වගේ දේවල් මේකෙන් කරන්න පුළුවන්.
- Amazon Transcribe: Speech-to-text Service එකක්. කටහඬ (audio) ලිඛිත පෙළට හරවනවා. Call center analysis, subtitles generate කිරීමට මේවා ප්රයෝජනවත්.
මේවා API calls මගින් ඉතා පහසුවෙන් Integrate කරන්න පුළුවන්.
Machine Learning Platforms (ML වේදිකා)
මේවා ඔබට ඔබේම Machine Learning Models හදන්න, Train කරන්න, සහ Deploy කරන්න අවශ්ය Tools සහ infrastructure සපයනවා. Data scientists ලාට සහ ML engineers ලාට මේවා ගොඩක් ප්රයෝජනවත්. මෙහිදී ඔබට Models වල Algorithm එකේ සිට Data Pre-processing දක්වාම සම්පූර්ණ පාලනයක් තියෙනවා.
- Amazon SageMaker: මේ ක්ෂේත්රයේ ප්රධානම Service එක තමයි Amazon SageMaker. Data preparation, model training, tuning, deployment, monitoring වගේ ML lifecycle එකේ හැම පියවරකටම Support කරනවා.
- SageMaker Studio, Jupyter notebooks, built-in algorithms, flexible training options (distributed training, hyperparameter tuning), model hosting, සහ monitoring capabilities වගේ දේවල් මේකේ තියෙනවා. ඔබට Custom Algorithms සහ Frameworks (TensorFlow, PyTorch) පාවිච්චි කරන්නත් පුළුවන්.
Generative AI Services (නිර්මාණාත්මක AI සේවා)
මේවා අලුතින්ම ආපු Services. මේවාට text, images, code, audio වගේ දේවල් "create" කරන්න පුළුවන්. Large Language Models (LLMs) වගේ දේවල් මේ යටතට එනවා. මේවා විශාල Data Sets මත Training කර ඇති අතර, විවිධ නිර්මාණාත්මක කාර්යයන් සඳහා යොදාගැනීමට හැකියි.
- Amazon Bedrock: Foundation Models (FMs) ගොඩකට Access දෙන Fully managed service එකක්. (Anthropic's Claude, AI21 Labs' Jurassic, Stability AI's Stable Diffusion, Amazon's Titan Models). ඔබට මේ Models ඔබේම Data එකෙන් Fine-tune කරලා ඔබේ Business එකට specific outputs ගන්නත් පුළුවන්.
- Amazon CodeWhisperer: Developers ලාට Code ලියන්න උදව් කරන AI coding companion එකක්. Real-time code suggestions, completions, සහ unit test generation වගේ දේවල් ලබා දෙනවා. Python, Java, JavaScript, C#, TypeScript, Go, Rust, PHP, Ruby, Kotlin, SQL, Scala, and shell scripts වගේ භාෂා වලට Support කරනවා.
නිවැරදි AWS AI/ML Service එක තෝරාගැනීම (Choosing the Right AWS AI/ML Service)
මේක ගොඩක් වැදගත්. ඔබේ Project එකට ගැලපෙන Service එක තෝරගන්න මේ කරුණු ගැන අවධානය දෙන්න:
- ඔබ Data Science සහ ML ගැන දැනුමක් නැති සාමාන්ය Developer කෙනෙක් නම්, Pre-trained AI Services (Rekognition, Polly, Translate) ඔබට පහසුයි. මේවාට Data Science දැනුම අවශ්ය වන්නේ නැහැ, API call එකක් කරන්න දැන සිටීම ප්රමාණවත්.
- ඔබට ML expertise එකක් තියෙනවා නම්, SageMaker වගේ Platforms ඔබේ Models වලට වඩා හොඳ Customization එකක් දෙනවා. මෙහිදී ඔබට Models වලට බලපෑම් කිරීමට සහ Algorithms තෝරා ගැනීමට හැකියි.
- Standard tasks (image recognition, text-to-speech) වලට Pre-trained services හොඳයි. මේවා සාමාන්යයෙන් General Use Cases සඳහා සුදුසුයි.
- ඔබේ Business එකට specific වෙන Models හදන්න, හෝ සුවිශේෂී Data Sets මත Models Train කරන්න ඕන නම්, SageMaker වගේ ML Platforms අවශ්යයි.
- Generative AI Models ඔබේ Data එකෙන් Fine-tune කරලා specific output styles හෝ Knowledge Domains වලට අනුව සකස් කරන්න ඕන නම්, Bedrock වගේ services යොදාගන්න පුළුවන්.
- Pre-trained services සාමාන්යයෙන් "pay-per-use" (API call එකකට ගාස්තු) Model එකක් මත ක්රියාත්මක වෙනවා. ඒ නිසා ඔබට වියදම් වන්නේ ඔබ භාවිතා කරන ප්රමාණයට පමණයි.
- SageMaker වගේ Platforms වලට Instance hours, Storage, සහ Data processing අනුව ගාස්තු අය වෙනවා. මේවා Models Training කරනකොට වැඩි වෙන්න පුළුවන්. ඔබේ Training Jobs වලට අවශ්ය Hardware Resources සහ කාලය අනුව Cost එක වෙනස් වෙනවා. AWS Free Tier එක ගැනත් සැලකිලිමත් වෙන්න, අත්හදා බැලීම් සඳහා එය විශාල උපකාරයක්.
- විශාල Data ප්රමාණයක් Real-time analyze කරන්න ඕන නම්, Service එකේ Scalability සහ Performance බලන්න ඕන. AWS Services ගොඩක් High Scalability එකක් දෙනවා. උදාහරණයක් ලෙස, Amazon Kinesis වැනි Services සමඟ AI/ML Services Integrate කරලා Real-time Data Processing කරන්න පුළුවන්.
- ඔබේ application එකට ඉතා අඩු latency එකක් අවශ්ය නම්, Service එකේ Response time එක ගැන අවධානය දෙන්න. Pre-trained services සාමාන්යයෙන් අඩු latency එකක් දෙනවා. Custom Models වලදී, Instance type එක සහ Model Optimization එක මත Latency එක රඳා පවතිනවා.
- AWS services එකිනෙක හොඳින් Integrate වෙනවා. ඔබේ Architecture එකට ගැලපෙන පරිදි Data Flow එක Design කරන්න. මේක Cloud Native Development වලදී ඉතා වැදගත් අංගයක්.
අනෙකුත් Services සමඟ Integration (Integration with other Services)
Performance සහ Latency (Performance and Latency)
Data Volume සහ Velocity (Data Volume and Velocity)
පිරිවැය (Cost)
Customization අවශ්යතාවය (Customization Needs)
ඔබේ Skillset එක (Your Skillset)
AWS AI/ML Services එකිනෙක සම්බන්ධ කරන හැටි (Service Integration Patterns)
AWS ecosystem එකේදී Services එකිනෙක සම්බන්ධ කිරීම ගොඩක් පහසුයි. Application Architecture එකක් හදනකොට මේ patterns ප්රයෝජනවත් වෙනවා:
Step Functions
සමහර වෙලාවට AI/ML workflows වලට Services ගොඩක් sequential විදිහට සම්බන්ධ කරන්න ඕන වෙනවා. ඒවගේ වෙලාවට AWS Step Functions පාවිච්චි කරන්න පුළුවන්. මේකෙන් Distributed Applications වල Workflow simplify කරන්න පුළුවන්. Complex ML pipelines (Data preparation, training, evaluation, deployment) කළමනාකරණය කිරීමට මෙය හොඳ විසඳුමකි.
API Gateway + Lambda + AI Service
Web Application එකකින් Frontend එකෙන් API Gateway එකට Call එකක් දීලා, ඒක Lambda එකක් Trigger කරලා, AI Service එකකින් Process කරලා Result එක ආපහු Frontend එකට යවන්න පුළුවන්. (Real-time predictions වලට හොඳයි). User input මත පදනම්ව AI services ක්රියාත්මක කිරීමට මෙය ඉතා ප්රයෝජනවත් වේ.
S3 (Storage) + Lambda (Compute) + AI Service
S3 Bucket එකකට File (image, audio, text) එකක් Upload කරපු ගමන්, Lambda Function එකක් Trigger කරලා, AI Service එකකින් ඒ File එක Process කරන්න පුළුවන්. Result එක ආයෙත් S3 එකක save කරන්න හෝ Database එකකට (DynamoDB) දාන්න පුළුවන්. මේක Event-driven Architecture එකක් සඳහා හොඳ උදාහරණයක්.
ප්රායෝගික උදාහරණය: S3 Bucket එකකට Upload කරන Images වල Objects Detect කරන Lambda Function එකක්.
import json
import boto3
import os
s3_client = boto3.client('s3')
rekognition_client = boto3.client('rekognition')
dynamodb = boto3.resource('dynamodb')
table_name = os.environ.get('DYNAMODB_TABLE_NAME', 'ImageAnalysisResults') # Environment variable
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
# Get the S3 bucket and object key from the event
bucket = event['Records'][0]['s3']['bucket']['name']
key = event['Records'][0]['s3']['object']['key']
try:
# Call Amazon Rekognition to detect labels in the image
response = rekognition_client.detect_labels(
Image={
'S3Object': {
'Bucket': bucket,
'Name': key
}
},
MaxLabels=10,
MinConfidence=70
)
print(f"Detected labels for {key}: {response['Labels']}")
# Prepare data for DynamoDB
labels = [{'Name': label['Name'], 'Confidence': float(label['Confidence'])} for label in response['Labels']]
table = dynamodb.Table(table_name)
table.put_item(
Item={
'ImageKey': key,
'Bucket': bucket,
'Labels': labels,
'Timestamp': context.get_remaining_time_in_millis() # Example timestamp
}
)
print(f"Results stored in DynamoDB for {key}")
return {
'statusCode': 200,
'body': json.dumps('Image processed successfully!')
}
except Exception as e:
print(e)
print(f'Error processing object {key} from bucket {bucket}.')
raise e
මේ Code එකෙන් පෙන්නන්නේ S3 එකට Image එකක් Upload කරාම, Lambda එකක් Trigger වෙලා, Amazon Rekognition පාවිච්චි කරලා ඒ Image එකේ තියෙන Objects Detect කරලා, ඒ Results DynamoDB Table එකක Save කරන හැටි. මේකෙන් Data Flow එකක් කොච්චර ලේසියෙන් හදාගන්න පුළුවන්ද කියලා තේරෙනවා. මේ Lambda Function එක ක්රියාත්මක කිරීම සඳහා, ඔබට S3 Bucket එකක්, DynamoDB Table එකක් (ImageAnalysisResults
වගේ) සහ Lambda Function එකට Rekognition, S3, DynamoDB වලට Access ලබා දීමට අවශ්ය IAM Permissions ලබා දිය යුතුයි.
AWS AI/ML Pricing Models සහ Limits (AWS AI/ML Pricing Models and Limits)
Cloud Services පාවිච්චි කරනකොට Cost Management කියන්නේ ගොඩක් වැදගත් දෙයක්. අනවශ්ය වියදම් වළක්වා ගැනීමට මේ ගැන අවබෝධයක් තිබීම අත්යාවශ්යයි.
Pricing Models
- Pay-as-you-go: බොහෝ AWS AI Services වලට මේක තමයි ප්රධානම Model එක. ඔබ පාවිච්චි කරන ප්රමාණයට විතරයි ගාස්තු ගෙවන්නේ. (e.g., Rekognition - images processed per month, Polly - characters processed, Transcribe - audio duration processed).
- Instance Hours: SageMaker වගේ Platforms වලදී Models Train කරන්න, Deploy කරන්න පාවිච්චි කරන EC2 Instances වල Runtime (පැය ගණන) අනුව ගාස්තු අය වෙනවා. GPU Instances වලට ගාස්තු වැඩියි.
- Storage: Data Storage (S3, EBS) වලට වෙනම ගාස්තු අය වෙනවා.
- Data Transfer: Data transfer out of AWS regions වලට ගාස්තු අය වෙන්න පුළුවන්.
- Free Tier: AWS Free Tier එකෙන් ඔබට සමහර Services Limited ප්රමාණයකට නොමිලේ පාවිච්චි කරන්න පුළුවන්. අලුතින් පටන් ගන්න අයට මේක හොඳ අවස්ථාවක්. ඔබේ Project එක ආරම්භ කිරීමට පෙර Free Tier details කියවා බැලීම වැදගත්.
Service Limits and Quotas (සේවා සීමා සහ කොටස්)
- සෑම AWS Service එකකටම Default Limits (Quotas) තියෙනවා. මේවා ඔබේ Account එකට අයත් Service එකකින් යම් කාලයක් තුළ කරන්න පුළුවන් operations ප්රමාණය, storage ප්රමාණය, instances ගණන වගේ දේවල් පාලනය කරනවා.
- උදාහරණ: Rekognition වලට per second කරන්න පුළුවන් requests ගණන, SageMaker වලට පාවිච්චි කරන්න පුළුවන් ML Instances ගණන.
- මේ Limits exceed වුණොත්, ඔබේ Applications fail වෙන්න පුළුවන්. ඒ නිසා ඔබේ Project එකේ අවශ්යතාවය අනුව AWS Support team එකට Request කරලා මේ Limits වැඩි කරගන්න පුළුවන්.
- AWS Trusted Advisor වගේ Tools පාවිච්චි කරලා මේ Limits Check කරන්න පුළුවන්. මේවා ඔබේ Infrastructure එකේ Performance සහ Cost Efficiency වැඩි කිරීමට උපකාරී වේ.
Conclusion
ඉතින් යාළුවනේ, මේ Guide එකෙන් ඔයාලට AWS AI/ML Landscape එක ගැන හොඳ අවබෝධයක් ලැබෙන්න ඇති කියලා මම හිතනවා. Pre-trained Services, ML Platforms, සහ Generative AI Services වගේ විවිධ Services වර්ග තියෙනවා. ඔබේ Project එකේ අවශ්යතාවය, skillset එක, සහ Cost එක අනුව නිවැරදි Service එක තෝරාගැනීම ගොඩක් වැදගත්. ඒ වගේම, Services එකිනෙක හොඳින් Integrate කරලා Scalable, Robust Solutions හදාගන්න පුළුවන් බවත් අපි දැක්කා.
අදම මේ Concepts පාවිච්චි කරලා පොඩි Project එකක් හදලා බලන්න. AWS Free Tier එක මේකට හොඳටම ප්රයෝජනවත්. ඔබේ අත්දැකීම් පහල Comment Section එකේ අපිත් එක්ක බෙදාගන්න අමතක කරන්න එපා. ජය වේවා!