Loading Academy Hub...
Integrate foundation generative AI models into big data pipelines: AWS Bedrock Titan Embeddings, Amazon OpenSearch Serverless vector search, LangChain batching, and RAG knowledge base data ingestion.
[!NOTE] Amazon Bedrock provides serverless API access to leading foundation models (Amazon Titan, Anthropic Claude, Meta Llama) without managing GPU infrastructure. Data engineers integrate Bedrock into ETL pipelines to generate semantic vector embeddings from unstructured text at petabyte scale.
[ S3 Raw Data ] ──▶ [ AWS Glue / Spark ] ──(Batch 100 Prompts)──▶ [ AWS Bedrock: Titan ]
│ │
▼ ▼ (1,536-dim vectors)
[ OpenSearch Serverless Vector Store ] ◀────────────────────────┘
InvokeModel API calls across 10M Lakehouse rows inside a Spark UDF—it blows past account RPM/TPM quotas and wastes executor CPU waiting on HTTP I/O. Use Amazon Bedrock Batch Inference on S3 JSONL manifests (50% cheaper per token) for offline enrichment, reserving live endpoints for online user queries.doc_id, chunk_hash (SHA-256 of normalized text), and embedding_model_version alongside vectors in OpenSearch Serverless or Aurora pgvector. On daily runs, anti-join against your Silver Delta/Iceberg table so only changed documents trigger Bedrock Titan / Cohere embedding spend.Review the production code, company interview Q&As, incident traces, and comprehension quiz inside this lesson.
import boto3
import json
bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')
def generate_titan_embedding(text_content: str) -> list:
"""Invokes Amazon Titan Embeddings G1 - Text"""
body = json.dumps({
"inputText": text_content[:8192], # Cap at context window
"dimensions": 1536,
"normalize": True
})
response = bedrock.invoke_model(
body=body,
modelId="amazon.titan-embed-text-v2:0",
accept="application/json",
contentType="application/json"
)
response_body = json.loads(response['body'].read())
return response_body['embedding']
# Sample pipeline execution
embedding = generate_titan_embedding("Customer requested credit limit increase after verifying income documents.")
print(f"Generated vector embedding with {len(embedding)} dimensions successfully.")botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Input text has 11,400 tokens, which exceeds model limit of 8,192.