|
6 | 6 | - [Getting Started](#getting-started) |
7 | 7 | - [Step 1: Set Your Environment Variable](#step-1-set-your-environment-variable) |
8 | 8 | - [Step 2: Navigate to the Examples Directory](#step-2-navigate-to-the-examples-directory) |
| 9 | +- [Model Selection Guide](#model-selection-guide) |
9 | 10 | - [Tutorial 1: LLM Completions and Chat](#tutorial-1-llm-completions-and-chat) |
10 | 11 | - [Tutorial 2: Function Calling](#tutorial-2-function-calling) |
11 | 12 | - [Tutorial 3: RAG (Retrieval-Augmented Generation)](#tutorial-3-rag-retrieval-augmented-generation) |
@@ -54,6 +55,25 @@ export GITHUB_TOKEN=your_github_token_here |
54 | 55 | cd 03-CoreGenerativeAITechniques/examples/ |
55 | 56 | ``` |
56 | 57 |
|
| 58 | +## Model Selection Guide |
| 59 | + |
| 60 | +These examples use different models optimized for their specific use cases: |
| 61 | + |
| 62 | +**GPT-4.1-nano** (Completions example): |
| 63 | +- Ultra-fast and ultra-cheap |
| 64 | +- Perfect for basic text completion and chat |
| 65 | +- Ideal for learning fundamental LLM interaction patterns |
| 66 | + |
| 67 | +**GPT-4o-mini** (Functions, RAG, and Responsible AI examples): |
| 68 | +- Small but fully-featured "omni workhorse" model |
| 69 | +- Reliably supports advanced capabilities across vendors: |
| 70 | + - Vision processing |
| 71 | + - JSON/structured outputs |
| 72 | + - Tool/function calling |
| 73 | +- More capabilities than nano, ensuring examples work consistently |
| 74 | + |
| 75 | +> **Why this matters**: While "nano" models are great for speed and cost, "mini" models are the safer choice when you need reliable access to advanced features like function calling, which may not be fully exposed by all hosting providers for nano variants. |
| 76 | +
|
57 | 77 | ## Tutorial 1: LLM Completions and Chat |
58 | 78 |
|
59 | 79 | **File:** `src/main/java/com/example/genai/techniques/completions/LLMCompletionsApp.java` |
@@ -85,9 +105,9 @@ List<ChatRequestMessage> messages = List.of( |
85 | 105 | ); |
86 | 106 |
|
87 | 107 | ChatCompletionsOptions options = new ChatCompletionsOptions(messages) |
88 | | - .setModel("gpt-4o-mini") |
89 | | - .setMaxTokens(200) // Limit response length |
90 | | - .setTemperature(0.7); // Control creativity (0.0-1.0) |
| 108 | + .setModel("gpt-4.1-nano") // Fast, cost-effective model for basic completions |
| 109 | + .setMaxTokens(200) // Limit response length |
| 110 | + .setTemperature(0.7); // Control creativity (0.0-1.0) |
91 | 111 | ``` |
92 | 112 |
|
93 | 113 | #### 3. Conversation Memory |
@@ -118,6 +138,8 @@ mvn compile exec:java -Dexec.mainClass="com.example.genai.techniques.completions |
118 | 138 |
|
119 | 139 | Function calling enables AI models to request execution of external tools and APIs through a structured protocol where the model analyzes natural language requests, determines required function calls with appropriate parameters using JSON Schema definitions, and processes returned results to generate contextual responses, while the actual function execution remains under developer control for security and reliability. |
120 | 140 |
|
| 141 | +> **Note**: This example uses `gpt-4o-mini` because function calling requires reliable tool calling capabilities that may not be fully exposed in nano models on all hosting platforms. |
| 142 | +
|
121 | 143 | ### Key Code Concepts |
122 | 144 |
|
123 | 145 | #### 1. Function Definition |
@@ -193,6 +215,8 @@ mvn compile exec:java -Dexec.mainClass="com.example.genai.techniques.functions.F |
193 | 215 |
|
194 | 216 | Retrieval-Augmented Generation (RAG) combines information retrieval with language generation by injecting external document context into AI prompts, enabling models to provide accurate answers based on specific knowledge sources rather than potentially outdated or inaccurate training data, while maintaining clear boundaries between user queries and authoritative information sources through strategic prompt engineering. |
195 | 217 |
|
| 218 | +> **Note**: This example uses `gpt-4o-mini` to ensure reliable processing of structured prompts and consistent handling of document context, which is crucial for effective RAG implementations. |
| 219 | +
|
196 | 220 | ### Key Code Concepts |
197 | 221 |
|
198 | 222 | #### 1. Document Loading |
@@ -248,6 +272,8 @@ Try asking: "What is GitHub Models?" vs "What is the weather like?" |
248 | 272 |
|
249 | 273 | The Responsible AI example showcases the importance of implementing safety measures in AI applications. It demonstrates how modern AI safety systems work through two primary mechanisms: hard blocks (HTTP 400 errors from safety filters) and soft refusals (polite "I can't assist with that" responses from the model itself). This example shows how production AI applications should gracefully handle content policy violations through proper exception handling, refusal detection, user feedback mechanisms, and fallback response strategies. |
250 | 274 |
|
| 275 | +> **Note**: This example uses `gpt-4o-mini` because it provides more consistent and reliable safety responses across different types of potentially harmful content, ensuring the safety mechanisms are properly demonstrated. |
| 276 | +
|
251 | 277 | ### Key Code Concepts |
252 | 278 |
|
253 | 279 | #### 1. Safety Testing Framework |
|
0 commit comments