<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged oci-genai</title>
<link>https://coderlegion.com/tag/oci-genai</link>
<description>Powered by Question2Answer</description>
<item>
<title>OCI Generative AI Agents: Building Enterprise RAG Applications Without Code</title>
<link>https://coderlegion.com/10334/oci-generative-ai-agents-building-enterprise-rag-applications-without-code</link>
<description>&lt;p&gt;Oracle Cloud Infrastructure (OCI) Generative AI Agents represents a paradigm shift in building AI applications—enabling enterprises to deploy production-grade RAG (Retrieval-Augmented Generation) systems without writing a single line of code. This comprehensive guide explores the architecture, capabilities, and practical implementation of OCI Gen AI Agents for enterprise use cases.&lt;/p&gt;
&lt;h3 id=&quot;what-are-oci-generative-ai-agents-&quot;&gt;What are OCI Generative AI Agents?&lt;/h3&gt;
&lt;p&gt;OCI Generative AI Agents is a fully managed service that combines the power of large language models (LLMs) with an intelligent retrieval system to create contextually relevant answers by searching your knowledge base, making your AI applications smart and efficient.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AI Agents are applications of LLMs packaged and validated, ready to use out of the box&lt;/strong&gt; for enterprise deployments.&lt;/p&gt;
&lt;h4 id=&quot;core-capabilities&quot;&gt;Core Capabilities&lt;/h4&gt;
&lt;p&gt;An AI agent is an &lt;strong&gt;LLM-based autonomous system that understands and generates human-like text with high answerability and groundedness&lt;/strong&gt;. Specifically, an AI agent can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Perform complex tasks autonomously&lt;/strong&gt;: Execute multi-step workflows without constant human intervention&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mimic human chain-of-thought processing&lt;/strong&gt;: Reason through problems systematically&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Be an effective tool for automating processes&lt;/strong&gt;: Handle repetitive tasks at scale&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Utilize your knowledge&lt;/strong&gt;: Access and reason over enterprise-specific information&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;how-agents-work&quot;&gt;How Agents Work&lt;/h4&gt;
&lt;p&gt;An AI agent &lt;strong&gt;understands and interprets user queries, determines necessary actions, retrieves data if necessary, and executes actions&lt;/strong&gt; to deliver accurate, contextually relevant responses.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Complete Workflow:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;User Input&lt;/strong&gt;: Natural language query submitted to the agent&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Query Understanding&lt;/strong&gt;: LLM interprets the intent and context&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Knowledge Retrieval&lt;/strong&gt;: Agent searches knowledge base for relevant information&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Response Formulation&lt;/strong&gt;: LLM generates answer based on retrieved context&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Output&lt;/strong&gt;: User receives response with source citations&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;key-agent-components&quot;&gt;Key Agent Components&lt;/h3&gt;
&lt;h4 id=&quot;knowledge-base&quot;&gt;Knowledge Base&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;A knowledge base is the base for all the data sources that an agent can use to retrieve information for its chat answers.&lt;/strong&gt; An agent connects to a knowledge base, which is a vector-based storage that can connect to and ingest data from a data source.&lt;/p&gt;
&lt;p&gt;Knowledge bases support multiple data store types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OCI Object Storage&lt;/strong&gt;: Simple file-based storage (PDF, TXT, JSON, HTML, Markdown)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCI OpenSearch&lt;/strong&gt;: Pre-indexed documents with custom chunking&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Oracle Database 23ai&lt;/strong&gt;: AI Vector Search with structured and unstructured data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MySQL HeatWave&lt;/strong&gt;: In-database vector capabilities&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;data-sources&quot;&gt;Data Sources&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Data sources provide connection information to the data stores that an agent uses to generate responses.&lt;/strong&gt; Each knowledge base can have multiple data sources, though only one bucket is allowed per Object Storage data source.&lt;/p&gt;
&lt;h4 id=&quot;data-ingestion&quot;&gt;Data Ingestion&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Data ingestion is a process that extracts data from data source documents, converts it into a structured format suitable for analysis, and then stores it in a knowledge database.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ingestion pipeline handles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Document parsing and text extraction&lt;/li&gt;
&lt;li&gt;Chunking into smaller segments&lt;/li&gt;
&lt;li&gt;Embedding generation&lt;/li&gt;
&lt;li&gt;Vector indexing&lt;/li&gt;
&lt;li&gt;Metadata extraction&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;agent-concepts-and-terminology&quot;&gt;Agent Concepts and Terminology&lt;/h3&gt;
&lt;h4 id=&quot;session&quot;&gt;Session&lt;/h4&gt;
&lt;p&gt;A &lt;strong&gt;session is a series of exchanges where the user sends queries or prompts and the agent responds with relevant information&lt;/strong&gt;. Sessions maintain conversation context, enabling multi-turn dialogues where follow-up questions reference previous exchanges.&lt;/p&gt;
&lt;h4 id=&quot;agent-endpoint&quot;&gt;Agent Endpoint&lt;/h4&gt;
&lt;p&gt;An &lt;strong&gt;agent endpoint is a specific point of access in a network or system that agents use to interact with other systems or devices&lt;/strong&gt;. Endpoints provide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;REST API access for programmatic integration&lt;/li&gt;
&lt;li&gt;Chat interface for interactive testing&lt;/li&gt;
&lt;li&gt;Authentication and authorization controls&lt;/li&gt;
&lt;li&gt;Rate limiting and monitoring&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;trace&quot;&gt;Trace&lt;/h4&gt;
&lt;p&gt;A &lt;strong&gt;trace is a feature to track and display conversation history during a chat conversation&lt;/strong&gt;. Traces enable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Debugging agent responses&lt;/li&gt;
&lt;li&gt;Understanding retrieval decisions&lt;/li&gt;
&lt;li&gt;Monitoring performance&lt;/li&gt;
&lt;li&gt;Auditing user interactions&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;citation&quot;&gt;Citation&lt;/h4&gt;
&lt;p&gt;A &lt;strong&gt;citation is the source of information for an agent's response&lt;/strong&gt;. OCI Generative AI Agents provides source attribution for all answers, displaying:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Document name&lt;/li&gt;
&lt;li&gt;Page number (for PDFs)&lt;/li&gt;
&lt;li&gt;Hyperlinks to original sources&lt;/li&gt;
&lt;li&gt;Relevance scores&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This transparency enables users to verify information and builds trust in agent responses.&lt;/p&gt;
&lt;h4 id=&quot;content-moderation&quot;&gt;Content Moderation&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Content moderation is a feature designed to help detect or filter out certain toxic, violent, abusive, hateful, threatening, insulting, and harassing phrases from generated responses or user prompts in LLMs.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Content moderation protects both users and organizations by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Filtering inappropriate user inputs&lt;/li&gt;
&lt;li&gt;Screening generated outputs&lt;/li&gt;
&lt;li&gt;Blocking harmful content&lt;/li&gt;
&lt;li&gt;Maintaining brand safety&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;object-storage-guidelines-for-genai-agents&quot;&gt;Object Storage Guidelines for GenAI Agents&lt;/h3&gt;
&lt;p&gt;When using Object Storage as your data source, follow these critical guidelines to ensure successful ingestion.&lt;/p&gt;
&lt;h4 id=&quot;file-requirements&quot;&gt;File Requirements&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Data for GenAI Agents must be uploaded as files to an Object Storage bucket.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Supported File Types:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As of 2025, OCI Generative AI Agents supports:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PDF&lt;/strong&gt; files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TXT&lt;/strong&gt; files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JSON&lt;/strong&gt; files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HTML&lt;/strong&gt; files  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Markdown (MD)&lt;/strong&gt; files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;File Size Limits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Each file must be no larger than 100 MB&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Files exceeding this limit are ignored during ingestion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PDF images, charts, and reference tables must not exceed 8 MB&lt;/strong&gt; within each PDF&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Bucket Restrictions:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Only one bucket is allowed per data source&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;However, you can use multiple data sources per knowledge base&lt;/li&gt;
&lt;li&gt;You can ingest up to 1,000 files from an OCI Object Storage bucket into a knowledge base&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;chart-and-table-guidelines&quot;&gt;Chart and Table Guidelines&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Charts:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;No special preparation is needed for charts as long as they're two-dimensional with labeled axes.&lt;/strong&gt; The model can answer questions about charts without explicit explanations.&lt;/p&gt;
&lt;p&gt;Requirements for optimal chart understanding:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Two-dimensional visualization&lt;/li&gt;
&lt;li&gt;Clearly labeled X and Y axes&lt;/li&gt;
&lt;li&gt;Legend (if multiple data series)&lt;/li&gt;
&lt;li&gt;Title or caption&lt;/li&gt;
&lt;li&gt;Size within 8 MB limit&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Tables:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use reference tables with several rows and columns.&lt;/strong&gt; For enhanced table understanding, ensure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;All cells separated with visible lines or object boundaries&lt;/li&gt;
&lt;li&gt;All columns including the first column have header names&lt;/li&gt;
&lt;li&gt;Each table has more than one column and more than one row (excluding headers)&lt;/li&gt;
&lt;li&gt;Tables use consistent formatting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example ingestion message:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Count of tables that support enhanced table understanding in following PDFs:
- 2025_Report1.pdf has 4 tables processed successfully
- 2025_Report2.pdf has 3 tables processed successfully
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;hyperlinks-and-urls&quot;&gt;Hyperlinks and URLs&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;All hyperlinks present in PDF documents are extracted and displayed as hyperlinks in chat responses.&lt;/strong&gt; This enables users to navigate directly to referenced resources without manual searching.&lt;/p&gt;
&lt;h4 id=&quot;planning-for-future-data&quot;&gt;Planning for Future Data&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;If data isn't yet available, create an empty folder for the data source and populate it later.&lt;/strong&gt; This allows you to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set up knowledge base infrastructure in advance&lt;/li&gt;
&lt;li&gt;Define data source connections&lt;/li&gt;
&lt;li&gt;Run ingestion jobs when content becomes available&lt;/li&gt;
&lt;li&gt;Maintain consistent agent configuration&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;advanced-features-march-2025-release-&quot;&gt;Advanced Features (March 2025 Release)&lt;/h3&gt;
&lt;p&gt;Oracle released significant enhancements to the RAG tool in March 2025 based on customer feedback.&lt;/p&gt;
&lt;h4 id=&quot;enhanced-response-quality&quot;&gt;Enhanced Response Quality&lt;/h4&gt;
&lt;p&gt;Improved accuracy by refining contextual understanding and relevance of generated answers through:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Better semantic understanding&lt;/li&gt;
&lt;li&gt;More precise context extraction&lt;/li&gt;
&lt;li&gt;Improved answer synthesis&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;hybrid-search&quot;&gt;Hybrid Search&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Combines keyword and vector search for highly precise, efficient retrieval.&lt;/strong&gt; Hybrid search uses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Keyword (BM25) search&lt;/strong&gt;: Exact term matching for specific terminology&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vector search&lt;/strong&gt;: Semantic similarity for conceptual matches&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fusion ranking&lt;/strong&gt;: Combining scores from both approaches&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This dual approach ensures agents find documents matching both semantic meaning and specific keywords.&lt;/p&gt;
&lt;h4 id=&quot;improved-multi-modal-parsing&quot;&gt;Improved Multi-Modal Parsing&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Extract insights from rich content formats such as images and charts.&lt;/strong&gt; Enhanced capabilities include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Image understanding within PDFs&lt;/li&gt;
&lt;li&gt;Chart data extraction&lt;/li&gt;
&lt;li&gt;Table structure recognition&lt;/li&gt;
&lt;li&gt;Diagram interpretation&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;custom-instructions&quot;&gt;Custom Instructions&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Define preferences to fine-tune behavior and response styles of the RAG tool.&lt;/strong&gt; Custom instructions enable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Setting agent personality and tone&lt;/li&gt;
&lt;li&gt;Defining response formats&lt;/li&gt;
&lt;li&gt;Establishing domain-specific terminology&lt;/li&gt;
&lt;li&gt;Configuring citation styles&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;multi-lingual-support&quot;&gt;Multi-Lingual Support&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Seamlessly interact across several languages&lt;/strong&gt;, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;French&lt;/li&gt;
&lt;li&gt;Spanish&lt;/li&gt;
&lt;li&gt;Portuguese&lt;/li&gt;
&lt;li&gt;Arabic&lt;/li&gt;
&lt;li&gt;German&lt;/li&gt;
&lt;li&gt;Italian&lt;/li&gt;
&lt;li&gt;Japanese&lt;/li&gt;
&lt;li&gt;English&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This enables global deployment with localized experiences.&lt;/p&gt;
&lt;h4 id=&quot;multiple-knowledge-bases&quot;&gt;Multiple Knowledge Bases&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;To help improve coverage and depth of knowledge, set up agents to retrieve information from several knowledge bases.&lt;/strong&gt; Benefits include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Specialized knowledge bases per domain&lt;/li&gt;
&lt;li&gt;Improved organization and maintenance&lt;/li&gt;
&lt;li&gt;Better access control&lt;/li&gt;
&lt;li&gt;Reduced search latency&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;metadata-ingestion-amp-filtering&quot;&gt;Metadata Ingestion &amp;amp; Filtering&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Use metadata to refine searches and categorize content more effectively.&lt;/strong&gt; Metadata filtering enables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Date-based filtering (e.g., &quot;documents from 2024&quot;)&lt;/li&gt;
&lt;li&gt;Department/category filtering&lt;/li&gt;
&lt;li&gt;Author-based retrieval&lt;/li&gt;
&lt;li&gt;Custom taxonomy support&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Users can apply metadata filters during chat conversations to narrow results.&lt;/p&gt;
&lt;h3 id=&quot;building-your-first-agent-step-by-step&quot;&gt;Building Your First Agent: Step-by-Step&lt;/h3&gt;
&lt;h4 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;OCI Account&lt;/strong&gt;: With appropriate IAM permissions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Identity Domain&lt;/strong&gt;: Required for agent creation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Region Subscription&lt;/strong&gt;: Chicago region (primary availability)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Object Storage Bucket&lt;/strong&gt;: With source documents uploaded&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;step-1-create-knowledge-base&quot;&gt;Step 1: Create Knowledge Base&lt;/h4&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Analytics &amp;amp; AI → Generative AI Agents → Knowledge Bases&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Create knowledge base&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Enter name (1-255 characters, start with letter or underscore)&lt;/li&gt;
&lt;li&gt;Select compartment&lt;/li&gt;
&lt;li&gt;Choose data store type (Object Storage, OpenSearch, or Database)&lt;/li&gt;
&lt;li&gt;Configure data source:&lt;ul&gt;
&lt;li&gt;Select Object Storage bucket&lt;/li&gt;
&lt;li&gt;Choose files or use prefixes&lt;/li&gt;
&lt;li&gt;Select &quot;Automatically start ingestion job&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;step-2-monitor-ingestion&quot;&gt;Step 2: Monitor Ingestion&lt;/h4&gt;
&lt;p&gt;The ingestion job automatically starts and processes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Document parsing&lt;/li&gt;
&lt;li&gt;Text extraction&lt;/li&gt;
&lt;li&gt;Chunking (512 tokens for OpenSearch)&lt;/li&gt;
&lt;li&gt;Embedding generation&lt;/li&gt;
&lt;li&gt;Vector indexing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Check ingestion logs to confirm success and view detailed status including number of ingested, ignored, and failed files.&lt;/p&gt;
&lt;h4 id=&quot;step-3-create-agent&quot;&gt;Step 3: Create Agent&lt;/h4&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Agents&lt;/strong&gt; page:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Create agent&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Enter agent name and description&lt;/li&gt;
&lt;li&gt;Select LLM (Command R+, Llama 4, etc.)&lt;/li&gt;
&lt;li&gt;Add RAG tool configuration:&lt;ul&gt;
&lt;li&gt;Select knowledge base(s)&lt;/li&gt;
&lt;li&gt;Configure custom instructions&lt;/li&gt;
&lt;li&gt;Set hybrid search options&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Enable content moderation (optional)&lt;/li&gt;
&lt;li&gt;Choose to create endpoint now or later&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;step-4-create-agent-endpoint&quot;&gt;Step 4: Create Agent Endpoint&lt;/h4&gt;
&lt;p&gt;If not created during agent setup:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to agent details&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create endpoint&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Enter endpoint name&lt;/li&gt;
&lt;li&gt;Select region&lt;/li&gt;
&lt;li&gt;Configure authentication&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Copy the endpoint OCID for API access.&lt;/p&gt;
&lt;h4 id=&quot;step-5-test-in-playground&quot;&gt;Step 5: Test in Playground&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Launch chat from agent or endpoint details page&lt;/li&gt;
&lt;li&gt;Select agent and endpoint&lt;/li&gt;
&lt;li&gt;Submit test queries&lt;/li&gt;
&lt;li&gt;Review responses and citations&lt;/li&gt;
&lt;li&gt;Verify knowledge base retrieval&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;step-6-integrate-via-api&quot;&gt;Step 6: Integrate via API&lt;/h4&gt;
&lt;p&gt;Use the REST API to integrate with applications:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import requests

endpoint_url = &quot;https://agent.generativeai.us-chicago-1.oci.oraclecloud.com/20240531/agentEndpoints/{endpoint_id}/actions/chat&quot;

payload = {
    &quot;message&quot;: &quot;What is our company policy on remote work?&quot;,
    &quot;sessionId&quot;: &quot;session-123&quot;,
    &quot;shouldStream&quot;: False
}

headers = {
    &quot;Content-Type&quot;: &quot;application/json&quot;,
    &quot;Authorization&quot;: &quot;Bearer &amp;lt;your_token&amp;gt;&quot;
}

response = requests.post(endpoint_url, json=payload, headers=headers)
agent_response = response.json()

print(agent_response['message'])
print(agent_response['citations'])
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;use-cases-for-oci-generative-ai-agents&quot;&gt;Use Cases for OCI Generative AI Agents&lt;/h3&gt;
&lt;h4 id=&quot;1-customer-support&quot;&gt;1. Customer Support&lt;/h4&gt;
&lt;p&gt;In the customer service industry, RAG agents retrieve information from a company's knowledge base to provide correct and contextually relevant answers to customer inquiries, reducing response times and improving customer satisfaction.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;24/7 availability&lt;/li&gt;
&lt;li&gt;Instant access to knowledge base&lt;/li&gt;
&lt;li&gt;Consistent responses&lt;/li&gt;
&lt;li&gt;Escalation to human agents when needed&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-legal-research&quot;&gt;2. Legal Research&lt;/h4&gt;
&lt;p&gt;Legal professionals can use RAG agents to quickly find precedents and relevant case law from vast legal databases, streamlining the research process and ensuring thorough consideration of relevant legal texts.&lt;/p&gt;
&lt;h4 id=&quot;3-healthcare-and-medical-guidance&quot;&gt;3. Healthcare and Medical Guidance&lt;/h4&gt;
&lt;p&gt;In healthcare, RAG agents help doctors and medical staff by providing diagnostic support, retrieving medical literature, treatment protocols, and patient history to suggest potential diagnoses and treatments.&lt;/p&gt;
&lt;h4 id=&quot;4-financial-analysis&quot;&gt;4. Financial Analysis&lt;/h4&gt;
&lt;p&gt;In finance, RAG agents analyze large volumes of financial data, reports, and news to provide analysis and recommendations for traders and analysts, helping them make informed decisions.&lt;/p&gt;
&lt;h4 id=&quot;5-travel-planning&quot;&gt;5. Travel Planning&lt;/h4&gt;
&lt;p&gt;In the travel industry, RAG agents serve as interactive travel guides, pulling information on destinations, weather, local attractions, and regulations to provide personalized travel advice and itineraries.&lt;/p&gt;
&lt;h4 id=&quot;6-hr-and-internal-knowledge&quot;&gt;6. HR and Internal Knowledge&lt;/h4&gt;
&lt;p&gt;Deploy agents for employee self-service:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Benefits information&lt;/li&gt;
&lt;li&gt;Policy questions&lt;/li&gt;
&lt;li&gt;Onboarding guidance&lt;/li&gt;
&lt;li&gt;Training materials&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;best-practices-for-production-agents&quot;&gt;Best Practices for Production Agents&lt;/h3&gt;
&lt;h4 id=&quot;1-organize-knowledge-bases-strategically&quot;&gt;1. Organize Knowledge Bases Strategically&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Create separate knowledge bases for different domains&lt;/li&gt;
&lt;li&gt;Use multiple data sources for comprehensive coverage&lt;/li&gt;
&lt;li&gt;Maintain clear naming conventions&lt;/li&gt;
&lt;li&gt;Document knowledge base purposes&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-optimize-document-preparation&quot;&gt;2. Optimize Document Preparation&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Keep files under 100 MB&lt;/li&gt;
&lt;li&gt;Ensure charts have clear labels and legends&lt;/li&gt;
&lt;li&gt;Format tables with proper headers&lt;/li&gt;
&lt;li&gt;Include descriptive filenames&lt;/li&gt;
&lt;li&gt;Add custom URLs for citation tracking&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;3-leverage-metadata-effectively&quot;&gt;3. Leverage Metadata Effectively&lt;/h4&gt;
&lt;p&gt;Tag documents with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Department/category&lt;/li&gt;
&lt;li&gt;Publication date&lt;/li&gt;
&lt;li&gt;Author&lt;/li&gt;
&lt;li&gt;Document type&lt;/li&gt;
&lt;li&gt;Sensitivity level&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;4-implement-content-moderation&quot;&gt;4. Implement Content Moderation&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Enable input and output filtering&lt;/li&gt;
&lt;li&gt;Define custom moderation rules&lt;/li&gt;
&lt;li&gt;Monitor flagged content&lt;/li&gt;
&lt;li&gt;Establish escalation procedures&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;5-monitor-and-iterate&quot;&gt;5. Monitor and Iterate&lt;/h4&gt;
&lt;p&gt;Track key metrics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Response accuracy&lt;/li&gt;
&lt;li&gt;Citation quality&lt;/li&gt;
&lt;li&gt;User satisfaction&lt;/li&gt;
&lt;li&gt;Query volume&lt;/li&gt;
&lt;li&gt;Latency&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;6-plan-for-scale&quot;&gt;6. Plan for Scale&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Request limit increases proactively (agents, knowledge bases, files)&lt;/li&gt;
&lt;li&gt;Implement caching for common queries&lt;/li&gt;
&lt;li&gt;Design for multi-region deployment&lt;/li&gt;
&lt;li&gt;Establish backup and recovery procedures&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;limitations-and-considerations&quot;&gt;Limitations and Considerations&lt;/h3&gt;
&lt;h4 id=&quot;regional-availability&quot;&gt;Regional Availability&lt;/h4&gt;
&lt;p&gt;As of early 2025, OCI Generative AI Agents is primarily available in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;US Midwest (Chicago)&lt;/strong&gt; - Primary region&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additional regions are planned for future release.&lt;/p&gt;
&lt;h4 id=&quot;resource-limits&quot;&gt;Resource Limits&lt;/h4&gt;
&lt;p&gt;Default limits per tenancy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;2 agents&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2 knowledge bases per agent&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;1,000 files per Object Storage data source&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Limits can be increased through service request.&lt;/p&gt;
&lt;h4 id=&quot;file-type-restrictions&quot;&gt;File Type Restrictions&lt;/h4&gt;
&lt;p&gt;Supported formats are limited to PDF, TXT, JSON, HTML, and Markdown. Other formats (DOCX, XLSX, PPTX) require conversion before upload.&lt;/p&gt;
&lt;h3 id=&quot;security-and-compliance&quot;&gt;Security and Compliance&lt;/h3&gt;
&lt;h4 id=&quot;data-privacy&quot;&gt;Data Privacy&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Data remains within your tenancy&lt;/li&gt;
&lt;li&gt;No training on customer data&lt;/li&gt;
&lt;li&gt;Encryption at rest and in transit&lt;/li&gt;
&lt;li&gt;Access controlled via IAM policies&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;enterprise-features&quot;&gt;Enterprise Features&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;RBAC&lt;/strong&gt;: Fine-grained access control&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Audit Logging&lt;/strong&gt;: Complete activity trails&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Content Moderation&lt;/strong&gt;: Built-in safety controls&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Citation Tracking&lt;/strong&gt;: Source attribution for all responses&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;OCI Generative AI Agents democratizes enterprise AI by providing a fully managed, no-code platform for building production-grade RAG applications. Key advantages include:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ease of Use:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No coding required for basic setup&lt;/li&gt;
&lt;li&gt;Visual interface for configuration&lt;/li&gt;
&lt;li&gt;Automated ingestion and indexing&lt;/li&gt;
&lt;li&gt;Built-in testing playground&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Enterprise Features:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Multiple knowledge base support&lt;/li&gt;
&lt;li&gt;Hybrid search capabilities&lt;/li&gt;
&lt;li&gt;Multi-lingual support&lt;/li&gt;
&lt;li&gt;Content moderation&lt;/li&gt;
&lt;li&gt;Source attribution&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Flexibility:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Support for various data sources&lt;/li&gt;
&lt;li&gt;Custom instructions&lt;/li&gt;
&lt;li&gt;Metadata filtering&lt;/li&gt;
&lt;li&gt;API and chat interfaces&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fully managed service&lt;/li&gt;
&lt;li&gt;Enterprise-grade security&lt;/li&gt;
&lt;li&gt;Compliance ready&lt;/li&gt;
&lt;li&gt;Oracle infrastructure reliability&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By following the guidelines for Object Storage (100 MB file limit, supported formats, chart/table preparation), leveraging advanced features (hybrid search, multi-modal parsing, metadata filtering), and implementing best practices, organizations can deploy sophisticated AI agents that deliver accurate, grounded, and trustworthy responses to users.&lt;/p&gt;
&lt;p&gt;Whether you're building customer support chatbots, internal knowledge assistants, or specialized research tools, OCI Generative AI Agents provides the foundation for enterprise-grade AI applications—without the complexity of traditional RAG implementations.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/10334/oci-generative-ai-agents-building-enterprise-rag-applications-without-code</guid>
<pubDate>Fri, 23 Jan 2026 07:51:18 +0000</pubDate>
</item>
<item>
<title>OCI Generative AI and LangChain: Building Enterprise AI Applications with Oracle</title>
<link>https://coderlegion.com/10026/oci-generative-ai-and-langchain-building-enterprise-ai-applications-with-oracle</link>
<description>&lt;p&gt;Integrating Oracle Cloud Infrastructure (OCI) Generative AI with LangChain unlocks powerful capabilities for building enterprise-grade AI applications. This comprehensive guide explores the official integration, demonstrates practical implementations, and shows how Oracle Database 23ai complements LangChain workflows for complete end-to-end AI solutions.&lt;/p&gt;
&lt;h3 id=&quot;what-is-langchain-&quot;&gt;What is LangChain?&lt;/h3&gt;
&lt;p&gt;LangChain is a powerful, open-source framework for developing applications powered by large language models (LLMs). It provides essential tools for managing workflows, maintaining context, and integrating with external systems, streamlining the development of AI-powered applications.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Capabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;LangChain acts as a bridge, connecting LLMs with other data sources and tools, dramatically simplifying application development. The framework enables developers to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Build chatbots and conversational AI&lt;/li&gt;
&lt;li&gt;Create autonomous agents&lt;/li&gt;
&lt;li&gt;Implement Retrieval-Augmented Generation (RAG) workflows&lt;/li&gt;
&lt;li&gt;Manage prompt templates and chains&lt;/li&gt;
&lt;li&gt;Maintain conversation memory&lt;/li&gt;
&lt;li&gt;Integrate with vector databases and external APIs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Language Support:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;LangChain primarily supports Python but also has libraries for JavaScript, TypeScript, and Java (through LangChain4j).&lt;/p&gt;
&lt;h3 id=&quot;oci-generative-ai-integration-with-langchain&quot;&gt;OCI Generative AI Integration with LangChain&lt;/h3&gt;
&lt;p&gt;Oracle Cloud Infrastructure Generative AI has an official integration with LangChain, providing native support through wrapper classes that make OCI's LLMs and embedding models easily accessible within LangChain applications.&lt;/p&gt;
&lt;h4 id=&quot;the-official-langchain-oci-package&quot;&gt;The Official langchain-oci Package&lt;/h4&gt;
&lt;p&gt;As of 2025, Oracle maintains the official &lt;code&gt;langchain-oci&lt;/code&gt; package that replaces the earlier community integrations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Important Migration Note:&lt;/strong&gt; The OCI integrations available in langchain-community are now deprecated. All future development, bug fixes, and feature enhancements are hosted in the new langchain-oci package.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install langchain-oci
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This package provides:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ChatOCIGenAI&lt;/strong&gt;: Chat models from OCI Generative AI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCIGenAI&lt;/strong&gt;: Text generation from OCI Generative AI  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCIGenAIEmbeddings&lt;/strong&gt;: Embedding models from OCI Generative AI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ChatOCIModelDeployment&lt;/strong&gt;: Integration with OCI Data Science model endpoints&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Oracle AI Vector Search&lt;/strong&gt;: Native vector store integration&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;available-model-classes&quot;&gt;Available Model Classes&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;1. ChatOCIGenAI - Conversational AI&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The primary class for building chat applications with OCI Generative AI models.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_oci import ChatOCIGenAI

llm = ChatOCIGenAI(
    model_id=&quot;meta.llama-4-maverick-17b-128e-instruct-fp8&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;MY_COMPARTMENT_ID&quot;,
    model_kwargs={&quot;temperature&quot;: 0, &quot;max_tokens&quot;: 500},
    auth_profile=&quot;MY_AUTH_PROFILE&quot;,
    is_stream=True
)

response = llm.invoke(&quot;Sing a ballad of LangChain.&quot;)
print(response.content)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Supported Features:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Multi-turn conversations with context retention&lt;/li&gt;
&lt;li&gt;Streaming responses for real-time output&lt;/li&gt;
&lt;li&gt;Structured output generation&lt;/li&gt;
&lt;li&gt;Tool calling and function execution&lt;/li&gt;
&lt;li&gt;Parallel tool calling (Llama 4+ models only)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;2. OCIGenAI - Text Generation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For simpler text generation tasks without conversational context.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_oci import OCIGenAI

llm = OCIGenAI()
response = llm.invoke(&quot;The meaning of life is&quot;)
print(response)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;3. OCIGenAIEmbeddings - Vector Representations&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Convert text into semantic embeddings for similarity search and RAG applications.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_oci import OCIGenAIEmbeddings

embeddings = OCIGenAIEmbeddings(
    model_id=&quot;cohere.embed-v4.0&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;compartment_id&quot;
)

# Single query embedding
query = &quot;This is a query in English.&quot;
response = embeddings.embed_query(query)

# Multiple document embeddings
documents = [&quot;This is a sample document&quot;, &quot;and here is another one&quot;]
response = embeddings.embed_documents(documents)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Authentication Methods:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;LangChain OCI integration supports standard SDK authentication:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;API Key (default)&lt;/li&gt;
&lt;li&gt;Security Token&lt;/li&gt;
&lt;li&gt;Instance Principal&lt;/li&gt;
&lt;li&gt;Resource Principal&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;advanced-features&quot;&gt;Advanced Features&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Structured Output:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ChatOCIGenAI supports structured output generation using function calling, JSON schema, or JSON mode.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_oci import ChatOCIGenAI

llm = ChatOCIGenAI(
    model_id=&quot;meta.llama-4-maverick-17b-128e-instruct-fp8&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;MY_COMPARTMENT_ID&quot;
)

# Define your structured output schema
structured_llm = llm.with_structured_output(YourSchema)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Parallel Tool Calling:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Llama 4+ models support parallel tool calling, allowing multiple tools to execute simultaneously.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;llm_with_tools = llm.bind_tools(
    [get_weather, calculate_tip, get_population],
    parallel_tool_calls=True  # Tools can execute simultaneously
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note: Llama 3.x (including 3.3) and Cohere models will raise an error if parallel tool calling is used.&lt;/p&gt;
&lt;h3 id=&quot;langchain-prompt-templates&quot;&gt;LangChain Prompt Templates&lt;/h3&gt;
&lt;p&gt;LangChain prompts can be created using two types of prompt templates, each optimized for different use cases.&lt;/p&gt;
&lt;h4 id=&quot;1-string-prompt-template&quot;&gt;1. String Prompt Template&lt;/h4&gt;
&lt;p&gt;Outputs a simple string, ideal for basic text generation tasks.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_core.prompts import PromptTemplate

template = &quot;&quot;&quot;
You are a helpful assistant. Translate the following text to French:
{text}
&quot;&quot;&quot;

prompt = PromptTemplate.from_template(template)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;2-chat-prompt-template&quot;&gt;2. Chat Prompt Template&lt;/h4&gt;
&lt;p&gt;Supports a list of messages with different roles (system, user, assistant), perfect for conversational AI.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_core.prompts import ChatPromptTemplate

template = ChatPromptTemplate.from_messages([
    (&quot;system&quot;, &quot;You are a helpful assistant specialized in {domain}.&quot;),
    (&quot;user&quot;, &quot;{question}&quot;)
])

prompt = template.invoke({
    &quot;domain&quot;: &quot;Italian cuisine&quot;,
    &quot;question&quot;: &quot;What are the best ingredients for carbonara?&quot;
})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Message Types:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;System messages&lt;/strong&gt;: Set behavior and context&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User messages&lt;/strong&gt;: User queries and inputs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assistant messages&lt;/strong&gt;: Previous AI responses (for context)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Function messages&lt;/strong&gt;: Tool/function call results&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;creating-chains-with-lcel&quot;&gt;Creating Chains with LCEL&lt;/h3&gt;
&lt;p&gt;LangChain Expression Language (LCEL) enables declarative chain creation, offering a more concise and composable approach than traditional Python classes.&lt;/p&gt;
&lt;h4 id=&quot;declarative-chains-with-lcel&quot;&gt;Declarative Chains with LCEL&lt;/h4&gt;
&lt;p&gt;LCEL uses the pipe operator (&lt;code&gt;|&lt;/code&gt;) to chain components together.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_oci import ChatOCIGenAI

# Define components
prompt = ChatPromptTemplate.from_template(
    &quot;If the text is a question, first translate the question and then &quot;
    &quot;answer the question in French.: {text}&quot;
)

llm = ChatOCIGenAI(
    model_id=&quot;meta.llama-4-scout-17b-16e-instruct&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;&amp;lt;sandbox-compartment&amp;gt;&quot;,
    model_kwargs={&quot;temperature&quot;: 0, &quot;max_tokens&quot;: 500}
)

output_parser = StrOutputParser()

# Create chain using LCEL
chain = prompt | llm | output_parser

# Execute chain
result = chain.invoke({&quot;text&quot;: &quot;What are the four seasons in a year?&quot;})
print(result)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;La traduction de la question est : Quelles sont les quatre saisons dans une année?
Les quatre saisons dans une année sont : le printemps, l'été, l'automne et l'hiver.
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;traditional-python-classes&quot;&gt;Traditional Python Classes&lt;/h4&gt;
&lt;p&gt;Alternatively, use Python classes like &lt;code&gt;LLMChain&lt;/code&gt; for explicit chain construction.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.chains import LLMChain
from langchain_core.prompts import PromptTemplate
from langchain_oci import ChatOCIGenAI

llm = ChatOCIGenAI(model_id=&quot;meta.llama-4-scout-17b-16e-instruct&quot;, ...)
prompt = PromptTemplate.from_template(&quot;Translate to French: {text}&quot;)

chain = LLMChain(llm=llm, prompt=prompt)
result = chain.run(text=&quot;Hello, world!&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;LCEL vs Python Classes:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;LCEL&lt;/strong&gt;: More concise, composable, modern approach (recommended)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python Classes&lt;/strong&gt;: More explicit, traditional, verbose&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;langchain-memory-maintaining-conversation-context&quot;&gt;LangChain Memory: Maintaining Conversation Context&lt;/h3&gt;
&lt;p&gt;LangChain memory provides the ability to store information about past interactions, crucial for building conversational applications.&lt;/p&gt;
&lt;h4 id=&quot;memory-types&quot;&gt;Memory Types&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Conversation Buffer Memory:&lt;/strong&gt;&lt;br&gt;
Stores the entire conversation history.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.memory import ConversationBufferMemory

memory = ConversationBufferMemory()
memory.save_context({&quot;input&quot;: &quot;Hi&quot;}, {&quot;output&quot;: &quot;Hello! How can I help?&quot;})
memory.save_context({&quot;input&quot;: &quot;What's the weather?&quot;}, {&quot;output&quot;: &quot;It's sunny!&quot;})

print(memory.load_memory_variables({}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Conversation Buffer Window Memory:&lt;/strong&gt;&lt;br&gt;
Maintains only the last K interactions to manage token limits.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.memory import ConversationBufferWindowMemory

memory = ConversationBufferWindowMemory(k=2)  # Keep last 2 exchanges
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Conversation Summary Memory:&lt;/strong&gt;&lt;br&gt;
Uses an LLM to summarize conversation history, maintaining context while reducing tokens.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.memory import ConversationSummaryMemory

memory = ConversationSummaryMemory(llm=llm)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;oracle-database-23ai-as-a-vector-store&quot;&gt;Oracle Database 23ai as a Vector Store&lt;/h3&gt;
&lt;p&gt;Oracle Database 23ai can be used as a powerful vector store to generate and manage embeddings, seamlessly integrating with LangChain for RAG applications.&lt;/p&gt;
&lt;h4 id=&quot;why-oracle-database-23ai-for-vector-storage-&quot;&gt;Why Oracle Database 23ai for Vector Storage?&lt;/h4&gt;
&lt;p&gt;Oracle Database 23ai supports native AI Vector Search, enabling:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Semantic similarity search&lt;/strong&gt; on text, documents, images, and unstructured data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combined relational and vector queries&lt;/strong&gt; in a single system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pre-filtering, in-filtering, and post-filtering&lt;/strong&gt; for enhanced search capabilities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple distance metrics&lt;/strong&gt;: Cosine, Euclidean, dot product&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HNSW indexing&lt;/strong&gt; for high-performance similarity search&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integration with existing enterprise data&lt;/strong&gt; without data duplication&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;langchain-oracle-vector-store-integration&quot;&gt;LangChain Oracle Vector Store Integration&lt;/h4&gt;
&lt;p&gt;Oracle AI Vector Search integrates with LangChain at various levels, providing document loaders, text splitters, embeddings, and vector stores.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install langchain-oracle
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Basic Vector Store Usage:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_community.vectorstores import OracleVS
from langchain_oracle.embeddings import OCIGenAIEmbeddings
from langchain.schema import Document
import oracledb

# Connect to Oracle Database 23ai
conn = oracledb.connect(
    user=&quot;username&quot;,
    password=&quot;password&quot;,
    dsn=&quot;localhost/FREEPDB1&quot;
)

# Create embedding model
embeddings = OCIGenAIEmbeddings(
    model_id=&quot;cohere.embed-v4.0&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;compartment_id&quot;
)

# Prepare documents
documents = [
    Document(
        page_content=&quot;LangChain is a framework for LLM applications&quot;,
        metadata={&quot;id&quot;: &quot;doc1&quot;, &quot;source&quot;: &quot;documentation&quot;}
    ),
    Document(
        page_content=&quot;Oracle Database 23ai supports vector search natively&quot;,
        metadata={&quot;id&quot;: &quot;doc2&quot;, &quot;source&quot;: &quot;announcement&quot;}
    )
]

# Create vector store
vector_store = OracleVS.from_documents(
    documents,
    embeddings,
    client=conn,
    table_name=&quot;LANGCHAIN_VECTORS&quot;,
    distance_strategy=DistanceStrategy.COSINE
)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;creating-hnsw-index-for-performance&quot;&gt;Creating HNSW Index for Performance&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import oraclevs

oraclevs.create_index(
    conn,
    vector_store,
    params={
        &quot;idx_name&quot;: &quot;hnsw_idx1&quot;,
        &quot;idx_type&quot;: &quot;HNSW&quot;,
        &quot;accuracy&quot;: 97,  # Target accuracy percentage
        &quot;parallel&quot;: 8     # Number of parallel workers
    }
)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;similarity-search&quot;&gt;Similarity Search&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Perform similarity search
query = &quot;What is LangChain?&quot;
results = vector_store.similarity_search(query, k=3)

for doc in results:
    print(f&quot;Content: {doc.page_content}&quot;)
    print(f&quot;Metadata: {doc.metadata}\n&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;accessing-oci-generative-ai-from-oracle-database&quot;&gt;Accessing OCI Generative AI from Oracle Database&lt;/h3&gt;
&lt;p&gt;Oracle Database 23ai can directly access OCI Generative AI services through built-in APIs and Select AI capabilities.&lt;/p&gt;
&lt;h4 id=&quot;using-dbms-cloud-for-rest-api-access&quot;&gt;Using DBMS_CLOUD for REST API Access&lt;/h4&gt;
&lt;p&gt;You can access OCI Generative AI service using the &lt;code&gt;DBMS_CLOUD&lt;/code&gt; REST API directly from SQL.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;-- Create credential for OCI authentication
BEGIN
  DBMS_CLOUD.CREATE_CREDENTIAL(
    credential_name =&amp;gt; 'OCI_CRED',
    username =&amp;gt; 'ocid1.user.oc1...',
    password =&amp;gt; '&amp;lt;your-auth-token&amp;gt;'
  );
END;
/

-- Call OCI Generative AI endpoint
DECLARE
  l_response CLOB;
BEGIN
  l_response := DBMS_CLOUD.SEND_REQUEST(
    credential_name =&amp;gt; 'OCI_CRED',
    uri =&amp;gt; 'https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/...',
    method =&amp;gt; 'POST',
    body =&amp;gt; '{
      &quot;model&quot;: &quot;cohere.command-r-plus&quot;,
      &quot;prompt&quot;: &quot;Explain quantum computing&quot;,
      &quot;max_tokens&quot;: 500
    }'
  );
  
  DBMS_OUTPUT.PUT_LINE(l_response);
END;
/
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;select-ai-natural-language-to-sql&quot;&gt;Select AI: Natural Language to SQL&lt;/h3&gt;
&lt;p&gt;Select AI enables SQL access to generative AI using Large Language Models (LLMs) and embedding models, including support for natural language to SQL query generation and retrieval-augmented generation.&lt;/p&gt;
&lt;h4 id=&quot;how-select-ai-works&quot;&gt;How Select AI Works&lt;/h4&gt;
&lt;p&gt;Select AI translates natural language questions into SQL queries that the database understands, then uses LLMs trained to infer user intent to interpret queries and return desired answers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Capabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Select AI automatically builds and maintains a vector index using metadata for applicable objects in your schema, using semantic similarity search to choose the most relevant objects based on user prompts.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Natural language to SQL (NL2SQL / text-to-SQL)&lt;/strong&gt; query generation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automatic metadata augmentation&lt;/strong&gt; with table/column comments, constraints, annotations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Semantic similarity search&lt;/strong&gt; to select relevant schema objects&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RAG support&lt;/strong&gt; for context-augmented responses&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-dialect support&lt;/strong&gt; including Oracle SQL and SQLite&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;setting-up-select-ai&quot;&gt;Setting Up Select AI&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;-- Create credential for LLM provider
BEGIN
  DBMS_CLOUD.CREATE_CREDENTIAL(
    credential_name =&amp;gt; 'COHERE_CRED',
    username =&amp;gt; 'COHERE',
    password =&amp;gt; '&amp;lt;your-api-key&amp;gt;'
  );
END;
/

-- Create AI profile
BEGIN
  DBMS_CLOUD_AI.CREATE_PROFILE(
    profile_name =&amp;gt; 'COHERE',
    attributes =&amp;gt; '{
      &quot;provider&quot;: &quot;cohere&quot;,
      &quot;credential_name&quot;: &quot;COHERE_CRED&quot;,
      &quot;model&quot;: &quot;cohere.command-a-03-2025&quot;,
      &quot;object_list&quot;: [{&quot;owner&quot;: &quot;ADB_USER&quot;}],
      &quot;max_tokens&quot;: 512,
      &quot;temperature&quot;: 0.5,
      &quot;comments&quot;: true,
      &quot;constraints&quot;: true
    }'
  );
END;
/
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;using-select-ai&quot;&gt;Using Select AI&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Run SQL from Natural Language:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT AI What are the top 5 products by revenue this quarter?;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Show Generated SQL:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT AI showsql What are the top 5 products by revenue this quarter?;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Explain SQL in Natural Language:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT AI explainsql SELECT * FROM sales WHERE region = 'West';
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Chat Mode:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT AI chat Who won the 2024 World Series?;
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;select-ai-with-rag&quot;&gt;Select AI with RAG&lt;/h4&gt;
&lt;p&gt;Select AI supports RAG using Oracle AI Vector Search, integrating vector database content to deliver more accurate results from LLMs through semantic similarity search.&lt;/p&gt;
&lt;p&gt;Select AI RAG automates the orchestration steps of transforming prompts into vectors and performing semantic similarity search on vector database content, making it easy to use LLMs with your private data using natural language prompts.&lt;/p&gt;
&lt;h3 id=&quot;complete-rag-application-example&quot;&gt;Complete RAG Application Example&lt;/h3&gt;
&lt;p&gt;Here's a complete example combining OCI Generative AI, LangChain, and Oracle Database 23ai:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain_oci import ChatOCIGenAI, OCIGenAIEmbeddings
from langchain_community.vectorstores import OracleVS
from langchain_core.prompts import ChatPromptTemplate
from langchain.schema import Document
from langchain_core.output_parsers import StrOutputParser
import oracledb

# 1. Connect to Oracle Database 23ai
conn = oracledb.connect(
    user=&quot;username&quot;,
    password=&quot;password&quot;,
    dsn=&quot;localhost/FREEPDB1&quot;
)

# 2. Initialize embedding model
embeddings = OCIGenAIEmbeddings(
    model_id=&quot;cohere.embed-v4.0&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;compartment_id&quot;
)

# 3. Load documents into vector store
documents = [
    Document(page_content=&quot;Your document content here&quot;, metadata={&quot;source&quot;: &quot;doc1&quot;}),
    # ... more documents
]

vector_store = OracleVS.from_documents(
    documents,
    embeddings,
    client=conn,
    table_name=&quot;KNOWLEDGE_BASE&quot;
)

# 4. Initialize LLM
llm = ChatOCIGenAI(
    model_id=&quot;meta.llama-4-scout-17b-16e-instruct&quot;,
    service_endpoint=&quot;https://inference.generativeai.us-chicago-1.oci.oraclecloud.com&quot;,
    compartment_id=&quot;compartment_id&quot;,
    model_kwargs={&quot;temperature&quot;: 0.3, &quot;max_tokens&quot;: 1000}
)

# 5. Create RAG chain
template = &quot;&quot;&quot;
Answer the question based on the following context:

Context: {context}

Question: {question}

Answer:
&quot;&quot;&quot;

prompt = ChatPromptTemplate.from_template(template)

# 6. Query function
def ask_question(question: str):
    # Retrieve relevant documents
    docs = vector_store.similarity_search(question, k=3)
    context = &quot;\n\n&quot;.join([doc.page_content for doc in docs])
    
    # Create and execute chain
    chain = prompt | llm | StrOutputParser()
    response = chain.invoke({&quot;context&quot;: context, &quot;question&quot;: question})
    
    return response

# 7. Use the RAG system
answer = ask_question(&quot;What are the benefits of Oracle Database 23ai?&quot;)
print(answer)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;best-practices-for-oci-langchain-applications&quot;&gt;Best Practices for OCI + LangChain Applications&lt;/h3&gt;
&lt;h4 id=&quot;1-choose-the-right-components&quot;&gt;1. Choose the Right Components&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ChatOCIGenAI&lt;/strong&gt; for conversational applications&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCIGenAI&lt;/strong&gt; for simple text generation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCIGenAIEmbeddings&lt;/strong&gt; for semantic search and RAG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Oracle Database 23ai&lt;/strong&gt; as vector store for enterprise data&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-optimize-embedding-storage&quot;&gt;2. Optimize Embedding Storage&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Use appropriate distance metrics (cosine for text similarity)&lt;/li&gt;
&lt;li&gt;Create HNSW indexes for large datasets&lt;/li&gt;
&lt;li&gt;Leverage metadata filtering for refined searches&lt;/li&gt;
&lt;li&gt;Batch document processing for efficiency&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;3-manage-memory-effectively&quot;&gt;3. Manage Memory Effectively&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Use ConversationBufferWindowMemory for long conversations&lt;/li&gt;
&lt;li&gt;Implement ConversationSummaryMemory for token efficiency&lt;/li&gt;
&lt;li&gt;Clear memory when starting new conversation threads&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;4-leverage-lcel-for-composability&quot;&gt;4. Leverage LCEL for Composability&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Build modular, reusable chains&lt;/li&gt;
&lt;li&gt;Combine multiple chains for complex workflows&lt;/li&gt;
&lt;li&gt;Use parallel execution where appropriate&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;5-implement-proper-error-handling&quot;&gt;5. Implement Proper Error Handling&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;try:
    response = chain.invoke(input_data)
except Exception as e:
    logging.error(f&quot;Chain execution failed: {e}&quot;)
    # Implement fallback behavior
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;6-monitor-and-optimize-costs&quot;&gt;6. Monitor and Optimize Costs&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Cache frequently accessed embeddings&lt;/li&gt;
&lt;li&gt;Use appropriate model sizes (Scout vs Maverick)&lt;/li&gt;
&lt;li&gt;Implement rate limiting for user requests&lt;/li&gt;
&lt;li&gt;Monitor token usage across applications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The integration of OCI Generative AI with LangChain provides a powerful, enterprise-ready platform for building AI applications. Key takeaways:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Official Integration:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;langchain-oci package provides native support for OCI Generative AI&lt;/li&gt;
&lt;li&gt;Supports chat models, text generation, and embeddings&lt;/li&gt;
&lt;li&gt;Compatible with OCI Data Science model deployments&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Prompt Engineering:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;String and Chat prompt templates for different use cases&lt;/li&gt;
&lt;li&gt;LCEL for declarative chain creation&lt;/li&gt;
&lt;li&gt;Memory management for conversational context&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Oracle Database 23ai:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Native vector store with LangChain integration&lt;/li&gt;
&lt;li&gt;Combines relational and vector search in one system&lt;/li&gt;
&lt;li&gt;Select AI for natural language to SQL generation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Complete AI Stack:&lt;/strong&gt;&lt;br&gt;
By combining OCI Generative AI (LLMs + embeddings), LangChain (orchestration), and Oracle Database 23ai (vector store + Select AI), you can build sophisticated RAG applications, conversational agents, and enterprise AI solutions with security, scalability, and performance.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/10026/oci-generative-ai-and-langchain-building-enterprise-ai-applications-with-oracle</guid>
<pubDate>Mon, 19 Jan 2026 17:14:03 +0000</pubDate>
</item>
<item>
<title>OCI Generative AI Security: Dedicated GPUs, RDMA Networks, and Enterprise-Grade Data Protection</title>
<link>https://coderlegion.com/9917/oci-generative-security-dedicated-gpus-rdma-networks-enterprise-grade-data-protection</link>
<description>&lt;p&gt;Security and privacy of customer workloads is an essential design tenet for Oracle Cloud Infrastructure (OCI) Generative AI. In an era where data breaches and AI security vulnerabilities dominate headlines, OCI has architected a comprehensive security framework that ensures enterprise-grade protection for AI workloads. This deep dive explores the multi-layered security approach that makes OCI Generative AI one of the most secure platforms for enterprise AI deployments.&lt;/p&gt;
&lt;h3 id=&quot;the-foundation-gpu-isolation-and-dedicated-infrastructure&quot;&gt;The Foundation: GPU Isolation and Dedicated Infrastructure&lt;/h3&gt;
&lt;h4 id=&quot;dedicated-gpu-allocation&quot;&gt;Dedicated GPU Allocation&lt;/h4&gt;
&lt;p&gt;GPUs allocated for a customer's generative AI tasks are pooled within a dedicated RDMA network, ensuring they are exclusively allocated to a single customer and not shared with others. This fundamental isolation guarantees that customer data remains secure and inaccessible to unauthorized parties.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Isolation Characteristics:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Physical Separation:&lt;/strong&gt; Each customer's GPU cluster operates on dedicated hardware, preventing any cross-contamination or data leakage between tenants.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Network Isolation:&lt;/strong&gt; RDMA cluster networks with less than 10 microsecond latency provide ultra-high-bandwidth connections (1.6 TB/sec internode bandwidth) while maintaining complete isolation from other customers' workloads.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Compute Isolation:&lt;/strong&gt; OCI Supercluster can deploy up to 32,768 GPUs per cluster, all dedicated to a single customer with no sharing of computational resources.&lt;/p&gt;
&lt;h4 id=&quot;rdma-network-architecture&quot;&gt;RDMA Network Architecture&lt;/h4&gt;
&lt;p&gt;Remote Direct Memory Access (RDMA) is a critical component of OCI's AI infrastructure, providing both performance and security benefits.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;RDMA Technology Overview:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;RDMA allows for low-latency connections between nodes and access to GPU memory without involving the CPU. This technology enables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ultra-Low Latency:&lt;/strong&gt; Less than 10 microseconds between nodes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;High Bandwidth:&lt;/strong&gt; 1.6 TB/sec internode bandwidth for massive data transfers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CPU Offload:&lt;/strong&gt; Direct memory-to-memory transfers without CPU intervention&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security:&lt;/strong&gt; Dedicated network fabric preventing cross-tenant access&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Network Types:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OCI's cluster network uses RDMA over Converged Ethernet Version 2 (RoCE v2) on top of NVIDIA ConnectX-7 network interface cards (NICs) to support high-throughput and latency-sensitive workloads.&lt;/p&gt;
&lt;p&gt;For advanced deployments, OCI utilizes NVIDIA Quantum InfiniBand or NVIDIA Spectrum-X Ethernet with RDMA over Converged Ethernet (RoCE) configuration.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scale and Performance:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OCI enables customers to cluster up to 4,096 bare metal nodes, each with 8 GPUs, totaling up to 32,768 GPUs. The latest infrastructure scales even further—zettascale OCI Supercluster scales up to 131,072 GPUs, making it the largest hyperscale AI supercomputer in the cloud.&lt;/p&gt;
&lt;h4 id=&quot;hardware-security-modules-hsm-&quot;&gt;Hardware Security Modules (HSM)&lt;/h4&gt;
&lt;p&gt;Keys are stored on Hardware Security Modules (HSMs) that meet Federal Information Processing Standards (FIPS) 140-2 Security Level 3 security certification.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HSM Protection Modes:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Software Protection:&lt;/strong&gt; Keys stored and processed on servers, recommended for most use cases with strong encryption.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HSM Protection:&lt;/strong&gt; Keys stored on HSMs meeting FIPS 140-2 Security Level 3 certification, recommended for stringent compliance requirements like financial services and healthcare.&lt;/p&gt;
&lt;h3 id=&quot;model-endpoint-security&quot;&gt;Model Endpoint Security&lt;/h3&gt;
&lt;h4 id=&quot;single-customer-model-endpoints&quot;&gt;Single-Customer Model Endpoints&lt;/h4&gt;
&lt;p&gt;For strong data privacy and security, a dedicated GPU cluster only handles fine-tuned models for a single customer. This architectural decision ensures:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Data Isolation:&lt;/strong&gt; No model from one customer processes data from another customer&lt;br&gt;
&lt;strong&gt;Performance Isolation:&lt;/strong&gt; Resources allocated exclusively for your workloads&lt;br&gt;
&lt;strong&gt;Compliance:&lt;/strong&gt; Easier to meet regulatory requirements with clear tenant boundaries&lt;br&gt;
&lt;strong&gt;Security Boundaries:&lt;/strong&gt; Physical and logical separation of processing environments&lt;/p&gt;
&lt;h4 id=&quot;endpoint-access-control&quot;&gt;Endpoint Access Control&lt;/h4&gt;
&lt;p&gt;Model endpoints implement multiple layers of access control:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Authentication:&lt;/strong&gt; API keys, OAuth tokens, or IAM credentials required for all requests&lt;br&gt;
&lt;strong&gt;Authorization:&lt;/strong&gt; Role-Based Access Control (RBAC) determines what actions authenticated users can perform&lt;br&gt;
&lt;strong&gt;Network Security:&lt;/strong&gt; Private endpoints within Virtual Cloud Networks (VCNs), with optional public access through controlled ingress&lt;br&gt;
&lt;strong&gt;Rate Limiting:&lt;/strong&gt; Configurable throttling to prevent abuse and ensure fair resource allocation&lt;/p&gt;
&lt;h3 id=&quot;customer-data-and-model-isolation&quot;&gt;Customer Data and Model Isolation&lt;/h3&gt;
&lt;h4 id=&quot;tenancy-level-isolation&quot;&gt;Tenancy-Level Isolation&lt;/h4&gt;
&lt;p&gt;Customer data access is restricted within a customer's tenancy so that one customer's data cannot be seen by another customer. This fundamental principle manifests across multiple dimensions:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Compartment Isolation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OCI uses compartments to organize and isolate resources. The architecture implements compartmentalization and private subnets to isolate different operational environments.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Best Practice:&lt;/strong&gt; Create separate compartments for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Development environments&lt;/li&gt;
&lt;li&gt;Staging/testing&lt;/li&gt;
&lt;li&gt;Production workloads&lt;/li&gt;
&lt;li&gt;Different business units or projects&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Data Separation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Training data, fine-tuned model weights, embeddings, and inference logs are all stored within customer-controlled storage with strict access controls preventing cross-tenant access.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Workload Isolation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A single NVIDIA GB200 NVL72 rack can be configured to launch multiple NVLink groupings for smaller workloads and provide strong isolation for efficient workload distribution.&lt;/p&gt;
&lt;h4 id=&quot;network-level-isolation&quot;&gt;Network-Level Isolation&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Private Subnets:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Resources deployed in private subnets within VCNs, preventing direct internet access unless explicitly configured.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Security Lists and Network Security Groups (NSGs):&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Stateful firewalls controlling inbound and outbound traffic at the subnet and network interface level.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Service Gateway and NAT Gateway:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Controlled access to Oracle services and internet resources without exposing instances to inbound internet traffic.&lt;/p&gt;
&lt;h3 id=&quot;integrated-oci-security-services&quot;&gt;Integrated OCI Security Services&lt;/h3&gt;
&lt;p&gt;OCI Generative AI leverages Oracle's comprehensive security ecosystem to provide defense-in-depth.&lt;/p&gt;
&lt;h4 id=&quot;oci-identity-and-access-management-iam-&quot;&gt;OCI Identity and Access Management (IAM)&lt;/h4&gt;
&lt;p&gt;IAM provides the foundation for authentication and authorization across all OCI services.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key IAM Capabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;User and Group Management:&lt;/strong&gt; Create users, organize them into groups, and assign permissions based on job functions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Policies:&lt;/strong&gt; Stringent access controls using OCI IAM policies enforce least-privilege access.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example IAM Policy for Generative AI:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Allow group GenAI-Engineers to manage generative-ai-family in compartment GenAI-Prod
Allow group GenAI-Engineers to use virtual-network-family in compartment GenAI-Networking
Allow group Data-Scientists to read generative-ai-endpoints in compartment GenAI-Prod
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Identity Providers:&lt;/strong&gt; Integration with corporate identity systems (SAML, SCIM) for single sign-on.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Multi-Factor Authentication (MFA):&lt;/strong&gt; Additional security layer requiring multiple forms of verification.&lt;/p&gt;
&lt;h4 id=&quot;oci-key-management-service-vault-&quot;&gt;OCI Key Management Service (Vault)&lt;/h4&gt;
&lt;p&gt;The Key Management Service is critical for protecting data at rest and managing encryption keys.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Vault Architecture:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Oracle Vault is a logical grouping of keys. There are two types of vaults: Private and Virtual, which have different levels of isolation, pricing, and computing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Centralized Key Management:&lt;/strong&gt; OCI Key Management provides centralized management of the encryption of your data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Customer-Managed Keys (CMK):&lt;/strong&gt; Customers create and control their own encryption keys, maintaining full ownership.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Oracle-Managed Keys:&lt;/strong&gt; Default encryption with Oracle-managed keys that are automatically rotated.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Rotation:&lt;/strong&gt; Each master encryption key (MEK) is automatically assigned a key version. When you rotate a key, the Vault service generates a new key version.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Integration with Generative AI:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OCI Generative AI uses Key Management Service to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Store Base Model Keys Securely:&lt;/strong&gt; Encryption keys for foundational models are managed through Vault&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Encrypt Fine-Tuned Models:&lt;/strong&gt; Custom model weights encrypted with customer-controlled keys&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Protect Training Data:&lt;/strong&gt; Datasets used for fine-tuning encrypted before storage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secure Inference Data:&lt;/strong&gt; Input and output data encrypted in transit and at rest&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;oci-object-storage-security&quot;&gt;OCI Object Storage Security&lt;/h4&gt;
&lt;p&gt;Object Storage buckets store critical AI assets including training data, model weights, and embeddings.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Default Encryption:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OCI encrypts all objects by default with Oracle-managed keys, which are periodically rotated. This ensures data is protected even if customers don't explicitly configure encryption.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Customer-Managed Encryption:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OCI provides options for customers to use their own keys for more security. Using IAM policies that authenticate users performing tasks, a best practice is creating and periodically rotating encryption keys in the Vault service to protect resources in Object Storage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Encryption at Multiple Layers:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Object-Level Encryption:&lt;/strong&gt; Each object encrypted with a unique Data Encryption Key (DEK)&lt;br&gt;
&lt;strong&gt;Bucket-Level Encryption:&lt;/strong&gt; Entire buckets can be encrypted with a specific Master Encryption Key (MEK)&lt;br&gt;
&lt;strong&gt;Client-Side Encryption:&lt;/strong&gt; Customers can encrypt data before sending it to Oracle Object Storage for additional control&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Required IAM Policies:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To use customer-managed keys with Object Storage, create a policy like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;allow service objectstorage-&amp;lt;region_name&amp;gt; to use keys in compartment &amp;lt;compartment_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Access Control:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pre-Authenticated Requests (PARs):&lt;/strong&gt; Time-bound access to objects without requiring IAM credentials&lt;br&gt;
&lt;strong&gt;Bucket Visibility:&lt;/strong&gt; Private by default, with explicit configuration required for public access&lt;br&gt;
&lt;strong&gt;Versioning:&lt;/strong&gt; Track and restore previous versions of objects&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Security Best Practices:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Restrict BUCKET_UPDATE permission to a minimal set of IAM groups to minimize the possibility of existing buckets being made public inadvertently or maliciously.&lt;/p&gt;
&lt;h4 id=&quot;cloud-guard-active-threat-detection&quot;&gt;Cloud Guard: Active Threat Detection&lt;/h4&gt;
&lt;p&gt;Comprehensive logging and audit trails maintained for all significant operations.&lt;/p&gt;
&lt;p&gt;Cloud Guard continuously monitors your OCI environment for security weaknesses and threats.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Detector Rules for Object Storage:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Cloud Guard includes detector rules for Object Storage to identify public buckets, unencrypted data, and other security issues.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Capabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Automated Detection:&lt;/strong&gt; Identifies misconfigurations and security threats in real-time&lt;br&gt;
&lt;strong&gt;Responder Actions:&lt;/strong&gt; Automatically remediate issues or notify administrators&lt;br&gt;
&lt;strong&gt;Problem Dashboard:&lt;/strong&gt; Centralized view of all detected security problems&lt;br&gt;
&lt;strong&gt;Integration:&lt;/strong&gt; Works across all OCI services including Generative AI resources&lt;/p&gt;
&lt;h3 id=&quot;data-protection-throughout-the-ai-lifecycle&quot;&gt;Data Protection Throughout the AI Lifecycle&lt;/h3&gt;
&lt;h4 id=&quot;training-data-security&quot;&gt;Training Data Security&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Ingestion:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Data uploaded to Object Storage with automatic encryption&lt;/li&gt;
&lt;li&gt;Customer-managed keys available for additional control&lt;/li&gt;
&lt;li&gt;Access restricted via IAM policies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Processing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Training occurs on dedicated GPUs isolated within customer's RDMA network&lt;/li&gt;
&lt;li&gt;No data sharing between customers&lt;/li&gt;
&lt;li&gt;Temporary data purged after training completion&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Storage:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fine-tuned model weights stored in Object Storage buckets&lt;/li&gt;
&lt;li&gt;Encrypted by default and managed by Key Management Service&lt;/li&gt;
&lt;li&gt;Version control for model iterations&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;inference-data-security&quot;&gt;Inference Data Security&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Input Processing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Requests authenticated via IAM or API keys&lt;/li&gt;
&lt;li&gt;Data encrypted in transit using TLS 1.2+&lt;/li&gt;
&lt;li&gt;Processed on dedicated endpoints with no cross-tenant access&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Output Generation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Responses encrypted in transit&lt;/li&gt;
&lt;li&gt;Optional logging with encryption at rest&lt;/li&gt;
&lt;li&gt;Retention policies configurable per use case&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Monitoring:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Continuous monitoring of resource usage to proactively mitigate contention&lt;/li&gt;
&lt;li&gt;Audit logs for all API calls&lt;/li&gt;
&lt;li&gt;Integration with OCI Logging Analytics&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;advanced-security-features&quot;&gt;Advanced Security Features&lt;/h3&gt;
&lt;h4 id=&quot;security-zones&quot;&gt;Security Zones&lt;/h4&gt;
&lt;p&gt;Security Zones provide compartment-associated Oracle-defined recipes of security policies based on best practices.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Enforced Policies:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;No Public Access:&lt;/strong&gt; Resources cannot be accessible from public internet&lt;br&gt;
&lt;strong&gt;Customer-Managed Keys:&lt;/strong&gt; Data encryption enforced using Customer-Managed Keys for block volumes, boot volumes, and Object Storage buckets&lt;br&gt;
&lt;strong&gt;Deny Public Buckets:&lt;/strong&gt; Public access to Object Storage buckets is denied to prevent accidental exposure&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Deploy Generative AI workloads in Security Zones to automatically enforce security best practices and maintain compliance.&lt;/p&gt;
&lt;h4 id=&quot;compliance-and-certifications&quot;&gt;Compliance and Certifications&lt;/h4&gt;
&lt;p&gt;OCI maintains extensive compliance certifications relevant to AI workloads:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Regional Compliance:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GDPR:&lt;/strong&gt; European data protection requirements&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HIPAA:&lt;/strong&gt; Healthcare data in the United States&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;FedRAMP:&lt;/strong&gt; U.S. government cloud security&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ISO 27001/27017/27018:&lt;/strong&gt; International security standards&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Industry-Specific:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PCI DSS:&lt;/strong&gt; Payment card industry&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SOC 1/2/3:&lt;/strong&gt; Service organization controls&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;FIPS 140-2 Level 3:&lt;/strong&gt; Cryptographic module security&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;sovereign-cloud-options&quot;&gt;Sovereign Cloud Options&lt;/h4&gt;
&lt;p&gt;Oracle's distributed cloud, AI infrastructure, and generative AI services enable governments and enterprises to deploy AI factories that run cloud services locally and within a country's secure premises with operational controls supporting sovereign goals.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Available Options:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;OCI Dedicated Region:&lt;/strong&gt; Entire cloud region operated exclusively for a single customer&lt;br&gt;
&lt;strong&gt;Oracle Alloy:&lt;/strong&gt; Cloud platform for partners to deliver sovereign cloud&lt;br&gt;
&lt;strong&gt;Oracle EU Sovereign Cloud:&lt;/strong&gt; European data residency and operational sovereignty&lt;br&gt;
&lt;strong&gt;Oracle Government Cloud:&lt;/strong&gt; FedRAMP-authorized regions for U.S. government&lt;/p&gt;
&lt;h3 id=&quot;best-practices-for-secure-generative-ai-deployments&quot;&gt;Best Practices for Secure Generative AI Deployments&lt;/h3&gt;
&lt;h4 id=&quot;1-implement-least-privilege-access&quot;&gt;1. Implement Least-Privilege Access&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Principle:&lt;/strong&gt; Grant only the minimum permissions necessary for each role.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Implementation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Development team - read-only on production
Allow group GenAI-Developers to read generative-ai-family in compartment GenAI-Prod

# Production team - full management
Allow group GenAI-Production to manage generative-ai-family in compartment GenAI-Prod
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;2-use-customer-managed-keys&quot;&gt;2. Use Customer-Managed Keys&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Benefit:&lt;/strong&gt; Full control over encryption key lifecycle and usage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create Vault in Key Management Service&lt;/li&gt;
&lt;li&gt;Generate or import master encryption key&lt;/li&gt;
&lt;li&gt;Create IAM policy allowing services to use key&lt;/li&gt;
&lt;li&gt;Configure buckets and resources to use customer key&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;3-enable-comprehensive-logging&quot;&gt;3. Enable Comprehensive Logging&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Audit Logs:&lt;/strong&gt; Enable audit logging for all API calls to Generative AI services&lt;br&gt;
&lt;strong&gt;Flow Logs:&lt;/strong&gt; Monitor network traffic to/from GPU clusters&lt;br&gt;
&lt;strong&gt;Application Logs:&lt;/strong&gt; Capture inference requests and responses for analysis&lt;/p&gt;
&lt;h4 id=&quot;4-leverage-network-isolation&quot;&gt;4. Leverage Network Isolation&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Private Endpoints:&lt;/strong&gt; Deploy model endpoints in private subnets&lt;br&gt;
&lt;strong&gt;Service Gateway:&lt;/strong&gt; Access Oracle services without internet exposure&lt;br&gt;
&lt;strong&gt;Bastion Hosts:&lt;/strong&gt; Secure administrative access to resources&lt;/p&gt;
&lt;h4 id=&quot;5-implement-defense-in-depth&quot;&gt;5. Implement Defense-in-Depth&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Multiple Layers:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Network security (NSGs, Security Lists)&lt;/li&gt;
&lt;li&gt;Identity security (IAM, MFA)&lt;/li&gt;
&lt;li&gt;Data security (encryption at rest and in transit)&lt;/li&gt;
&lt;li&gt;Application security (input validation, rate limiting)&lt;/li&gt;
&lt;li&gt;Monitoring security (Cloud Guard, Logging Analytics)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;6-regular-security-reviews&quot;&gt;6. Regular Security Reviews&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Periodic Assessments:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Review IAM policies quarterly&lt;/li&gt;
&lt;li&gt;Rotate encryption keys according to policy&lt;/li&gt;
&lt;li&gt;Audit user access and remove unused accounts&lt;/li&gt;
&lt;li&gt;Update network security rules based on traffic patterns&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;7-secure-development-practices&quot;&gt;7. Secure Development Practices&lt;/h4&gt;
&lt;p&gt;The architecture includes a CI/CD pipeline for promoting models from the playground environment to production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Separation of Environments:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Development: Unrestricted experimentation with synthetic data&lt;/li&gt;
&lt;li&gt;Staging: Production-like with access controls&lt;/li&gt;
&lt;li&gt;Production: Maximum security with customer data&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;monitoring-and-incident-response&quot;&gt;Monitoring and Incident Response&lt;/h3&gt;
&lt;h4 id=&quot;real-time-monitoring&quot;&gt;Real-Time Monitoring&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Metrics to Track:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;API request rates and latency&lt;/li&gt;
&lt;li&gt;Authentication failures&lt;/li&gt;
&lt;li&gt;Unusual access patterns&lt;/li&gt;
&lt;li&gt;Resource utilization anomalies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Alerting:&lt;/strong&gt;&lt;br&gt;
Configure Cloud Events to trigger notifications for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;IAM policy changes&lt;/li&gt;
&lt;li&gt;Network security group modifications&lt;/li&gt;
&lt;li&gt;Encryption key access&lt;/li&gt;
&lt;li&gt;Dedicated cluster scaling events&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;incident-response&quot;&gt;Incident Response&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Preparation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Define incident response procedures&lt;/li&gt;
&lt;li&gt;Establish communication channels&lt;/li&gt;
&lt;li&gt;Designate response team members&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Detection:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cloud Guard active monitoring&lt;/li&gt;
&lt;li&gt;Log analysis for anomalies&lt;/li&gt;
&lt;li&gt;User-reported issues&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Containment:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Isolate affected resources&lt;/li&gt;
&lt;li&gt;Revoke compromised credentials&lt;/li&gt;
&lt;li&gt;Block suspicious network traffic&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Recovery:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Restore from backups if necessary&lt;/li&gt;
&lt;li&gt;Rotate encryption keys&lt;/li&gt;
&lt;li&gt;Update security configurations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Lessons Learned:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Document incident timeline&lt;/li&gt;
&lt;li&gt;Identify root causes&lt;/li&gt;
&lt;li&gt;Update procedures and controls&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;future-security-enhancements&quot;&gt;Future Security Enhancements&lt;/h3&gt;
&lt;p&gt;Oracle continues investing in security capabilities:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AI-Powered Security:&lt;/strong&gt;&lt;br&gt;
Machine learning models detecting anomalous behavior in API usage patterns and access patterns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Zero Trust Architecture:&lt;/strong&gt;&lt;br&gt;
Moving toward continuous verification of all access requests regardless of source.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Confidential Computing:&lt;/strong&gt;&lt;br&gt;
NVIDIA BlueField-3 DPUs accelerate networking, storage, and security workloads, enabling hardware-based isolation for sensitive computations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Enhanced Compliance:&lt;/strong&gt;&lt;br&gt;
Expanding certifications and attestations for emerging regulatory requirements.&lt;/p&gt;
&lt;p&gt;OCI Generative AI security is built on a comprehensive, multi-layered approach that addresses the unique challenges of enterprise AI deployments:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Infrastructure Security:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dedicated GPUs pooled within RDMA networks exclusively for single customers&lt;/li&gt;
&lt;li&gt;Dedicated GPU clusters handling only customer's base and fine-tuned models&lt;/li&gt;
&lt;li&gt;Ultra-low latency RDMA networking with complete tenant isolation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Data Security:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Customer data access restricted within tenancy&lt;/li&gt;
&lt;li&gt;Object Storage encrypted by default with periodic key rotation&lt;/li&gt;
&lt;li&gt;Customer-managed keys for maximum control&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Identity and Access:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Comprehensive IAM with fine-grained policies&lt;/li&gt;
&lt;li&gt;Integration with enterprise identity providers&lt;/li&gt;
&lt;li&gt;Multi-factor authentication support&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Compliance:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;FIPS 140-2 Level 3 certified HSMs&lt;/li&gt;
&lt;li&gt;Sovereign cloud options for data residency&lt;/li&gt;
&lt;li&gt;Extensive regulatory certifications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Security and privacy of customer workloads is truly an essential design tenet at OCI. By combining dedicated infrastructure, comprehensive encryption, identity controls, and continuous monitoring, OCI Generative AI provides enterprise-grade security that enables organizations to confidently deploy AI at scale.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;How does your organization approach AI security? What security features are most critical for your use cases? Share your experiences in the comments&lt;/em&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/9917/oci-generative-security-dedicated-gpus-rdma-networks-enterprise-grade-data-protection</guid>
<pubDate>Sat, 17 Jan 2026 18:12:41 +0000</pubDate>
</item>
<item>
<title>OCI Generative AI: Dedicated Cluster Sizing, Pricing, and Fine-Tuning Deep Dive</title>
<link>https://coderlegion.com/9738/oci-generative-ai-dedicated-cluster-sizing-pricing-and-fine-tuning-deep-dive</link>
<description>&lt;p&gt;Understanding how to properly size, price, and configure dedicated AI clusters is crucial for cost-effective deployment of custom LLMs on Oracle Cloud Infrastructure. This comprehensive guide walks you through cluster types, pricing calculations, fine-tuning configurations, and how to interpret your results.&lt;/p&gt;
&lt;h3 id=&quot;dedicated-ai-cluster-unit-types&quot;&gt;Dedicated AI Cluster Unit Types&lt;/h3&gt;
&lt;p&gt;OCI Generative AI provides several dedicated cluster unit types, each optimized for specific models and workloads:&lt;/p&gt;
&lt;h4 id=&quot;available-unit-types&quot;&gt;Available Unit Types&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Small Cohere Dedicated (V2)&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unit identifier: &lt;code&gt;SMALL_COHERE_V2&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Suitable for: Cohere Command R models&lt;/li&gt;
&lt;li&gt;Use case: Fine-tuning and hosting smaller Cohere models&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Large Cohere Dedicated&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unit identifier: &lt;code&gt;LARGE_COHERE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Suitable for: Cohere Command R+ models&lt;/li&gt;
&lt;li&gt;Use case: Larger Cohere models requiring more compute&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Embed Cohere Dedicated&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unit identifier: &lt;code&gt;EMBED_COHERE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Suitable for: Cohere embedding models (English V3, Multilingual V3, Light variants)&lt;/li&gt;
&lt;li&gt;Use case: Generating embeddings at scale&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Large Meta Dedicated&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unit identifier: &lt;code&gt;LARGE_META&lt;/code&gt; (or specific like &lt;code&gt;Llama2-70-count&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Suitable for: Meta Llama models (70B, 405B parameters)&lt;/li&gt;
&lt;li&gt;Use case: Hosting and fine-tuning large Meta Llama models&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;understanding-unit-requirements&quot;&gt;Understanding Unit Requirements&lt;/h4&gt;
&lt;p&gt;Different models require different numbers of units for fine-tuning and hosting. Let's use the Cohere Command R 08-2024 model as an example:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fine-Tuning Requirements:&lt;/strong&gt;&lt;br&gt;
To fine-tune a Cohere Command R 08-2024 model, you need a preset value of 8 Small Cohere V2 units. This is non-negotiable—the fine-tuning cluster is automatically sized for optimal training performance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hosting Requirements:&lt;/strong&gt;&lt;br&gt;
To host the fine-tuned Command R 08-2024 model, you need a minimum of 1 Small Cohere V2 unit. You can add more units (up to 3 or more) to handle higher call volumes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Total for Complete Workflow:&lt;/strong&gt;&lt;br&gt;
If you want to both fine-tune and host a Command R model, you'll need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;8 Small Cohere V2 units (fine-tuning cluster)&lt;/li&gt;
&lt;li&gt;1+ Small Cohere V2 units (hosting cluster)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Total: Minimum 9 Small Cohere V2 units&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;commitment-requirements-and-billing&quot;&gt;Commitment Requirements and Billing&lt;/h3&gt;
&lt;p&gt;Understanding OCI's commitment model is essential for cost planning.&lt;/p&gt;
&lt;h4 id=&quot;minimum-commitments&quot;&gt;Minimum Commitments&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Hosting Clusters&lt;/strong&gt;: Require a minimum commitment of 744 unit-hours per cluster&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;744 hours = 31 days (one month)&lt;/li&gt;
&lt;li&gt;This is your minimum billing period for hosting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Fine-Tuning Clusters&lt;/strong&gt;: Require a minimum of 1 unit-hour&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You pay only for the actual time used&lt;/li&gt;
&lt;li&gt;Much more flexible than hosting commitments&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;billing-mechanics&quot;&gt;Billing Mechanics&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Character-Based Billing (On-Demand):&lt;/strong&gt;&lt;br&gt;
A transaction is one character. 10,000 transactions = 10,000 characters. Foundational models on-demand are charged per character for prompts and responses (except embeddings, where responses aren't counted).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Unit-Hour Billing (Dedicated Clusters):&lt;/strong&gt;&lt;br&gt;
If you're hosting foundational models or fine-tuning them on dedicated AI clusters, you're charged by the unit-hour rather than by transaction.&lt;/p&gt;
&lt;h3 id=&quot;real-world-pricing-example-ryan-s-fine-tuning-journey&quot;&gt;Real-World Pricing Example: Ryan's Fine-Tuning Journey&lt;/h3&gt;
&lt;p&gt;Let's walk through a complete pricing scenario based on Bob's example from Oracle documentation, adapted for our Ryan scenario:&lt;/p&gt;
&lt;h4 id=&quot;ryan-s-requirements&quot;&gt;Ryan's Requirements&lt;/h4&gt;
&lt;p&gt;Ryan wants to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Fine-tune a Cohere Command R 08-2024 model&lt;/li&gt;
&lt;li&gt;Host the fine-tuned model for production use&lt;/li&gt;
&lt;li&gt;Create a new fine-tuned version weekly (4 times per month)&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;step-by-step-cost-calculation&quot;&gt;Step-by-Step Cost Calculation&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Step 1: Fine-Tuning Cluster Costs&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Ryan creates a fine-tuning dedicated AI cluster with the preset value of 8 Small Cohere V2 units. The fine-tuning job takes 5 hours to complete. Ryan creates a fine-tuning cluster every week.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Monthly Fine-Tuning Calculation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Fine-tuning sessions per month: 4 (weekly)
Units per session: 8 Small Cohere V2
Hours per session: 5 hours
Total unit-hours: 4 sessions × 8 units × 5 hours = 160 unit-hours

Monthly fine-tuning cost = 160 unit-hours × $&amp;lt;Small-Cohere-dedicated-unit-per-hour-price&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Hosting Cluster Costs&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For hosting, dedicated AI clusters require a minimum commitment of 744 unit-hours per cluster.&lt;/p&gt;
&lt;p&gt;Let's assume Ryan uses 1 Small Cohere V2 unit for hosting:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Hosting units: 1 Small Cohere V2
Hours per month: 744 (minimum commitment)
Total unit-hours: 1 unit × 744 hours = 744 unit-hours

Monthly hosting cost = 744 unit-hours × $&amp;lt;Small-Cohere-dedicated-unit-per-hour-price&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 3: Total Monthly Cost&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Total monthly cost = Fine-tuning cost + Hosting cost
Total monthly cost = (160 + 744) unit-hours × $&amp;lt;Small-Cohere-dedicated-unit-per-hour-price&amp;gt;
Total monthly cost = 904 unit-hours × $&amp;lt;Small-Cohere-dedicated-unit-per-hour-price&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;scaling-hosting-for-higher-traffic&quot;&gt;Scaling Hosting for Higher Traffic&lt;/h4&gt;
&lt;p&gt;If Ryan decides to buy three units of Small Cohere V2 to handle higher call volume, the hosting calculation becomes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Hosting units: 3 Small Cohere V2
Hours per month: 744 (minimum commitment applies per unit)
Total unit-hours: 3 units × 744 hours = 2,232 unit-hours

Monthly hosting cost = 2,232 unit-hours × $&amp;lt;Small-Cohere-dedicated-unit-per-hour-price&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;fine-tuning-configuration-parameters&quot;&gt;Fine-Tuning Configuration Parameters&lt;/h3&gt;
&lt;p&gt;Understanding fine-tuning hyperparameters is crucial for achieving optimal model performance.&lt;/p&gt;
&lt;h4 id=&quot;training-methods&quot;&gt;Training Methods&lt;/h4&gt;
&lt;p&gt;OCI Generative AI supports two main parameter-efficient fine-tuning methods:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;T-Few (Training Few):&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parameter-efficient method for Cohere models&lt;/li&gt;
&lt;li&gt;Selectively updates only a fraction of model weights&lt;/li&gt;
&lt;li&gt;Recommended for small datasets (&amp;lt;100,000 samples)&lt;/li&gt;
&lt;li&gt;Ideal for changing instruction-following behavior&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;LoRA (Low-Rank Adaptation):&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parameter-efficient method for Llama models&lt;/li&gt;
&lt;li&gt;Adds trainable adapter matrices while freezing base model&lt;/li&gt;
&lt;li&gt;Balances efficiency with performance&lt;/li&gt;
&lt;li&gt;Suitable for most fine-tuning scenarios&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;hyperparameters-explained&quot;&gt;Hyperparameters Explained&lt;/h4&gt;
&lt;p&gt;OCI Generative AI fine-tunes each base model using hyperparameters based on the pretrained base model. Start training with default hyperparameter values.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Training Epochs Total:&lt;/strong&gt;&lt;br&gt;
An epoch is one complete pass through the entire training dataset. The number of epochs determines how many times the model sees all training examples.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Too few epochs&lt;/strong&gt;: Model underfits, doesn't learn patterns well&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Too many epochs&lt;/strong&gt;: Model overfits, memorizes training data instead of generalizing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimal range&lt;/strong&gt;: Typically 3-10 epochs depending on dataset size&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Learning Rate:&lt;/strong&gt;&lt;br&gt;
The learning rate influences how much model parameters are adjusted in each iteration. A lower learning rate means smaller changes to parameter estimates, requiring longer training time but potentially achieving minimum loss.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Too high&lt;/strong&gt;: Model may overshoot optimal parameters, fail to converge&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Too low&lt;/strong&gt;: Training takes excessively long, may get stuck in local minima&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Typical range&lt;/strong&gt;: 1e-5 to 1e-3 for fine-tuning&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Techniques like learning rate schedules adjust the rate over time, or adaptive algorithms like Adam or RMSprop are commonly used.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Training Batch Size:&lt;/strong&gt;&lt;br&gt;
Number of training examples processed together before updating model parameters.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Larger batches&lt;/strong&gt;: More stable gradient estimates, faster training, higher memory usage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Smaller batches&lt;/strong&gt;: More gradient noise (can help escape local minima), lower memory usage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Typical range&lt;/strong&gt;: 4-32 for LLM fine-tuning&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Early Stopping Patience:&lt;/strong&gt;&lt;br&gt;
Number of epochs to wait for improvement before stopping training early. Prevents wasting compute on models that have stopped improving.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Example&lt;/strong&gt;: If patience = 3, training stops if validation loss doesn't improve for 3 consecutive epochs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Early Stopping Threshold:&lt;/strong&gt;&lt;br&gt;
The minimum improvement required to reset the patience counter. Helps distinguish real improvements from noise.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Example&lt;/strong&gt;: Threshold = 0.001 means validation loss must improve by at least 0.001 to count as improvement&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Log Model Metrics Interval Steps:&lt;/strong&gt;&lt;br&gt;
Frequency of logging training metrics (loss, accuracy) during training.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Smaller intervals&lt;/strong&gt;: More detailed monitoring, larger log files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Larger intervals&lt;/strong&gt;: Less granular view, smaller storage requirements&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Typical value&lt;/strong&gt;: Every 10-100 steps&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;hyperparameter-calculation&quot;&gt;Hyperparameter Calculation&lt;/h4&gt;
&lt;p&gt;The model calculates totalTrainingSteps using: totalTrainingSteps = (totalTrainingEpochs × size(trainingDataset)) / trainingBatchSize&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example Calculation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Training dataset: 1,000 examples
Training epochs: 5
Batch size: 10

Total training steps = (5 × 1,000) / 10 = 500 steps
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;understanding-fine-tuning-results&quot;&gt;Understanding Fine-Tuning Results&lt;/h3&gt;
&lt;p&gt;After training completes, evaluating model performance is critical. In the model's detail page, under Model Performance, check the values for accuracy and loss. If you're not happy with the results, create another model with either a larger dataset or different hyperparameters until performance improves.&lt;/p&gt;
&lt;h4 id=&quot;key-metrics-explained&quot;&gt;Key Metrics Explained&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Accuracy:&lt;/strong&gt;&lt;br&gt;
Accuracy measures the proportion of correct predictions among the total number of cases evaluated. In the context of LLM fine-tuning, accuracy measures when the generated tokens match the annotated tokens in your training data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Formula:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Accuracy = (Number of correct token predictions) / (Total number of tokens)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Interpretation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Accuracy = 0.90 (90%)&lt;/strong&gt;: The model predicts the correct token 90% of the time&lt;/li&gt;
&lt;li&gt;Higher is better, but perfect accuracy (1.0) often indicates overfitting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
If fine-tuning on a medical terminology task, accuracy of 85% means the model correctly generates medical terms 85% of the time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Loss:&lt;/strong&gt;&lt;br&gt;
Loss (also called training loss) measures how wrong the generated outputs of the model are. The loss function quantifies the discrepancy between predicted outputs and actual targets.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Characteristics:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Loss decreases as the model improves&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Lower loss indicates better fit to training data&lt;/li&gt;
&lt;li&gt;Should decrease consistently across epochs (if not, check learning rate)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Common Loss Functions:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cross-entropy loss&lt;/strong&gt;: Standard for classification and language modeling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mean squared error&lt;/strong&gt;: Less common for LLMs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Interpreting Loss Curves:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Training loss started at step 25 at 2.86 and by step 200, total training and validation loss was insignificant at just 0.4.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Epoch 1: Loss = 2.5
Epoch 2: Loss = 1.8  ← Good! Decreasing
Epoch 3: Loss = 1.3  ← Still improving
Epoch 4: Loss = 1.1  ← Slowing down
Epoch 5: Loss = 1.05 ← Converging
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Warning Signs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Loss increases&lt;/strong&gt;: Learning rate too high, or data quality issues&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loss plateaus early&lt;/strong&gt;: Learning rate too low, or model capacity insufficient&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loss fluctuates wildly&lt;/strong&gt;: Batch size too small, or learning rate too high&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;training-vs-validation-loss&quot;&gt;Training vs. Validation Loss&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Training Loss:&lt;/strong&gt;&lt;br&gt;
Measured on the data the model is learning from. Always decreases with enough training.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Validation Loss:&lt;/strong&gt;&lt;br&gt;
Measured on held-out data the model hasn't seen. Indicates generalization ability.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ideal Pattern:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Epoch  | Training Loss | Validation Loss
-------|---------------|----------------
1      | 2.5          | 2.6
2      | 1.8          | 1.9
3      | 1.3          | 1.4
4      | 1.1          | 1.2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Both decreasing = healthy training&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Overfitting Pattern:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Epoch  | Training Loss | Validation Loss
-------|---------------|----------------
1      | 2.5          | 2.6
2      | 1.8          | 1.9
3      | 1.3          | 1.6  ← Warning!
4      | 1.0          | 1.8  ← Overfitting!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Training loss decreases but validation loss increases = model memorizing training data&lt;/p&gt;
&lt;h4 id=&quot;additional-evaluation-metrics&quot;&gt;Additional Evaluation Metrics&lt;/h4&gt;
&lt;p&gt;While accuracy and loss are primary, consider these secondary metrics:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Perplexity:&lt;/strong&gt;&lt;br&gt;
Exponential of the loss, more interpretable for language models. Lower is better.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Perplexity = e^(loss)
If loss = 1.5, perplexity = 4.48
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;F1-Score:&lt;/strong&gt;&lt;br&gt;
The F1-score is a combined measure of recall and precision, offering a balanced assessment of LLM performance in language tasks.&lt;/p&gt;
&lt;p&gt;Particularly useful for classification tasks within fine-tuning (e.g., intent classification, sentiment analysis).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BLEU/ROUGE Scores:&lt;/strong&gt;&lt;br&gt;
For text generation quality, though traditional metrics like BLEU and ROUGE are considered insufficient for natural conversations.&lt;/p&gt;
&lt;h3 id=&quot;best-practices-for-cost-optimization&quot;&gt;Best Practices for Cost Optimization&lt;/h3&gt;
&lt;h4 id=&quot;1-fine-tuning-strategy&quot;&gt;1. Fine-Tuning Strategy&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Minimize Training Sessions:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Prepare high-quality datasets before fine-tuning&lt;/li&gt;
&lt;li&gt;Test hyperparameters on small subsets first&lt;/li&gt;
&lt;li&gt;Batch multiple improvements into single training runs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Optimize Training Time:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use early stopping to avoid unnecessary epochs&lt;/li&gt;
&lt;li&gt;Monitor loss curves—stop if converging&lt;/li&gt;
&lt;li&gt;Start with smaller epochs, increase if needed&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-hosting-strategy&quot;&gt;2. Hosting Strategy&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Right-Size Hosting Units:&lt;/strong&gt;&lt;br&gt;
Start with 1 unit and add more only as call volume demands. Remember the 744-hour minimum commitment.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Consider On-Demand for Low Volume:&lt;/strong&gt;&lt;br&gt;
If usage is sporadic or low, on-demand pricing might be more cost-effective than dedicated hosting.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Calculation for Break-Even:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;On-demand cost per 10k characters: $X
Dedicated cost per unit-hour: $Y
Characters processed per hour: Z

Break-even: Z × $X = $Y
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;3-development-vs-production&quot;&gt;3. Development vs. Production&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Development/Testing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use on-demand inferencing&lt;/li&gt;
&lt;li&gt;Fine-tune infrequently with small datasets&lt;/li&gt;
&lt;li&gt;No hosting commitment needed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Production:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dedicated hosting for consistent performance&lt;/li&gt;
&lt;li&gt;Batch fine-tuning updates (weekly/monthly)&lt;/li&gt;
&lt;li&gt;Scale hosting units based on actual traffic&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;4-monitoring-and-optimization&quot;&gt;4. Monitoring and Optimization&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Track Key Metrics:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cost per fine-tuning session&lt;/li&gt;
&lt;li&gt;Cost per inference (characters processed)&lt;/li&gt;
&lt;li&gt;Utilization rate of hosting clusters&lt;/li&gt;
&lt;li&gt;Model performance metrics (accuracy, loss)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Optimization Opportunities:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reduce fine-tuning frequency if model performance stable&lt;/li&gt;
&lt;li&gt;Adjust hosting capacity based on traffic patterns&lt;/li&gt;
&lt;li&gt;Use cached responses for common queries&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;common-pitfalls-and-solutions&quot;&gt;Common Pitfalls and Solutions&lt;/h3&gt;
&lt;h4 id=&quot;pitfall-1-over-fine-tuning&quot;&gt;Pitfall 1: Over-Fine-Tuning&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: Creating new fine-tuned models too frequently&lt;br&gt;
&lt;strong&gt;Cost Impact&lt;/strong&gt;: Unnecessary compute charges&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Fine-tune only when you have substantial new training data or performance degrades&lt;/p&gt;
&lt;h4 id=&quot;pitfall-2-over-provisioning-hosting&quot;&gt;Pitfall 2: Over-Provisioning Hosting&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: Allocating too many hosting units &quot;just in case&quot;&lt;br&gt;
&lt;strong&gt;Cost Impact&lt;/strong&gt;: Paying for unused capacity (744 hours/month minimum per unit)&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Start with minimum units, monitor utilization, scale up as needed&lt;/p&gt;
&lt;h4 id=&quot;pitfall-3-ignoring-model-metrics&quot;&gt;Pitfall 3: Ignoring Model Metrics&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: Not evaluating accuracy and loss before deploying&lt;br&gt;
&lt;strong&gt;Cost Impact&lt;/strong&gt;: Poor model performance requiring additional fine-tuning sessions&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Always check Model Performance metrics and iterate if needed&lt;/p&gt;
&lt;h4 id=&quot;pitfall-4-poor-hyperparameter-choices&quot;&gt;Pitfall 4: Poor Hyperparameter Choices&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: Using default hyperparameters without experimentation&lt;br&gt;
&lt;strong&gt;Cost Impact&lt;/strong&gt;: Suboptimal models requiring more training sessions&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Test hyperparameters systematically, document what works&lt;/p&gt;
&lt;h3 id=&quot;practical-workflow-example&quot;&gt;Practical Workflow Example&lt;/h3&gt;
&lt;p&gt;Here's a complete workflow with cost awareness:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Phase 1: Initial Fine-Tuning (Week 1)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Prepare 5,000 training examples
2. Create fine-tuning cluster (8 Small Cohere V2 units)
3. Fine-tune with default hyperparameters (5 hours)
4. Cost: 40 unit-hours × $price
5. Check accuracy: 82% ← Needs improvement
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Phase 2: Iteration (Week 2)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Increase dataset to 10,000 examples
2. Adjust learning rate from 1e-4 to 5e-5
3. Fine-tune again (6 hours)
4. Cost: 48 unit-hours × $price
5. Check accuracy: 91% ← Acceptable!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Phase 3: Deployment (Week 3-4)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Create hosting cluster (1 Small Cohere V2 unit)
2. Deploy fine-tuned model
3. Cost: 744 unit-hours × $price (monthly minimum)
4. Monitor usage and performance
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Total Month 1 Cost:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Fine-tuning: (40 + 48) = 88 unit-hours
Hosting: 744 unit-hours (minimum commitment)
Total: 832 unit-hours × $&amp;lt;price per unit-hour&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;conclusion-1&quot;&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Effective use of OCI Generative AI dedicated clusters requires understanding three key areas:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Sizing&lt;/strong&gt;: Match cluster unit types and counts to your specific models&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fine-tuning: 8 Small Cohere V2 units for Command R&lt;/li&gt;
&lt;li&gt;Hosting: Start with 1 unit, scale based on traffic&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;2. Pricing&lt;/strong&gt;: Plan for commitments and optimize costs&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fine-tuning: Pay for actual hours used (minimum 1 hour)&lt;/li&gt;
&lt;li&gt;Hosting: 744-hour monthly minimum per cluster&lt;/li&gt;
&lt;li&gt;Calculate break-even vs. on-demand based on usage&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;3. Configuration&lt;/strong&gt;: Tune hyperparameters and monitor metrics&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start with defaults, iterate systematically&lt;/li&gt;
&lt;li&gt;Watch accuracy (higher is better) and loss (lower is better)&lt;/li&gt;
&lt;li&gt;Use early stopping to save compute time&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By following these guidelines, you can deploy custom fine-tuned models on OCI cost-effectively while maintaining high performance.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/9738/oci-generative-ai-dedicated-cluster-sizing-pricing-and-fine-tuning-deep-dive</guid>
<pubDate>Thu, 15 Jan 2026 07:33:12 +0000</pubDate>
</item>
<item>
<title>Chat and Embedding Models in OCI Generative AI</title>
<link>https://coderlegion.com/8520/chat-and-embedding-models-in-oci-generative-ai</link>
<description>&lt;p&gt;Oracle Cloud Infrastructure (OCI) Generative AI provides two powerful categories of models: chat models for conversational AI and text generation, and embedding models for semantic understanding and search. Understanding how to configure and optimize these models is essential for building effective AI applications.&lt;/p&gt;
&lt;h3 id=&quot;understanding-tokens&quot;&gt;Understanding Tokens&lt;/h3&gt;
&lt;p&gt;Before diving into model parameters, it's crucial to understand that &lt;strong&gt;LLMs understand tokens rather than characters&lt;/strong&gt;. A token can be a word, part of a word, or even punctuation. As a general rule, estimate &lt;strong&gt;approximately 4 characters per token&lt;/strong&gt;—meaning 100 tokens is roughly 60-80 words.&lt;/p&gt;
&lt;p&gt;This matters because all LLM limits, costs, and parameters are expressed in tokens, not words or characters.&lt;/p&gt;
&lt;h3 id=&quot;chat-models-configuration-parameters&quot;&gt;Chat Models: Configuration Parameters&lt;/h3&gt;
&lt;p&gt;Chat models in OCI Generative AI offer extensive configuration options to control their behavior and output characteristics.&lt;/p&gt;
&lt;h4 id=&quot;max-output-tokens&quot;&gt;Max Output Tokens&lt;/h4&gt;
&lt;p&gt;The &lt;strong&gt;maximum number of tokens&lt;/strong&gt; that you want the model to generate per response. Each model has different maximum output token limits specified in their key features.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: Because you're prompting a chat model, the response depends on the prompt and each response doesn't necessarily use up the maximum allocated tokens. Setting this parameter essentially creates a ceiling—the model will stop generating once it hits this limit.&lt;/p&gt;
&lt;h4 id=&quot;preamble-override&quot;&gt;Preamble Override&lt;/h4&gt;
&lt;p&gt;An &lt;strong&gt;initial context or guiding message&lt;/strong&gt; for a chat model that changes the model's overall chat behavior and conversation style. When you don't provide a preamble, the model uses its default.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Default Preamble for Cohere Command R Family:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;You are Command. You are an extremely capable large language model built by Cohere. 
You are given instructions programmatically via an API that you follow to the best 
of your ability.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Custom Preamble Example:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;You are a helpful assistant specialized in Italian cuisine. 
Respond with enthusiasm and include regional context when discussing dishes.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this preamble override, when asked about cannolis, the model responds with regional details about Sicily and specific bakeries like Caffe Sierra and Pasticceria Cappello.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Alternative Approach&lt;/strong&gt;: You can also include preamble-like instructions directly in your conversation. For example: &quot;Answer the following question in a marketing tone. Where's the best place to go sailing?&quot;&lt;/p&gt;
&lt;h4 id=&quot;temperature&quot;&gt;Temperature&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Temperature controls the randomness of the output&lt;/strong&gt;. It's one of the most important parameters for shaping model behavior.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How Temperature Works:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Temperature modulates the probability distribution over words in the vocabulary&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Temperature = 0&lt;/strong&gt;: Makes the model deterministic, always selecting the word with the highest probability (essentially greedy decoding)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Low temperature (&amp;lt; 1.0)&lt;/strong&gt;: Distribution is more peaked around the most likely tokens, producing focused, predictable outputs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Temperature = 1.0&lt;/strong&gt;: Standard probability distribution with no modification&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;High temperature (&amp;gt; 1.0)&lt;/strong&gt;: Distribution flattens across all words, increasing randomness and creativity&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Best Practices:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Start with temperature set to 0 or less than one, and increase it as you regenerate prompts for more creative output. Be cautious: high temperatures can introduce hallucinations and factually incorrect information.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Low temperature (0.0-0.3)&lt;/strong&gt;: Code generation, factual Q&amp;amp;A, technical documentation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium temperature (0.5-0.7)&lt;/strong&gt;: General chatbots, customer service, balanced responses&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;High temperature (0.8-1.0+)&lt;/strong&gt;: Creative writing, brainstorming, diverse idea generation&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;top-k-sampling&quot;&gt;Top-K Sampling&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Top-K&lt;/strong&gt; tells the model to pick the next token from the &lt;strong&gt;top K tokens&lt;/strong&gt; in its list sorted by probability.&lt;/p&gt;
&lt;p&gt;A higher value for K generates more random output, making the text sound more natural. The parameter essentially limits the selection pool to the K most likely candidates at each step.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Range:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Minimum&lt;/strong&gt;: 1 (considers only the single most probable token, essentially deterministic)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maximum&lt;/strong&gt;: Vocabulary size (considers all possible tokens)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCI Default&lt;/strong&gt;: 0 for Command models, -1 for Llama models (meaning the model considers all tokens and doesn't use this method)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: If K=3 and the top three tokens are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&quot;favorite&quot; (40% probability)&lt;/li&gt;
&lt;li&gt;&quot;best&quot; (30% probability)  &lt;/li&gt;
&lt;li&gt;&quot;preferred&quot; (15% probability)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The model randomly selects from only these three options, weighted by their probabilities.&lt;/p&gt;
&lt;h4 id=&quot;top-p-nucleus-sampling-&quot;&gt;Top-P (Nucleus Sampling)&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Top-P&lt;/strong&gt; is similar to Top-K but &lt;strong&gt;picks from top tokens based on the sum of their probabilities&lt;/strong&gt;. It's more dynamic than Top-K because the number of tokens considered varies.&lt;/p&gt;
&lt;p&gt;Top-P selects tokens whose cumulative probability exceeds a threshold (p), limiting the pool to the smallest set meeting this sum.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Top-P picks the next token based on cumulative probability, ensuring the sum of probabilities is below a certain threshold.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: If Top-P = 0.5 and tokens have probabilities:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Token A: 0.3 (30%)&lt;/li&gt;
&lt;li&gt;Token B: 0.2 (20%)&lt;/li&gt;
&lt;li&gt;Token C: 0.1 (10%)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The model only considers A and B (cumulative 50%), excluding C.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Range:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Minimum&lt;/strong&gt;: 0.0 (considers only the single most probable token)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maximum&lt;/strong&gt;: 1.0 (considers all tokens)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A high top-p value means the model looks at more possible words, even less likely ones, making generated text more diverse.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Practical Guidelines:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Top-P = 0.5&lt;/strong&gt;: Only considers words adding up to 50% probability—focused responses&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Top-P = 0.9&lt;/strong&gt;: Includes many more words—varied and original responses&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;the-interaction-temperature-top-k-and-top-p&quot;&gt;The Interaction: Temperature, Top-K, and Top-P&lt;/h4&gt;
&lt;p&gt;The selection process works in stages: Top-K tokens with highest probabilities are sampled first, then tokens are further filtered based on Top-P, with the final token being selected using temperature.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Decision Framework:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For tasks requiring accuracy and focus (like code completion), use lower temperature, higher Top-P/Top-K, and moderate max tokens&lt;/li&gt;
&lt;li&gt;For creative writing, experiment with higher temperature, lower Top-P/Top-K, and larger max token limits&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;frequency-and-presence-penalties&quot;&gt;Frequency and Presence Penalties&lt;/h4&gt;
&lt;p&gt;These parameters are &lt;strong&gt;useful if you want to get rid of repetition in your outputs&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Frequency Penalty:&lt;/strong&gt;&lt;br&gt;
A penalty assigned to a token when that token appears frequently. High penalties encourage fewer repeated tokens and produce more random output.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Presence Penalty:&lt;/strong&gt;&lt;br&gt;
A penalty assigned to each token when it appears in the output to encourage generating outputs with tokens that haven't been used.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;: If your model keeps repeating the same phrases or concepts, increase these penalties to encourage more diverse vocabulary and concepts.&lt;/p&gt;
&lt;h4 id=&quot;seed-parameter-reproducibility-&quot;&gt;Seed Parameter (Reproducibility)&lt;/h4&gt;
&lt;p&gt;Assigning a number for the seed parameter is similar to tagging the request with a number. The LLM aims to generate the same set of tokens for the same integer in consecutive requests.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Important Notes:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Allowed values are integers; assigning large or small seed values doesn't affect the result&lt;/li&gt;
&lt;li&gt;Especially useful for debugging and testing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Warning&lt;/strong&gt;: The seed parameter might not produce the same result long-term because model updates might invalidate the seed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;OCI Limits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;API: No maximum value&lt;/li&gt;
&lt;li&gt;Console: Maximum value is 9999&lt;/li&gt;
&lt;li&gt;Leave blank (Console) or null (API) to disable&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;stop-sequences&quot;&gt;Stop Sequences&lt;/h4&gt;
&lt;p&gt;A sequence of characters—such as a word, phrase, newline (\n), or period—that tells the model when to stop the generated output.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: If the stop sequence is a period (.), the model stops generating text once it reaches the end of the first sentence, even if the token limit is much higher.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;: Useful for controlling output length and format, especially when you want responses limited to single sentences or specific sections.&lt;/p&gt;
&lt;h4 id=&quot;likelihood-display&quot;&gt;Likelihood Display&lt;/h4&gt;
&lt;p&gt;Shows how likely a token is to follow the current generated token. Likelihood is defined by a number between -15 and 0, where more negative numbers mean less likely tokens.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: The word &quot;favorite&quot; is more likely to be followed by &quot;food&quot; or &quot;book&quot; rather than &quot;zebra.&quot;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: This parameter doesn't influence the generation process itself but serves as a diagnostic tool to help understand the model's behavior.&lt;/p&gt;
&lt;h3 id=&quot;embedding-models-converting-text-to-vectors&quot;&gt;Embedding Models: Converting Text to Vectors&lt;/h3&gt;
&lt;p&gt;Embedding models transform text into numerical representations that capture semantic meaning, enabling AI systems to understand relationships between words, sentences, and documents.&lt;/p&gt;
&lt;h4 id=&quot;what-are-embeddings-&quot;&gt;What Are Embeddings?&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Embeddings are numerical representations of text converted to number sequences&lt;/strong&gt;. A piece of text can be a phrase, sentence, or one or more paragraphs.&lt;/p&gt;
&lt;p&gt;A vector embedding is a mapping from input (like a word, list of words, or image) into a list of floating-point numbers. That list represents the input in the multidimensional embedding space of the model.&lt;/p&gt;
&lt;h4 id=&quot;oci-embedding-model-dimensions&quot;&gt;OCI Embedding Model Dimensions&lt;/h4&gt;
&lt;p&gt;OCI Generative AI embedding models transform each phrase, sentence, or paragraph into an array with 384 (light models) or 1024 numbers, depending on the embedding model selected.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Available Models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cohere Embed English V3&lt;/strong&gt;: 1024 dimensions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cohere Embed English Light V3&lt;/strong&gt;: 384 dimensions  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cohere Embed Multilingual V3&lt;/strong&gt;: 1024 dimensions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cohere Embed Multilingual Light V3&lt;/strong&gt;: 384 dimensions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cohere Embed 4&lt;/strong&gt;: Latest version supporting text and images&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Light models (384d)&lt;/strong&gt;: Faster processing, lower memory usage, suitable for most applications&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Standard models (1024d)&lt;/strong&gt;: Richer semantic representation, better for complex similarity tasks&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;types-of-embeddings&quot;&gt;Types of Embeddings&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Word Embeddings:&lt;/strong&gt;&lt;br&gt;
Capture properties and relationships of individual words. Word2vec was the most well-known embedding model for a long time, accepting only single words but very good at representing semantic meaning, typically outputting 300-dimensional vectors.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sentence Embeddings:&lt;/strong&gt;&lt;br&gt;
Associate every sentence with a vector of numbers, capturing meaning at the sentence level rather than individual words.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Document Embeddings:&lt;/strong&gt;&lt;br&gt;
Represent entire paragraphs or documents as single vectors, useful for document similarity and classification tasks.&lt;/p&gt;
&lt;h4 id=&quot;semantic-similarity-the-core-principle&quot;&gt;Semantic Similarity: The Core Principle&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Embeddings that are numerically similar are also semantically similar.&lt;/strong&gt; This is the fundamental principle that makes embeddings powerful.&lt;/p&gt;
&lt;p&gt;Similar words, documents, or images have vectors that are also similar. For example, &quot;basketball&quot; and &quot;baseball&quot; have embedding vectors much closer to each other than &quot;rainforest&quot;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Measuring Similarity:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The most popular way to compare vectors is cosine similarity, which measures the cosine of the angle between two vectors in multi-dimensional space. The closer the vectors, the smaller the angle.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Other Distance Metrics:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Euclidean distance&lt;/strong&gt;: Straight-line distance between vectors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dot product (inner product)&lt;/strong&gt;: Especially effective for unit vectors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Manhattan distance&lt;/strong&gt;: Sum of absolute differences&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cosine similarity is popular for text embeddings, measuring the angle between vectors. Dot product can also work, especially for unit vectors, offering performance benefits in vector databases.&lt;/p&gt;
&lt;h4 id=&quot;embedding-model-evolution&quot;&gt;Embedding Model Evolution&lt;/h4&gt;
&lt;p&gt;Word2vec was the pioneer, focusing on single words with 300 dimensions—lightweight and great for semantic meaning. Then came OpenAI's text-embedding-ada-002 in 2022, supporting up to 8192 tokens and outputting 1536 dimensions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2025 State of the Art:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Advances in 2025, driven by LLMs and benchmarks, show transformer-based and instruction-tuned embeddings achieving top performance. Key trends include multilingual models (1000+ languages), domain-specific models (medicine, code), and multimodal models (text-image-audio).&lt;/p&gt;
&lt;h4 id=&quot;embedding-use-cases&quot;&gt;Embedding Use Cases&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;1. Vector Databases and Semantic Search&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The most common use case: Embeddings are mostly used for semantic searches where the search function focuses on the meaning of the text rather than finding results based on keywords.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Workflow:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;User query is converted to a vector representation using an embedding model&lt;/li&gt;
&lt;li&gt;Query vector is stored/compared in a vector database&lt;/li&gt;
&lt;li&gt;Similar vectors are retrieved from private content&lt;/li&gt;
&lt;li&gt;Retrieved content is sent to an LLM for response generation&lt;/li&gt;
&lt;li&gt;LLM sends response back to the user&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We use the embedding model to create vector embeddings for content we want to index. The vector embedding is inserted into the vector database with some reference to the original content.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Recommendation Systems&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;By embedding items (products, articles, movies) and user preferences, systems can recommend semantically similar items even if they don't share obvious keywords.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Text Classification and Clustering&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Embeddings enable text classification and text clustering by grouping semantically similar items together.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Applications:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Classifying support tickets by department&lt;/li&gt;
&lt;li&gt;Categorizing documents by topic&lt;/li&gt;
&lt;li&gt;Detecting duplicate or similar content&lt;/li&gt;
&lt;li&gt;Sentiment analysis grouping&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;4. Retrieval-Augmented Generation (RAG)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;While the most common scenario for vector databases is retrieval-augmented generation (RAG), other possible use cases include recommendations, anomaly detection, and more.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. Question Answering Systems&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Create chatbots that respond to questions about your own data—for instance, a chatbot responding to employee questions on healthcare coverage. Hundreds of pages of documentation can be split into chunks, converted into embeddings, and searched based on vector similarity.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;6. Semantic Caching&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Reduce cost and latency of LLMs by caching LLM completions. LLM queries are compared using vector similarity—if a new query is similar enough to a previously cached query, the cached query is returned.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;7. LLM Conversation Memory&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Persist conversation history with an LLM as embeddings in a vector database. Applications can use vector search to pull relevant history or &quot;memories&quot; into LLM responses.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;8. Cross-Lingual and Multimodal Search&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We can use vector search across languages since embedding models are frequently trained on more than just English data, and we can use vector search with images if we use multimodal embedding models trained on both text and images.&lt;/p&gt;
&lt;h4 id=&quot;vector-databases-storage-and-retrieval&quot;&gt;Vector Databases: Storage and Retrieval&lt;/h4&gt;
&lt;p&gt;A vector database is a database that can store, manage, retrieve, and compare vectors.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Capabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Vector databases are purpose-built to manage vector embeddings, offering data management (insert, delete, update), metadata storage and filtering, scalability with distributed processing, and real-time query performance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Popular Vector Databases:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pinecone&lt;/li&gt;
&lt;li&gt;Weaviate&lt;/li&gt;
&lt;li&gt;Qdrant&lt;/li&gt;
&lt;li&gt;Milvus&lt;/li&gt;
&lt;li&gt;Chroma&lt;/li&gt;
&lt;li&gt;Oracle Database 23ai (with AI Vector Search)&lt;/li&gt;
&lt;li&gt;Azure Redis&lt;/li&gt;
&lt;li&gt;MyScale&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Advanced Features:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Some vector databases can perform hybrid searches by first narrowing results based on characteristics or metadata before conducting vector search—making searches more effective and customizable.&lt;/p&gt;
&lt;h4 id=&quot;oci-embedding-model-input-requirements&quot;&gt;OCI Embedding Model Input Requirements&lt;/h4&gt;
&lt;p&gt;Input data for text embeddings must meet the following requirements: maximum of 96 inputs allowed for each run, with each input less than 512 tokens for text-only models.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Handling Long Inputs:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If an input exceeds the 512 token limit, you can set the Truncate parameter to Start or End to cut off text to fit within the token limit. Setting it to None will produce an error if inputs exceed limits.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Multimodal Support:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For text and image embed models like Cohere Embed English Image V3, you can add either text or one image only.&lt;/p&gt;
&lt;h3 id=&quot;best-practices-for-oci-generative-ai&quot;&gt;Best Practices for OCI Generative AI&lt;/h3&gt;
&lt;h4 id=&quot;chat-model-optimization&quot;&gt;Chat Model Optimization&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Start Simple&lt;/strong&gt;: Begin with default parameters, then adjust based on results&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Temperature First&lt;/strong&gt;: Adjust temperature before other sampling parameters&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use Preambles Wisely&lt;/strong&gt;: Set clear behavioral expectations with custom preambles&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implement Stop Sequences&lt;/strong&gt;: Control output format and length precisely&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test Reproducibility&lt;/strong&gt;: Use seed parameter during development for consistent testing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Monitor Penalties&lt;/strong&gt;: Add frequency/presence penalties if seeing repetition&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;embedding-model-selection&quot;&gt;Embedding Model Selection&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Choose Appropriate Dimensions&lt;/strong&gt;: Use light models (384d) for most applications; standard models (1024d) for complex similarity tasks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Select Right Model&lt;/strong&gt;: English vs. Multilingual based on your data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batch Process&lt;/strong&gt;: Take advantage of the 96-input limit for efficient processing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Index Strategically&lt;/strong&gt;: Store embeddings in vector databases with appropriate indexes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Measure Appropriately&lt;/strong&gt;: Use cosine similarity for most text applications&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;integration-patterns&quot;&gt;Integration Patterns&lt;/h4&gt;
&lt;p&gt;OCI Generative AI integrates with LangChain for building context-augmented applications and RAG solutions. It also works with LlamaIndex for accessing pretrained models or creating custom models on dedicated AI clusters.&lt;/p&gt;
&lt;p&gt;Understanding chat and embedding models in OCI Generative AI enables you to build sophisticated AI applications. Chat models with properly tuned parameters (temperature, top-k, top-p, penalties) produce high-quality, contextually appropriate responses. Embedding models convert text into semantic vectors that power search, recommendations, and retrieval systems.&lt;/p&gt;
&lt;p&gt;Key takeaways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tokens are the fundamental unit&lt;/strong&gt;—everything is measured in tokens, not characters&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Temperature controls creativity&lt;/strong&gt;—low for precision, high for creativity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sampling parameters work together&lt;/strong&gt;—Top-K and Top-P filter candidates before temperature applies&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Embeddings enable semantic understanding&lt;/strong&gt;—similar meanings produce similar vectors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vector databases make it practical&lt;/strong&gt;—efficient storage and retrieval of embeddings at scale&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Whether building chatbots, implementing semantic search, or creating RAG applications, mastering these parameters and concepts is essential for production-grade AI systems on OCI.&lt;/p&gt;
</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://coderlegion.com/8520/chat-and-embedding-models-in-oci-generative-ai</guid>
<pubDate>Tue, 16 Dec 2025 08:45:24 +0000</pubDate>
</item>
<item>
<title>OCI Generative AI Service: Enterprise-Grade LLMs on Oracle Cloud</title>
<link>https://coderlegion.com/8424/oci-generative-ai-service-enterprise-grade-llms-on-oracle-cloud</link>
<description>&lt;p&gt;Oracle Cloud Infrastructure (OCI) Generative AI is a fully managed service providing enterprises with access to state-of-the-art, customizable large language models through a comprehensive API. OCI positions itself as a neutral, enterprise-focused platform offering unprecedented choice and flexibility in the generative AI space.&lt;/p&gt;
&lt;h3 id=&quot;what-is-oci-generative-ai-&quot;&gt;What is OCI Generative AI?&lt;/h3&gt;
&lt;p&gt;OCI Generative AI helps enterprises seamlessly integrate advanced language comprehension capabilities into applications, providing a complete end-to-end platform for building, customizing, and deploying LLM-powered applications at scale.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Capabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Access to pretrained foundational models from multiple leading AI providers&lt;/li&gt;
&lt;li&gt;Flexible fine-tuning with custom datasets on dedicated infrastructure&lt;/li&gt;
&lt;li&gt;Enterprise-grade security, compliance, and data sovereignty&lt;/li&gt;
&lt;li&gt;Integration with Oracle's broader AI ecosystem&lt;/li&gt;
&lt;li&gt;Support for both on-demand usage and dedicated hosting&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;available-models-2025-&quot;&gt;Available Models (2025)&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Cohere Models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Command A (03-2025)&lt;/strong&gt;: 256K token context, excels at tool use, agents, RAG, and multilingual tasks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Command R/R+&lt;/strong&gt;: 128K context for RAG and enterprise use cases&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Embed models&lt;/strong&gt;: English v3.0, Multilingual v3.0, Embed 4&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Meta Llama Models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Llama 4 Maverick&lt;/strong&gt;: 17B active from ~400B total (mixture-of-experts)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Llama 4 Scout&lt;/strong&gt;: 17B active from ~109B total&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Llama 3.3 (70B)&lt;/strong&gt;, &lt;strong&gt;Llama 3.2 Vision&lt;/strong&gt; (90B, 11B), &lt;strong&gt;Llama 3.1&lt;/strong&gt; (405B, 70B)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Google Gemini Models (Coming Soon):&lt;/strong&gt;&lt;br&gt;
Oracle will be the only hyperscaler aside from Google Cloud to offer Gemini as a managed service.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Gemini 2.5 Pro/Flash/Flash-Lite&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;xAI Grok Models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Grok 4/Grok 4 Fast&lt;/strong&gt;, &lt;strong&gt;Grok 3 series&lt;/strong&gt;, &lt;strong&gt;Grok Code Fast 1&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;OpenAI Models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;gpt-oss-120b&lt;/strong&gt; and &lt;strong&gt;gpt-oss-20b&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;core-features&quot;&gt;Core Features&lt;/h3&gt;
&lt;h4 id=&quot;1-pretrained-models&quot;&gt;1. Pretrained Models&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Chat Models&lt;/strong&gt;: Multi-turn conversational AI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Text Generation&lt;/strong&gt;: Content creation, code generation, documentation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Embedding Models&lt;/strong&gt;: Vector representations for semantic search (384-1024 dimensions)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rerank Models&lt;/strong&gt;: Relevance scoring for search results&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-fine-tuning&quot;&gt;2. Fine-Tuning&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Strategies:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;T-Few &amp;amp; Vanilla&lt;/strong&gt; for Cohere models (with layer-specific optimization)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LoRA&lt;/strong&gt; for Llama 3 models (efficient parameter adaptation)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Customization:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Training epochs, learning rate, batch size&lt;/li&gt;
&lt;li&gt;Early stopping controls&lt;/li&gt;
&lt;li&gt;JSONL format with prompt/completion pairs&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;3-dedicated-ai-clusters&quot;&gt;3. Dedicated AI Clusters&lt;/h4&gt;
&lt;p&gt;GPU-based compute resources exclusive to your tenancy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Isolated infrastructure for fine-tuning&lt;/li&gt;
&lt;li&gt;Private GPUs for hosting with zero-downtime scaling&lt;/li&gt;
&lt;li&gt;Multiple cluster sizes (Small/Large/Large Generic 2/4 for 405B models)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;4-deployment-options&quot;&gt;4. Deployment Options&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;On-Demand&lt;/strong&gt;: Pay-per-character, ideal for experimentation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dedicated Clusters&lt;/strong&gt;: Predictable costs for production workloads&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;5-oci-generative-ai-agents-2024-2025-&quot;&gt;5. OCI Generative AI Agents (2024-2025)&lt;/h4&gt;
&lt;p&gt;Fully managed RAG service combining LLMs with enterprise search.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Agent Hub Features (March 2025):&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SQL Tool&lt;/strong&gt;: Self-correction, multi-dialect support (Oracle SQL, SQLite)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enhanced RAG Tool&lt;/strong&gt;: Hybrid search, multi-modal parsing, multi-lingual support (7+ languages)&lt;/li&gt;
&lt;li&gt;Integration with OCI Object Storage, OpenSearch, Oracle Database 23ai&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;use-cases&quot;&gt;Use Cases&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Text Generation&lt;/strong&gt;: Blog posts, marketing copy, documentation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Semantic Search&lt;/strong&gt;: Intent-based search, recommendations, document retrieval&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Document Summarization&lt;/strong&gt;: Executive summaries, support tickets, research papers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Classification&lt;/strong&gt;: Support ticket routing, sentiment analysis, intent detection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Question Answering&lt;/strong&gt;: Intelligent responses from documents and knowledge bases&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enterprise Knowledge Management&lt;/strong&gt;: RAG-powered customer support&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;developer-experience&quot;&gt;Developer Experience&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Access Methods:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;OCI Console Playground&lt;/li&gt;
&lt;li&gt;REST API&lt;/li&gt;
&lt;li&gt;OCI CLI&lt;/li&gt;
&lt;li&gt;SDKs (Python, Java, TypeScript, Node.js)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Framework Integration:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;LangChain&lt;/strong&gt;: Prompt templating, memory, chain-of-thought&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LlamaIndex&lt;/strong&gt;: Context-augmented applications, RAG solutions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Tool Use&lt;/strong&gt;: Chat models can integrate with external tools and APIs for complex queries requiring external data.&lt;/p&gt;
&lt;h3 id=&quot;security-amp-compliance&quot;&gt;Security &amp;amp; Compliance&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Data isolation within your tenancy&lt;/li&gt;
&lt;li&gt;Encryption at rest and in transit&lt;/li&gt;
&lt;li&gt;Fine-grained IAM policies and RBAC&lt;/li&gt;
&lt;li&gt;Comprehensive audit trails&lt;/li&gt;
&lt;li&gt;Private endpoints and VPN connectivity&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Regional Availability:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;US (Chicago, Phoenix, Ashburn)&lt;/li&gt;
&lt;li&gt;Europe (Frankfurt, London, Amsterdam)&lt;/li&gt;
&lt;li&gt;Asia Pacific (Tokyo, Mumbai, Seoul)&lt;/li&gt;
&lt;li&gt;Middle East (Dubai, Jeddah)&lt;/li&gt;
&lt;li&gt;Latin America (São Paulo)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sovereign Cloud&lt;/strong&gt;: Oracle EU Sovereign Cloud for data residency&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;advanced-features-1&quot;&gt;Advanced Features&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Configurable Parameters:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Temperature (0.0-1.0)&lt;/li&gt;
&lt;li&gt;Top-k and top-p sampling&lt;/li&gt;
&lt;li&gt;Frequency/presence penalties&lt;/li&gt;
&lt;li&gt;Seed parameter for reproducibility&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Performance Benchmarks:&lt;/strong&gt;&lt;br&gt;
RAG scenarios with 2,000-token prompts and 200-token responses benchmarked across cluster types.&lt;/p&gt;
&lt;h3 id=&quot;pricing&quot;&gt;Pricing&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Free Tier&lt;/strong&gt;: $300 credits for trial&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;On-Demand&lt;/strong&gt;: Pay-per-character (input/output)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dedicated Clusters&lt;/strong&gt;: Predictable monthly costs&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;oracle-s-ai-ecosystem&quot;&gt;Oracle's AI Ecosystem&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Oracle Database 23ai:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Native AI Vector Search&lt;/li&gt;
&lt;li&gt;In-database LLM integration&lt;/li&gt;
&lt;li&gt;Support for RAG workflows&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;MySQL HeatWave:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In-database LLMs (HeatWave GenAI)&lt;/li&gt;
&lt;li&gt;Automated vector store&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Oracle Fusion Applications:&lt;/strong&gt;&lt;br&gt;
Generative AI embedded across ERP, HCM, SCM, and CX applications.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;OCI Data Science:&lt;/strong&gt;&lt;br&gt;
No-code access to open-source LLMs (Meta, Mistral AI) with Hugging Face Transformers and PyTorch.&lt;/p&gt;
&lt;h3 id=&quot;certification&quot;&gt;Certification&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;OCI 2025 Generative AI Professional Certification&lt;/strong&gt; covers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LLM Fundamentals &amp;amp; Transformer Architecture&lt;/li&gt;
&lt;li&gt;Prompt Engineering&lt;/li&gt;
&lt;li&gt;Fine-Tuning Techniques&lt;/li&gt;
&lt;li&gt;RAG Workflows &amp;amp; Vector Databases&lt;/li&gt;
&lt;li&gt;Agent Development&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt; Free tutorials, Coursera courses, Oracle MyLearn platform&lt;/p&gt;
&lt;h3 id=&quot;competitive-advantages&quot;&gt;Competitive Advantages&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Model Choice&lt;/strong&gt;: Access to Cohere, Meta, Google, xAI, OpenAI through unified platform&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enterprise-First&lt;/strong&gt;: Security, compliance, data sovereignty&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cost-Effective&lt;/strong&gt;: Better price-performance with transparent pricing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Database Integration&lt;/strong&gt;: Unique integration with Oracle Database 23ai and MySQL HeatWave&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sovereign Cloud&lt;/strong&gt;: Data residency guarantees&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Create OCI account (free tier available)&lt;/li&gt;
&lt;li&gt;Navigate to Analytics &amp;amp; AI → Generative AI&lt;/li&gt;
&lt;li&gt;Choose approach: Playground, API/SDK, or Fine-tuning&lt;/li&gt;
&lt;li&gt;Select model and configure parameters&lt;/li&gt;
&lt;li&gt;Start building&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Example: Building a Support Chatbot&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Ingest documentation into Oracle Database 23ai vector store&lt;/li&gt;
&lt;li&gt;Create embeddings using Cohere Embed models&lt;/li&gt;
&lt;li&gt;Deploy RAG Agent&lt;/li&gt;
&lt;li&gt;Implement chat interface with LangChain&lt;/li&gt;
&lt;li&gt;Enable multi-turn conversations with tool calling&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;OCI Generative AI offers comprehensive, enterprise-focused LLM capabilities addressing real-world needs: security, sovereignty, choice, and integration. Whether building chatbots, implementing semantic search, or developing multi-agent systems, OCI provides the foundation for enterprise-grade AI applications.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Are you using OCI Generative AI? Share your experiences below&lt;/em&gt;&lt;/p&gt;
</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://coderlegion.com/8424/oci-generative-ai-service-enterprise-grade-llms-on-oracle-cloud</guid>
<pubDate>Fri, 12 Dec 2025 09:55:53 +0000</pubDate>
</item>
</channel>
</rss>