From db6cee739b104a9aa6cb099a4bdfccd6b8d6532a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Mon, 2 Feb 2026 11:43:05 +0300 Subject: [PATCH] feat(content): add MDX linting script and configuration in package.json --- package.json | 3 +- scripts/lint-mdx.js | 407 +++++++++ src/content/book/el/05-structured-output.mdx | 140 ++-- src/content/book/el/06-chain-of-thought.mdx | 396 ++++----- src/content/book/el/07-few-shot-learning.mdx | 526 ++++++------ .../book/el/08-iterative-refinement.mdx | 254 +++--- .../book/fa/12-handling-edge-cases.mdx | 298 +++---- .../book/fa/13-multimodal-prompting.mdx | 782 +++++++++--------- .../book/fa/14-context-engineering.mdx | 312 +++---- src/content/book/fa/15-common-pitfalls.mdx | 396 ++++----- .../book/fa/16-ethics-responsible-use.mdx | 286 +++---- .../book/fa/17-prompt-optimization.mdx | 210 ++--- .../book/he/12-handling-edge-cases.mdx | 702 ++++++++-------- .../book/he/13-multimodal-prompting.mdx | 782 +++++++++--------- .../book/he/14-context-engineering.mdx | 310 +++---- src/content/book/he/15-common-pitfalls.mdx | 396 ++++----- .../book/he/16-ethics-responsible-use.mdx | 286 +++---- .../book/he/17-prompt-optimization.mdx | 210 ++--- 18 files changed, 3552 insertions(+), 3144 deletions(-) create mode 100644 scripts/lint-mdx.js diff --git a/package.json b/package.json index c0b98c39..b03cf49e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "test": "vitest run", "test:watch": "vitest", "test:ui": "vitest --ui", - "test:coverage": "vitest run --coverage" + "test:coverage": "vitest run --coverage", + "lint:mdx": "node scripts/lint-mdx.js" }, "dependencies": { "@auth/prisma-adapter": "^2.11.1", diff --git a/scripts/lint-mdx.js b/scripts/lint-mdx.js new file mode 100644 index 00000000..3d26dbd7 --- /dev/null +++ b/scripts/lint-mdx.js @@ -0,0 +1,407 @@ +#!/usr/bin/env node + +/** + * MDX Linting Script + * Checks MDX files for common issues: + * - Unclosed/mismatched JSX tags + * - Invalid JSX attribute syntax + * - Unbalanced braces/brackets + * - Empty files + * - Trailing whitespace issues + */ + +const fs = require("fs"); +const path = require("path"); +const pc = require("picocolors"); + +const BOOK_DIR = path.join(__dirname, "../src/content/book"); + +// Known self-closing components (don't need closing tags) +const SELF_CLOSING_COMPONENTS = new Set([ + "TokenizerDemo", + "TokenPredictionDemo", + "ContextWindowDemo", + "TemperatureDemo", + "TextToImageDemo", + "TextToVideoDemo", + "LLMCapabilitiesDemo", + "TryIt", + "Compare", + "Quiz", + "br", + "hr", + "img", + "input", +]); + +// Known block components that need closing +const BLOCK_COMPONENTS = new Set([ + "Callout", + "Collapsible", + "div", + "span", + "p", +]); + +class MDXLinter { + constructor(filePath) { + this.filePath = filePath; + this.content = ""; + this.lines = []; + this.errors = []; + this.warnings = []; + } + + addError(line, message) { + this.errors.push({ line, message }); + } + + addWarning(line, message) { + this.warnings.push({ line, message }); + } + + load() { + try { + this.content = fs.readFileSync(this.filePath, "utf-8"); + this.lines = this.content.split("\n"); + return true; + } catch (err) { + this.addError(0, `Failed to read file: ${err.message}`); + return false; + } + } + + checkEmptyFile() { + if (this.content.trim().length === 0) { + this.addError(1, "File is empty"); + } + } + + checkUnbalancedBraces() { + let braceCount = 0; + let bracketCount = 0; + + for (let i = 0; i < this.lines.length; i++) { + const line = this.lines[i]; + // Skip code blocks + if (line.trim().startsWith("```")) continue; + + for (const char of line) { + if (char === "{") braceCount++; + if (char === "}") braceCount--; + if (char === "[") bracketCount++; + if (char === "]") bracketCount--; + } + } + + if (braceCount !== 0) { + this.addError(0, `Unbalanced curly braces: ${braceCount > 0 ? "missing" : "extra"} ${Math.abs(braceCount)} closing brace(s)`); + } + if (bracketCount !== 0) { + this.addWarning(0, `Unbalanced square brackets: ${bracketCount > 0 ? "missing" : "extra"} ${Math.abs(bracketCount)} closing bracket(s)`); + } + } + + checkJSXTags() { + // Remove code blocks from content for tag analysis + let content = ""; + let inCodeBlock = false; + const lineMapping = []; // Maps position to line number + + for (let i = 0; i < this.lines.length; i++) { + const line = this.lines[i]; + if (line.trim().startsWith("```")) { + inCodeBlock = !inCodeBlock; + content += "\n"; + continue; + } + if (inCodeBlock) { + content += "\n"; + continue; + } + const startPos = content.length; + content += line + "\n"; + for (let j = 0; j <= line.length; j++) { + lineMapping[startPos + j] = i + 1; + } + } + + const openingTags = []; + const closingTags = []; + + // Parse tags character by character for accuracy + let i = 0; + while (i < content.length) { + if (content[i] === "<") { + const startIdx = i; + const startLine = lineMapping[i] || 0; + + // Check if it's a closing tag + if (content[i + 1] === "/") { + // Closing tag: + const closeMatch = content.slice(i).match(/^<\/([A-Z][A-Za-z0-9]*)>/); + if (closeMatch) { + closingTags.push({ name: closeMatch[1], line: startLine, index: startIdx }); + i += closeMatch[0].length; + continue; + } + } else if (/[A-Z]/.test(content[i + 1])) { + // Opening or self-closing tag: or + // Find the tag name + const nameMatch = content.slice(i).match(/^<([A-Z][A-Za-z0-9]*)/); + if (nameMatch) { + const tagName = nameMatch[1]; + // Find the end of this tag (the matching >) + let depth = 0; + let inString = false; + let stringChar = ""; + let inJSX = 0; + let j = i + nameMatch[0].length; + + while (j < content.length) { + const char = content[j]; + + // Handle string literals + if (!inString && (char === '"' || char === "'" || char === "`")) { + inString = true; + stringChar = char; + j++; + continue; + } + if (inString) { + if (char === stringChar && content[j - 1] !== "\\") { + inString = false; + } + j++; + continue; + } + + // Handle nested JSX expressions + if (char === "{") { + inJSX++; + j++; + continue; + } + if (char === "}") { + inJSX--; + j++; + continue; + } + + // Only look for > when not inside JSX expression + if (inJSX === 0) { + if (char === "/" && content[j + 1] === ">") { + // Self-closing tag + j += 2; + break; + } + if (char === ">") { + // Opening tag - add to stack + if (!SELF_CLOSING_COMPONENTS.has(tagName)) { + openingTags.push({ name: tagName, line: startLine, index: startIdx }); + } + j++; + break; + } + } + + j++; + } + i = j; + continue; + } + } + } + i++; + } + + // Match opening and closing tags + const unmatchedOpening = [...openingTags]; + const unmatchedClosing = []; + + for (const closeTag of closingTags) { + let found = false; + for (let k = unmatchedOpening.length - 1; k >= 0; k--) { + if (unmatchedOpening[k].name === closeTag.name && unmatchedOpening[k].index < closeTag.index) { + unmatchedOpening.splice(k, 1); + found = true; + break; + } + } + if (!found) { + unmatchedClosing.push(closeTag); + } + } + + // Report errors + for (const tag of unmatchedOpening) { + this.addError(tag.line, `Unclosed tag <${tag.name}>`); + } + for (const tag of unmatchedClosing) { + this.addError(tag.line, `Unexpected closing tag with no matching opening tag`); + } + } + + checkJSXAttributes() { + let inCodeBlock = false; + + for (let i = 0; i < this.lines.length; i++) { + const line = this.lines[i]; + const lineNum = i + 1; + + if (line.trim().startsWith("```")) { + inCodeBlock = !inCodeBlock; + continue; + } + if (inCodeBlock) continue; + + // Check for common JSX attribute issues + // Missing quotes around string attributes + const badAttrRegex = /\s([a-z]+)=([^"{}\s>][^\s>]*)/gi; + const badMatches = [...line.matchAll(badAttrRegex)]; + for (const match of badMatches) { + // Skip if it looks like a JSX expression or valid + if (match[2].startsWith("{") || match[2].startsWith('"') || match[2].startsWith("'")) { + continue; + } + this.addWarning(lineNum, `Attribute "${match[1]}" may need quotes around value "${match[2]}"`); + } + + // Check for unterminated JSX expressions + const jsxExprCount = (line.match(/\{/g) || []).length - (line.match(/\}/g) || []).length; + // This is checked at file level, but flag obvious single-line issues + if (line.includes("<") && line.includes(">") && jsxExprCount !== 0) { + // Only warn if it's clearly a JSX line + if (/<[A-Z]/.test(line)) { + this.addWarning(lineNum, `Possible unterminated JSX expression in component`); + } + } + } + } + + checkTrailingWhitespace() { + for (let i = 0; i < this.lines.length; i++) { + const line = this.lines[i]; + if (line !== line.trimEnd()) { + this.addWarning(i + 1, "Trailing whitespace"); + } + } + } + + checkConsecutiveBlankLines() { + let blankCount = 0; + for (let i = 0; i < this.lines.length; i++) { + if (this.lines[i].trim() === "") { + blankCount++; + if (blankCount > 2) { + this.addWarning(i + 1, "More than 2 consecutive blank lines"); + } + } else { + blankCount = 0; + } + } + } + + lint() { + if (!this.load()) return this; + + this.checkEmptyFile(); + this.checkUnbalancedBraces(); + this.checkJSXTags(); + this.checkJSXAttributes(); + // Uncomment for stricter checks: + // this.checkTrailingWhitespace(); + // this.checkConsecutiveBlankLines(); + + return this; + } + + hasIssues() { + return this.errors.length > 0 || this.warnings.length > 0; + } + + printResults() { + if (!this.hasIssues()) return; + + const relativePath = path.relative(process.cwd(), this.filePath); + console.log(`\n${pc.underline(relativePath)}`); + + for (const err of this.errors) { + console.log(` ${pc.red("error")} ${err.line > 0 ? `line ${err.line}: ` : ""}${err.message}`); + } + for (const warn of this.warnings) { + console.log(` ${pc.yellow("warn")} ${warn.line > 0 ? `line ${warn.line}: ` : ""}${warn.message}`); + } + } +} + +function findMDXFiles(dir) { + const files = []; + + function walk(currentDir) { + const entries = fs.readdirSync(currentDir, { withFileTypes: true }); + for (const entry of entries) { + const fullPath = path.join(currentDir, entry.name); + if (entry.isDirectory()) { + walk(fullPath); + } else if (entry.name.endsWith(".mdx")) { + files.push(fullPath); + } + } + } + + walk(dir); + return files; +} + +function main() { + const args = process.argv.slice(2); + let files = []; + + if (args.length > 0) { + // Lint specific files + files = args.map(f => path.resolve(f)).filter(f => f.endsWith(".mdx") && fs.existsSync(f)); + if (files.length === 0) { + console.error(pc.red("No valid MDX files specified")); + process.exit(1); + } + } else { + // Lint all MDX files in book directory + if (!fs.existsSync(BOOK_DIR)) { + console.error(pc.red(`Book directory not found: ${BOOK_DIR}`)); + process.exit(1); + } + files = findMDXFiles(BOOK_DIR); + } + + console.log(pc.cyan(`Linting ${files.length} MDX file(s)...\n`)); + + let totalErrors = 0; + let totalWarnings = 0; + let filesWithIssues = 0; + + for (const file of files) { + const linter = new MDXLinter(file).lint(); + if (linter.hasIssues()) { + filesWithIssues++; + linter.printResults(); + } + totalErrors += linter.errors.length; + totalWarnings += linter.warnings.length; + } + + console.log(""); + + if (totalErrors === 0 && totalWarnings === 0) { + console.log(pc.green(`✓ All ${files.length} files passed`)); + process.exit(0); + } else { + const summary = []; + if (totalErrors > 0) summary.push(pc.red(`${totalErrors} error(s)`)); + if (totalWarnings > 0) summary.push(pc.yellow(`${totalWarnings} warning(s)`)); + console.log(`Found ${summary.join(" and ")} in ${filesWithIssues} file(s)`); + process.exit(totalErrors > 0 ? 1 : 0); + } +} + +main(); diff --git a/src/content/book/el/05-structured-output.mdx b/src/content/book/el/05-structured-output.mdx index 19663a2d..73b66631 100644 --- a/src/content/book/el/05-structured-output.mdx +++ b/src/content/book/el/05-structured-output.mdx @@ -278,134 +278,134 @@ Tagline: _______________ Κείμενο: "Ο Tim Cook ανακοίνωσε ότι η Apple θα επενδύσει 1 δισεκατομμύριο δολάρια σε νέα εγκατάσταση στο Austin μέχρι τον Δεκέμβριο 2024."`} /> -## Multi-Part Structured Responses +## Πολυμερείς Δομημένες Απαντήσεις -When you need comprehensive output covering multiple aspects, define distinct parts with clear boundaries. Specify exactly what goes in each part—format, length, and content type. This prevents the model from blending sections or omitting parts. +Όταν χρειάζεστε ολοκληρωμένη έξοδο που καλύπτει πολλαπλές πτυχές, ορίστε ξεχωριστά μέρη με σαφή όρια. Καθορίστε ακριβώς τι πηγαίνει σε κάθε μέρος—μορφή, μήκος, και τύπος περιεχομένου. Αυτό αποτρέπει το μοντέλο από το να αναμιγνύει ενότητες ή να παραλείπει μέρη. ``` -Research this topic and provide: +Ερεύνησε αυτό το θέμα και δώσε: -### PART 1: EXECUTIVE SUMMARY -[2-3 sentence overview] +### ΜΕΡΟΣ 1: ΕΚΤΕΛΕΣΤΙΚΗ ΣΥΝΟΨΗ +[Επισκόπηση 2-3 προτάσεων] -### PART 2: KEY FINDINGS -[Exactly 5 bullet points] +### ΜΕΡΟΣ 2: ΒΑΣΙΚΑ ΕΥΡΗΜΑΤΑ +[Ακριβώς 5 κουκκίδες] -### PART 3: DATA TABLE -| Metric | Value | Source | -|--------|-------|--------| -[Include 5 rows minimum] +### ΜΕΡΟΣ 3: ΠΙΝΑΚΑΣ ΔΕΔΟΜΕΝΩΝ +| Μετρική | Τιμή | Πηγή | +|---------|------|------| +[Συμπερίλαβε τουλάχιστον 5 σειρές] -### PART 4: RECOMMENDATIONS -[Numbered list of 3 actionable recommendations] +### ΜΕΡΟΣ 4: ΣΥΣΤΑΣΕΙΣ +[Αριθμημένη λίστα 3 πρακτικών συστάσεων] -### PART 5: FURTHER READING -[3 suggested resources with brief descriptions] +### ΜΕΡΟΣ 5: ΠΕΡΑΙΤΕΡΩ ΑΝΑΓΝΩΣΗ +[3 προτεινόμενοι πόροι με σύντομες περιγραφές] ``` -## Conditional Formatting +## Υπό Συνθήκη Μορφοποίηση -Conditional formatting lets you define different output formats based on the input's characteristics. This is powerful for classification, triage, and routing systems where the response format should vary based on what the model detects. Use clear if/then logic with explicit output templates for each case. +Η υπό συνθήκη μορφοποίηση σας επιτρέπει να ορίσετε διαφορετικές μορφές εξόδου βάσει των χαρακτηριστικών της εισόδου. Αυτό είναι ισχυρό για συστήματα ταξινόμησης, διαλογής, και δρομολόγησης όπου η μορφή απάντησης πρέπει να ποικίλει βάσει του τι ανιχνεύει το μοντέλο. Χρησιμοποιήστε σαφή λογική if/then με ρητά templates εξόδου για κάθε περίπτωση. -## Arrays and Lists in JSON +## Πίνακες και Λίστες σε JSON -Extracting multiple items into arrays requires careful schema definition. Specify the array structure, what each item should contain, and how to handle edge cases (empty arrays, single items). Including a count field helps verify completeness. +Η εξαγωγή πολλαπλών στοιχείων σε πίνακες απαιτεί προσεκτικό ορισμό schema. Καθορίστε τη δομή πίνακα, τι πρέπει να περιέχει κάθε στοιχείο, και πώς να χειριστείτε ακραίες περιπτώσεις (κενοί πίνακες, μονά στοιχεία). Η συμπερίληψη πεδίου count βοηθά στην επαλήθευση πληρότητας. ``` -Extract all action items from this meeting transcript. +Εξαγάγε όλα τα action items από αυτό το πρακτικό συνάντησης. -Return as JSON array: +Επέστρεψε ως JSON array: { "action_items": [ { - "task": "string describing the task", - "assignee": "person name or 'Unassigned'", - "deadline": "date if mentioned, else null", + "task": "string που περιγράφει την εργασία", + "assignee": "όνομα ατόμου ή 'Μη ανατεθειμένο'", + "deadline": "ημερομηνία αν αναφέρεται, αλλιώς null", "priority": "high" | "medium" | "low", - "context": "relevant quote from transcript" + "context": "σχετικό απόσπασμα από πρακτικό" } ], "total_count": number } -Transcript: "[meeting transcript]" +Πρακτικό: "[πρακτικό συνάντησης]" ``` -## Validation Instructions +## Οδηγίες Επικύρωσης -Self-validation prompts the model to check its own output before responding. This catches common issues like missing sections, placeholder text, or constraint violations. The model will iterate internally to fix problems, improving output quality without additional API calls. +Η αυτο-επικύρωση προτρέπει το μοντέλο να ελέγξει τη δική του έξοδο πριν απαντήσει. Αυτό πιάνει κοινά προβλήματα όπως ελλείπουσες ενότητες, κείμενο placeholder, ή παραβιάσεις περιορισμών. Το μοντέλο θα επαναλάβει εσωτερικά για να διορθώσει προβλήματα, βελτιώνοντας την ποιότητα εξόδου χωρίς επιπλέον API κλήσεις. ``` -Generate the report, then: +Δημιούργησε την αναφορά, μετά: -VALIDATION CHECKLIST: -□ All required sections present -□ No placeholder text remaining -□ All statistics include sources -□ Word count within 500-700 words -□ Conclusion ties back to introduction +ΛΙΣΤΑ ΕΛΕΓΧΟΥ ΕΠΙΚΥΡΩΣΗΣ: +□ Όλες οι απαιτούμενες ενότητες παρούσες +□ Κανένα κείμενο placeholder δεν απομένει +□ Όλα τα στατιστικά περιλαμβάνουν πηγές +□ Αριθμός λέξεων εντός 500-700 λέξεων +□ Το συμπέρασμα συνδέεται με την εισαγωγή -If any check fails, fix before responding. +Αν οποιοσδήποτε έλεγχος αποτύχει, διόρθωσε πριν απαντήσεις. ``` -## Handling Optional Fields +## Χειρισμός Προαιρετικών Πεδίων -Real-world data often has missing values. Explicitly instruct the model on how to handle optional fields—using `null` is cleaner than empty strings and easier to process programmatically. Also prevent "hallucination" of missing data by emphasizing that the model should never invent information. +Τα δεδομένα πραγματικού κόσμου συχνά έχουν ελλείπουσες τιμές. Δώστε ρητές οδηγίες στο μοντέλο για το πώς να χειριστεί προαιρετικά πεδία—η χρήση `null` είναι καθαρότερη από κενά strings και ευκολότερη στην προγραμματική επεξεργασία. Επίσης αποτρέψτε την "παραισθησιογένεση" ελλειπόντων δεδομένων τονίζοντας ότι το μοντέλο δεν πρέπει ποτέ να επινοεί πληροφορίες. ``` -Extract contact information. Use null for missing fields. +Εξαγάγε στοιχεία επικοινωνίας. Χρησιμοποίησε null για ελλείποντα πεδία. { - "name": "string (required)", - "email": "string or null", - "phone": "string or null", - "company": "string or null", - "role": "string or null", - "linkedin": "URL string or null" + "name": "string (απαιτούμενο)", + "email": "string ή null", + "phone": "string ή null", + "company": "string ή null", + "role": "string ή null", + "linkedin": "URL string ή null" } -IMPORTANT: -- Never invent information not in the source -- Use null, not empty strings, for missing data -- Phone numbers in E.164 format if possible +ΣΗΜΑΝΤΙΚΟ: +- Ποτέ μην επινοείς πληροφορίες που δεν υπάρχουν στην πηγή +- Χρησιμοποίησε null, όχι κενά strings, για ελλείποντα δεδομένα +- Αριθμοί τηλεφώνου σε μορφή E.164 αν είναι δυνατόν ``` -## Summary +## Σύνοψη - -Be explicit about format, use examples, specify types, handle edge cases with null values, and ask the model to validate its own output. + +Να είστε ρητοί για τη μορφή, χρησιμοποιήστε παραδείγματα, καθορίστε τύπους, χειριστείτε ακραίες περιπτώσεις με null τιμές, και ζητήστε από το μοντέλο να επικυρώσει τη δική του έξοδο. -Structured outputs are essential for building reliable AI-powered applications. In the next chapter, we'll explore chain-of-thought prompting for complex reasoning tasks. +Οι δομημένες εξόδοι είναι απαραίτητες για τη δημιουργία αξιόπιστων εφαρμογών με AI. Στο επόμενο κεφάλαιο, θα εξερευνήσουμε το chain-of-thought prompting για πολύπλοκες εργασίες συλλογισμού. diff --git a/src/content/book/el/06-chain-of-thought.mdx b/src/content/book/el/06-chain-of-thought.mdx index e579be5d..6b8f2af5 100644 --- a/src/content/book/el/06-chain-of-thought.mdx +++ b/src/content/book/el/06-chain-of-thought.mdx @@ -1,226 +1,226 @@ -Chain of Thought (CoT) prompting is a technique that dramatically improves AI performance on complex reasoning tasks by asking the model to show its work step by step. +Το Chain of Thought (CoT) prompting είναι μια τεχνική που βελτιώνει δραματικά την απόδοση της AI σε πολύπλοκες εργασίες συλλογισμού ζητώντας από το μοντέλο να δείξει τη δουλειά του βήμα-βήμα. - -Just like a math teacher asking students to show their work, CoT prompting asks the AI to make its reasoning visible. + +Ακριβώς όπως ένας καθηγητής μαθηματικών ζητά από τους μαθητές να δείξουν τη δουλειά τους, το CoT prompting ζητά από την AI να κάνει τον συλλογισμό της ορατό. -## The Problem CoT Solves +## Το Πρόβλημα που Λύνει το CoT -AI models can struggle with multi-step reasoning when asked to jump directly to an answer. +Τα μοντέλα AI μπορεί να δυσκολεύονται με τον πολυβήματο συλλογισμό όταν τους ζητείται να πηδήξουν απευθείας στην απάντηση. -## Basic CoT Prompts +## Βασικά CoT Prompts -### Simple Trigger Phrases +### Απλές Φράσεις-Κλειδιά -Add one of these to your prompts: +Προσθέστε μία από αυτές στα prompts σας:
-
"Let's think step by step."
-
"Think through this carefully."
-
"Work through this problem methodically."
-
"Show your reasoning at each step."
-
"Explain your thought process."
+
"Ας σκεφτούμε βήμα-βήμα."
+
"Σκέψου αυτό προσεκτικά."
+
"Δούλεψε αυτό το πρόβλημα μεθοδικά."
+
"Δείξε τον συλλογισμό σου σε κάθε βήμα."
+
"Εξήγησε τη διαδικασία σκέψης σου."
-### Explicit Step Request +### Ρητό Αίτημα Βημάτων ## Zero-Shot vs Few-Shot CoT -There are two main approaches to Chain of Thought prompting, each with different trade-offs between simplicity and control. +Υπάρχουν δύο κύριες προσεγγίσεις στο Chain of Thought prompting, κάθε μία με διαφορετικές ανταλλαγές μεταξύ απλότητας και ελέγχου. ### Zero-Shot CoT -The simplest approach—just add a trigger phrase and let the model figure out how to reason. No examples needed. This works surprisingly well for many problems, though you have less control over the reasoning format. +Η απλούστερη προσέγγιση—απλά πρόσθεσε μια φράση-κλειδί και άφησε το μοντέλο να βρει πώς να συλλογιστεί. Δεν χρειάζονται παραδείγματα. Αυτό λειτουργεί εκπληκτικά καλά για πολλά προβλήματα, αν και έχεις λιγότερο έλεγχο στη μορφή συλλογισμού. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -Let's think step by step. -- John starts with 3 apples -- Half of 3 is 1.5, but we can't split apples -- If we round down: John gives 1 apple, keeps 2 -- After buying 4 more: 2 + 4 = 6 apples +Ας σκεφτούμε βήμα-βήμα. +- Ο Γιάννης ξεκινά με 3 μήλα +- Τα μισά του 3 είναι 1,5, αλλά δεν μπορούμε να χωρίσουμε μήλα +- Αν στρογγυλοποιήσουμε προς τα κάτω: Ο Γιάννης δίνει 1 μήλο, κρατά 2 +- Μετά την αγορά 4 ακόμα: 2 + 4 = 6 μήλα -Answer: 6 apples +Απάντηση: 6 μήλα ``` ### Few-Shot CoT -For more consistent results, show the model exactly how you want it to reason by providing worked examples. This gives you control over the reasoning style, format, and level of detail. The model will mimic your demonstrated pattern. +Για πιο συνεπή αποτελέσματα, δείξε στο μοντέλο ακριβώς πώς θέλεις να συλλογιστεί παρέχοντας επεξεργασμένα παραδείγματα. Αυτό σου δίνει έλεγχο στο στυλ συλλογισμού, τη μορφή, και το επίπεδο λεπτομέρειας. Το μοντέλο θα μιμηθεί το μοτίβο που επέδειξες. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -A: Let's work through this: -- Regular price: $3, Quantity: 12 -- Since 12 ≥ 10, the 25% discount applies -- Regular total: 12 × $3 = $36 -- Discount: 25% of $36 = $9 -- Final price: $36 - $9 = $27 +Α: Ας το δουλέψουμε: +- Κανονική τιμή: 3€, Ποσότητα: 12 +- Επειδή 12 ≥ 10, ισχύει η έκπτωση 25% +- Κανονικό σύνολο: 12 × 3€ = 36€ +- Έκπτωση: 25% των 36€ = 9€ +- Τελική τιμή: 36€ - 9€ = 27€ ``` -## Structured CoT Formats +## Δομημένες Μορφές CoT -For consistent, reproducible reasoning, use structured formats with named steps. These frameworks ensure the model doesn't skip important stages and makes outputs easier to parse and verify. +Για συνεπή, αναπαραγώγιμο συλλογισμό, χρησιμοποίησε δομημένες μορφές με ονομασμένα βήματα. Αυτά τα πλαίσια διασφαλίζουν ότι το μοντέλο δεν παραλείπει σημαντικά στάδια και κάνει τις εξόδους ευκολότερες στην ανάλυση και επαλήθευση. -### The BREAK Format +### Η Μορφή BREAK -A memorable acronym that guides the model through a complete problem-solving cycle, from understanding to verification. +Ένα αξέχαστο ακρωνύμιο που καθοδηγεί το μοντέλο μέσα από έναν πλήρη κύκλο επίλυσης προβλήματος, από την κατανόηση μέχρι την επαλήθευση. -### The Reasoning Template +### Το Template Συλλογισμού -A more formal structure that separates inputs, goals, and execution. Excellent for technical problems where you need clear documentation of the solution process. +Μια πιο επίσημη δομή που διαχωρίζει εισόδους, στόχους, και εκτέλεση. Εξαιρετική για τεχνικά προβλήματα όπου χρειάζεσαι σαφή τεκμηρίωση της διαδικασίας επίλυσης. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -GIVEN: 8L/100km, tank 45L, $1.50/L, drive 300km -GOAL: Calculate fuel cost -APPROACH: Fuel needed × cost per liter -STEPS: -1. Fuel = (300 ÷ 100) × 8 = 24 liters -2. Cost = 24 × $1.50 = $36 -VERIFICATION: 24L < 45L tank ✓ -ANSWER: $36 +ΔΕΔΟΜΕΝΑ: 8L/100km, ρεζερβουάρ 45L, 1,50€/L, οδήγηση 300km +ΣΤΟΧΟΣ: Υπολογισμός κόστους καυσίμου +ΠΡΟΣΕΓΓΙΣΗ: Καύσιμο που χρειάζεται × κόστος ανά λίτρο +ΒΗΜΑΤΑ: +1. Καύσιμο = (300 ÷ 100) × 8 = 24 λίτρα +2. Κόστος = 24 × 1,50€ = 36€ +ΕΠΑΛΗΘΕΥΣΗ: 24L < 45L ρεζερβουάρ ✓ +ΑΠΑΝΤΗΣΗ: 36€ ``` -## CoT for Different Problem Types +## CoT για Διαφορετικούς Τύπους Προβλημάτων -Different problem types benefit from different CoT approaches. Here are patterns optimized for common scenarios. +Διαφορετικοί τύποι προβλημάτων ωφελούνται από διαφορετικές προσεγγίσεις CoT. Εδώ είναι μοτίβα βελτιστοποιημένα για κοινά σενάρια. -### Mathematical Reasoning +### Μαθηματικός Συλλογισμός -Math problems benefit most from CoT because each step builds on the previous one. Errors compound, so showing work helps catch mistakes early. The model should clearly label each calculation. +Τα μαθηματικά προβλήματα ωφελούνται περισσότερο από το CoT επειδή κάθε βήμα χτίζει πάνω στο προηγούμενο. Τα σφάλματα πολλαπλασιάζονται, οπότε η επίδειξη δουλειάς βοηθά να πιαστούν λάθη νωρίς. Το μοντέλο πρέπει να επισημαίνει ξεκάθαρα κάθε υπολογισμό. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -Q1: $1,200,000 (given) -Q2: $1,200,000 × 1.15 = $1,380,000 -Q3: $1,380,000 × 0.90 = $1,242,000 -Q4: $1,242,000 × 1.25 = $1,552,500 +Q1: 1.200.000€ (δοσμένο) +Q2: 1.200.000€ × 1,15 = 1.380.000€ +Q3: 1.380.000€ × 0,90 = 1.242.000€ +Q4: 1.242.000€ × 1,25 = 1.552.500€ -Total: $5,374,500 +Σύνολο: 5.374.500€ ``` -### Logical Reasoning +### Λογικός Συλλογισμός -Logic puzzles require systematic elimination and hypothesis testing. CoT helps the model track constraints, test possibilities, and verify that all conditions are satisfied. The key is methodical exploration rather than guessing. +Τα λογικά παζλ απαιτούν συστηματικό αποκλεισμό και δοκιμή υποθέσεων. Το CoT βοηθά το μοντέλο να παρακολουθεί περιορισμούς, να δοκιμάζει πιθανότητες, και να επαληθεύει ότι όλες οι συνθήκες ικανοποιούνται. Το κλειδί είναι η μεθοδική εξερεύνηση αντί της εικασίας. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -From clue 3: Bob = teacher -→ Alice and Carol are engineer/doctor +Από το στοιχείο 3: Μπομπ = δάσκαλος +→ Αλίκη και Κάρολ είναι μηχανικός/γιατρός -If Carol = engineer: -- Carol has dog (clue 2) -- Alice = doctor, has fish (clue 1) -- Bob has cat +Αν Κάρολ = μηχανικός: +- Κάρολ έχει σκύλο (στοιχείο 2) +- Αλίκη = γιατρός, έχει ψάρι (στοιχείο 1) +- Μπομπ έχει γάτα -Verify: All 4 clues satisfied ✓ -Answer: Alice (doctor, fish), Bob (teacher, cat), Carol (engineer, dog) +Επαλήθευση: Όλα τα 4 στοιχεία ικανοποιούνται ✓ +Απάντηση: Αλίκη (γιατρός, ψάρι), Μπομπ (δάσκαλος, γάτα), Κάρολ (μηχανικός, σκύλος) ``` -### Code Debugging +### Αποσφαλμάτωση Κώδικα -Debugging benefits from CoT because it forces the model to trace execution rather than guess at bugs. By walking through the code with concrete values, the actual behavior becomes visible and discrepancies with expected behavior are exposed. +Η αποσφαλμάτωση ωφελείται από το CoT επειδή αναγκάζει το μοντέλο να ιχνηλατήσει την εκτέλεση αντί να μαντεύει bugs. Περπατώντας μέσα από τον κώδικα με συγκεκριμένες τιμές, η πραγματική συμπεριφορά γίνεται ορατή και οι αποκλίσεις από την αναμενόμενη συμπεριφορά εκτίθενται. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -Trace [2, 3, 4, 6]: -n=2: total += 1 → 1 (wait, adding 1 not n!) -n=3: skip (odd) +Ιχνηλάτηση [2, 3, 4, 6]: +n=2: total += 1 → 1 (περίμενε, προσθέτει 1 όχι n!) +n=3: παράβλεψη (μονός) n=4: total = 2 n=6: total = 3 -BUG: "total += 1" should be "total += n" -Expected: 12, Got: 3 -Fix: Change to "total += n" +BUG: "total += 1" πρέπει να είναι "total += n" +Αναμενόμενο: 12, Πήρε: 3 +Διόρθωση: Άλλαξε σε "total += n" ``` -## Self-Consistency with CoT +## Αυτο-συνέπεια με CoT -For critical problems, don't rely on a single reasoning path. Generate multiple independent solutions and compare results. If different approaches converge on the same answer, confidence is high. Disagreement signals the need for careful review. +Για κρίσιμα προβλήματα, μην βασίζεσαι σε ένα μόνο μονοπάτι συλλογισμού. Δημιούργησε πολλαπλές ανεξάρτητες λύσεις και σύγκρινε αποτελέσματα. Αν διαφορετικές προσεγγίσεις συγκλίνουν στην ίδια απάντηση, η εμπιστοσύνη είναι υψηλή. Η διαφωνία σηματοδοτεί την ανάγκη για προσεκτική αναθεώρηση. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -Approach 1 (Algebra): c + w = 30, 2c + 4w = 74 → c=23, w=7 -Approach 2 (Guess): Try 23/7 → 46 + 28 = 74 ✓ -Approach 3 (Logic): 30 chickens = 60 legs, need 14 more → 7 cows +Προσέγγιση 1 (Άλγεβρα): κ + α = 30, 2κ + 4α = 74 → κ=23, α=7 +Προσέγγιση 2 (Δοκιμή): Δοκίμασε 23/7 → 46 + 28 = 74 ✓ +Προσέγγιση 3 (Λογική): 30 κότες = 60 πόδια, χρειάζονται 14 ακόμα → 7 αγελάδες -All agree: 23 chickens, 7 cows +Όλες συμφωνούν: 23 κότες, 7 αγελάδες ``` -## CoT for Decision Making +## CoT για Λήψη Αποφάσεων -Decisions involve weighing trade-offs across multiple dimensions. CoT ensures all relevant factors are considered systematically rather than jumping to conclusions. This structured approach also documents the reasoning for future reference. +Οι αποφάσεις περιλαμβάνουν στάθμιση ανταλλαγών σε πολλαπλές διαστάσεις. Το CoT διασφαλίζει ότι όλοι οι σχετικοί παράγοντες εξετάζονται συστηματικά αντί να πηδάμε σε συμπεράσματα. Αυτή η δομημένη προσέγγιση επίσης τεκμηριώνει τον συλλογισμό για μελλοντική αναφορά. -**Example Output:** +**Παράδειγμα Εξόδου:** ``` -FACTORS: -- Team size (5): Too small for microservices ❌ -- Scale (100 DAU): No scaling need ❌ -- Velocity: Monolith = faster iteration ❌ -- Future growth: Uncertain timeline ⚠️ +ΠΑΡΑΓΟΝΤΕΣ: +- Μέγεθος ομάδας (5): Πολύ μικρό για microservices ❌ +- Κλίμακα (100 DAU): Καμία ανάγκη κλιμάκωσης ❌ +- Ταχύτητα: Monolith = γρηγορότερη επανάληψη ❌ +- Μελλοντική ανάπτυξη: Αβέβαιο χρονοδιάγραμμα ⚠️ -WEIGHING: 3 strong against, 1 weak for +ΣΤΑΘΜΙΣΗ: 3 ισχυρά κατά, 1 αδύναμο υπέρ -RECOMMENDATION: Stay monolith, use clear module -boundaries to ease future transition. +ΣΥΣΤΑΣΗ: Μείνε monolith, χρησιμοποίησε σαφή όρια +modules για να διευκολύνεις μελλοντική μετάβαση. ``` -## When to Use CoT +## Πότε να Χρησιμοποιήσεις CoT
-

Use CoT For

+

Χρησιμοποίησε CoT Για

-

**Math problems** — Reduces calculation errors

-

**Logic puzzles** — Prevents skipped steps

-

**Complex analysis** — Organizes thinking

-

**Code debugging** — Traces execution

-

**Decision making** — Weighs trade-offs

+

**Μαθηματικά προβλήματα** — Μειώνει σφάλματα υπολογισμού

+

**Λογικά παζλ** — Αποτρέπει παραλειπόμενα βήματα

+

**Πολύπλοκη ανάλυση** — Οργανώνει τη σκέψη

+

**Αποσφαλμάτωση κώδικα** — Ιχνηλατεί εκτέλεση

+

**Λήψη αποφάσεων** — Σταθμίζει ανταλλαγές

-

Skip CoT For

+

Παράλειψε CoT Για

-

**Simple Q&A** — Unnecessary overhead

-

**Creative writing** — Can constrain creativity

-

**Factual lookups** — No reasoning needed

-

**Translation** — Direct task

-

**Summarization** — Usually straightforward

+

**Απλές Ερωτοαπαντήσεις** — Περιττή επιβάρυνση

+

**Δημιουργική γραφή** — Μπορεί να περιορίσει δημιουργικότητα

+

**Αναζήτηση γεγονότων** — Δεν χρειάζεται συλλογισμός

+

**Μετάφραση** — Άμεση εργασία

+

**Σύνοψη** — Συνήθως απλή

-## CoT Limitations +## Περιορισμοί CoT -While powerful, Chain of Thought isn't a silver bullet. Understanding its limitations helps you apply it appropriately. +Αν και ισχυρό, το Chain of Thought δεν είναι πανάκεια. Η κατανόηση των περιορισμών του βοηθά να το εφαρμόσεις κατάλληλα. -1. **Increased token usage** — More output means higher costs -2. **Not always needed** — Simple tasks don't benefit -3. **Can be verbose** — May need to ask for conciseness -4. **Reasoning can be flawed** — CoT doesn't guarantee correctness +1. **Αυξημένη χρήση tokens** — Περισσότερη έξοδος σημαίνει υψηλότερο κόστος +2. **Δεν χρειάζεται πάντα** — Απλές εργασίες δεν ωφελούνται +3. **Μπορεί να είναι φλύαρο** — Μπορεί να χρειαστεί να ζητήσεις συνοπτικότητα +4. **Ο συλλογισμός μπορεί να είναι λάθος** — Το CoT δεν εγγυάται ορθότητα -## Summary +## Σύνοψη - -CoT dramatically improves complex reasoning by making implicit steps explicit. Use it for math, logic, analysis, and debugging. Trade-off: better accuracy for more tokens. + +Το CoT βελτιώνει δραματικά τον πολύπλοκο συλλογισμό κάνοντας τα σιωπηρά βήματα ρητά. Χρησιμοποίησέ το για μαθηματικά, λογική, ανάλυση, και αποσφαλμάτωση. Ανταλλαγή: καλύτερη ακρίβεια για περισσότερα tokens. -In the next chapter, we'll explore few-shot learning—teaching the model through examples. +Στο επόμενο κεφάλαιο, θα εξερευνήσουμε το few-shot learning—διδάσκοντας το μοντέλο μέσω παραδειγμάτων. diff --git a/src/content/book/el/07-few-shot-learning.mdx b/src/content/book/el/07-few-shot-learning.mdx index 24e98f1d..fac124f5 100644 --- a/src/content/book/el/07-few-shot-learning.mdx +++ b/src/content/book/el/07-few-shot-learning.mdx @@ -1,32 +1,32 @@ -Few-shot learning is one of the most powerful prompting techniques. By providing examples of what you want, you can teach the model complex tasks without any fine-tuning. +Η μάθηση με λίγα παραδείγματα (few-shot learning) είναι μία από τις πιο ισχυρές τεχνικές prompting. Παρέχοντας παραδείγματα του τι θέλετε, μπορείτε να διδάξετε στο μοντέλο πολύπλοκες εργασίες χωρίς καμία λεπτομερή ρύθμιση. - -Just like humans learn by seeing examples, AI models can learn patterns from the examples you provide in your prompt. + +Ακριβώς όπως οι άνθρωποι μαθαίνουν βλέποντας παραδείγματα, τα μοντέλα AI μπορούν να μάθουν μοτίβα από τα παραδείγματα που παρέχετε στο prompt σας. -## What is Few-Shot Learning? +## Τι είναι η Μάθηση με Λίγα Παραδείγματα; -Few-shot learning shows the model examples of input-output pairs before asking it to perform the same task. The model learns the pattern from your examples and applies it to new inputs. +Η μάθηση με λίγα παραδείγματα δείχνει στο μοντέλο παραδείγματα ζευγών εισόδου-εξόδου πριν του ζητήσει να εκτελέσει την ίδια εργασία. Το μοντέλο μαθαίνει το μοτίβο από τα παραδείγματά σας και το εφαρμόζει σε νέες εισόδους. @@ -49,430 +49,430 @@ Now classify: -## Why Examples Work +## Γιατί Λειτουργούν τα Παραδείγματα -Examples communicate: -- **Format**: How output should be structured -- **Style**: Tone, length, vocabulary -- **Logic**: The reasoning pattern to follow -- **Edge cases**: How to handle special situations +Τα παραδείγματα επικοινωνούν: +- **Μορφή**: Πώς πρέπει να δομηθεί η έξοδος +- **Στυλ**: Τόνος, μήκος, λεξιλόγιο +- **Λογική**: Το μοτίβο συλλογισμού που πρέπει να ακολουθηθεί +- **Ακραίες περιπτώσεις**: Πώς να χειριστείς ειδικές καταστάσεις -## Basic Few-Shot Pattern +## Βασικό Μοτίβο Few-Shot -The fundamental structure of few-shot prompting follows a simple pattern: show examples, then ask for the new task. Consistency in formatting between examples is crucial. The model learns from the pattern you establish. +Η θεμελιώδης δομή του few-shot prompting ακολουθεί ένα απλό μοτίβο: δείξε παραδείγματα, μετά ζήτα τη νέα εργασία. Η συνέπεια στη μορφοποίηση μεταξύ παραδειγμάτων είναι κρίσιμη. Το μοντέλο μαθαίνει από το μοτίβο που καθιερώνεις. ``` -[Example 1] -Input: [input 1] -Output: [output 1] +[Παράδειγμα 1] +Είσοδος: [είσοδος 1] +Έξοδος: [έξοδος 1] -[Example 2] -Input: [input 2] -Output: [output 2] +[Παράδειγμα 2] +Είσοδος: [είσοδος 2] +Έξοδος: [έξοδος 2] -[Example 3] -Input: [input 3] -Output: [output 3] +[Παράδειγμα 3] +Είσοδος: [είσοδος 3] +Έξοδος: [έξοδος 3] -Now do this one: -Input: [new input] -Output: +Τώρα κάνε αυτό: +Είσοδος: [νέα είσοδος] +Έξοδος: ``` -## Few-Shot for Classification +## Few-Shot για Ταξινόμηση -Classification is one of the strongest use cases for few-shot learning. By showing examples of each category, you define the boundaries between classes more precisely than instructions alone could achieve. +Η ταξινόμηση είναι μία από τις ισχυρότερες περιπτώσεις χρήσης για μάθηση με λίγα παραδείγματα. Δείχνοντας παραδείγματα κάθε κατηγορίας, ορίζεις τα όρια μεταξύ κλάσεων πιο ακριβώς από ό,τι θα μπορούσαν οι οδηγίες μόνες τους. -### Sentiment Analysis +### Ανάλυση Συναισθήματος - -Sentiment analysis classifies text by emotional tone: positive, negative, neutral, or mixed. It's widely used for customer feedback, social media monitoring, and brand perception tracking. + +Η ανάλυση συναισθήματος ταξινομεί κείμενο βάσει συναισθηματικού τόνου: θετικό, αρνητικό, ουδέτερο, ή μικτό. Χρησιμοποιείται ευρέως για ανατροφοδότηση πελατών, παρακολούθηση μέσων κοινωνικής δικτύωσης, και παρακολούθηση αντίληψης μάρκας. -Sentiment classification benefits from showing examples of each sentiment type, especially edge cases like "mixed" sentiment that might be ambiguous. +Η ταξινόμηση συναισθήματος ωφελείται από την επίδειξη παραδειγμάτων κάθε τύπου συναισθήματος, ειδικά ακραίες περιπτώσεις όπως "μικτό" συναίσθημα που μπορεί να είναι διφορούμενο. - +Τώρα ταξινόμησε: +Κριτική: "Αγαπώ τον σχεδιασμό αλλά η διάρκεια μπαταρίας είναι απογοητευτική." +Συναίσθημα:`} /> -### Topic Classification +### Ταξινόμηση Θεμάτων -For multi-class categorization, include at least one example per category. This helps the model understand your specific taxonomy, which may differ from its default understanding. +Για κατηγοριοποίηση πολλαπλών κλάσεων, συμπεριλάβετε τουλάχιστον ένα παράδειγμα ανά κατηγορία. Αυτό βοηθά το μοντέλο να κατανοήσει τη συγκεκριμένη ταξονομία σας, που μπορεί να διαφέρει από την προεπιλεγμένη κατανόησή του. - +Τώρα κατηγοριοποίησε: +Αίτημα: "Η πληρωμή μου απορρίφθηκε αλλά βλέπω τη χρέωση στην κάρτα μου" +Κατηγορία:`} /> -## Few-Shot for Transformation +## Few-Shot για Μετασχηματισμό -Transformation tasks convert input from one form to another while preserving meaning. Examples are essential here because they define exactly what "transformation" means for your use case. +Οι εργασίες μετασχηματισμού μετατρέπουν είσοδο από μία μορφή σε άλλη διατηρώντας το νόημα. Τα παραδείγματα είναι απαραίτητα εδώ επειδή ορίζουν ακριβώς τι σημαίνει "μετασχηματισμός" για την περίπτωση χρήσης σας. -### Text Rewriting +### Αναδιατύπωση Κειμένου -Style transformation requires examples that show the exact tone shift you want. Abstract instructions like "make it professional" are interpreted differently. Examples make it concrete. +Ο μετασχηματισμός στυλ απαιτεί παραδείγματα που δείχνουν την ακριβή αλλαγή τόνου που θέλετε. Αφηρημένες οδηγίες όπως "κάντο επαγγελματικό" ερμηνεύονται διαφορετικά. Τα παραδείγματα το κάνουν συγκεκριμένο. - +Τώρα ξαναγράψε: +Ανεπίσημο: "Δεν μπορώ να έρθω στη συνάντηση, προέκυψε κάτι." +Επαγγελματικό:`} /> -### Format Conversion +### Μετατροπή Μορφής -Format conversion tasks benefit from examples showing edge cases and ambiguous inputs. The model learns your specific conventions for handling tricky cases. +Οι εργασίες μετατροπής μορφής ωφελούνται από παραδείγματα που δείχνουν ακραίες περιπτώσεις και διφορούμενες εισόδους. Το μοντέλο μαθαίνει τις συγκεκριμένες συμβάσεις σας για χειρισμό δύσκολων περιπτώσεων. - +Τώρα μετάτρεψε: +Είσοδος: "τη πρώτη Δευτέρα του επόμενου μήνα" +Έξοδος:`} /> -## Few-Shot for Generation +## Few-Shot για Παραγωγή -Generation tasks create new content following a learned pattern. Examples establish length, structure, tone, and what details to highlight. These are hard to specify in instructions alone. +Οι εργασίες παραγωγής δημιουργούν νέο περιεχόμενο ακολουθώντας ένα μαθημένο μοτίβο. Τα παραδείγματα καθιερώνουν μήκος, δομή, τόνο, και ποιες λεπτομέρειες να τονιστούν. Αυτά είναι δύσκολο να καθοριστούν μόνο με οδηγίες. -### Product Descriptions +### Περιγραφές Προϊόντων -Marketing copy benefits enormously from examples because they capture brand voice, feature emphasis, and persuasive techniques that are difficult to describe abstractly. +Το marketing copy ωφελείται τεράστια από παραδείγματα επειδή αποτυπώνουν τη φωνή της μάρκας, την έμφαση χαρακτηριστικών, και πειστικές τεχνικές που είναι δύσκολο να περιγραφούν αφηρημένα. - +Τώρα γράψε: +Προϊόν: Φορητός Φορτιστής Τηλεφώνου +Περιγραφή:`} /> -### Code Documentation +### Τεκμηρίωση Κώδικα - -Good documentation explains what code does, its parameters, return values, and usage examples. Consistent docstrings enable auto-generated API docs and help IDEs provide better code completion. + +Η καλή τεκμηρίωση εξηγεί τι κάνει ο κώδικας, τις παραμέτρους του, τις τιμές επιστροφής, και παραδείγματα χρήσης. Τα συνεπή docstrings επιτρέπουν αυτόματα παραγόμενα API docs και βοηθούν τα IDEs να παρέχουν καλύτερη αυτόματη συμπλήρωση κώδικα. -Documentation style varies widely between projects. Examples teach your specific format, what to include (args, returns, examples), and the level of detail expected. +Το στυλ τεκμηρίωσης ποικίλλει ευρέως μεταξύ projects. Τα παραδείγματα διδάσκουν τη συγκεκριμένη μορφή σας, τι να συμπεριλάβετε (args, returns, examples), και το επίπεδο λεπτομέρειας που αναμένεται. ->> calculate_bmi(70, 1.75) 22.86 """ -Now document: -Function: +Τώρα τεκμηρίωσε: +Συνάρτηση: def is_palindrome(text): cleaned = ''.join(c.lower() for c in text if c.isalnum()) return cleaned == cleaned[::-1] -Documentation:`} /> +Τεκμηρίωση:`} /> -## Few-Shot for Extraction +## Few-Shot για Εξαγωγή -Extraction tasks pull structured information from unstructured text. Examples define which entities matter, how to format output, and how to handle cases where information is missing or ambiguous. +Οι εργασίες εξαγωγής αντλούν δομημένη πληροφορία από μη δομημένο κείμενο. Τα παραδείγματα ορίζουν ποιες οντότητες έχουν σημασία, πώς να μορφοποιηθεί η έξοδος, και πώς να χειριστούν περιπτώσεις όπου η πληροφορία λείπει ή είναι διφορούμενη. -### Entity Extraction +### Εξαγωγή Οντοτήτων - -Named Entity Recognition (NER) identifies and classifies named entities in text into categories like persons, organizations, locations, dates, and products. It's fundamental for information retrieval and knowledge graphs. + +Η Αναγνώριση Ονομασμένων Οντοτήτων (NER) αναγνωρίζει και ταξινομεί ονομασμένες οντότητες σε κείμενο σε κατηγορίες όπως πρόσωπα, οργανισμούς, τοποθεσίες, ημερομηνίες, και προϊόντα. Είναι θεμελιώδης για ανάκτηση πληροφοριών και γράφους γνώσης. -NER benefits from examples showing your specific entity types and how to handle entities that could fit multiple categories. +Η NER ωφελείται από παραδείγματα που δείχνουν τους συγκεκριμένους τύπους οντοτήτων σας και πώς να χειριστείτε οντότητες που θα μπορούσαν να ταιριάζουν σε πολλαπλές κατηγορίες. - +Τώρα εξαγάγε από: +Κείμενο: "Η SpaceX του Elon Musk εκτόξευσε 23 δορυφόρους Starlink από το Cape Canaveral στις 3 Δεκεμβρίου." +Οντότητες:`} /> -### Structured Data Extraction +### Εξαγωγή Δομημένων Δεδομένων -Extracting structured data from natural language requires examples showing how to handle missing fields, implicit information, and varying input formats. +Η εξαγωγή δομημένων δεδομένων από φυσική γλώσσα απαιτεί παραδείγματα που δείχνουν πώς να χειριστείτε ελλείποντα πεδία, υπονοούμενη πληροφορία, και ποικίλες μορφές εισόδου. - +Συνάντηση:`} /> -## Advanced Few-Shot Techniques +## Προχωρημένες Τεχνικές Few-Shot -Beyond basic few-shot, several techniques can improve results for complex tasks. +Πέρα από το βασικό few-shot, αρκετές τεχνικές μπορούν να βελτιώσουν τα αποτελέσματα για πολύπλοκες εργασίες. -### Diverse Examples +### Ποικίλα Παραδείγματα -Diversity in examples is more valuable than quantity. Cover different scenarios, edge cases, and potential ambiguities rather than showing similar examples repeatedly. +Η ποικιλία στα παραδείγματα είναι πιο πολύτιμη από την ποσότητα. Καλύψτε διαφορετικά σενάρια, ακραίες περιπτώσεις, και πιθανές ασάφειες αντί να δείχνετε παρόμοια παραδείγματα επανειλημμένα. - +Τώρα απάντησε: +Πελάτης: "Το προϊόν δεν ταιριάζει με αυτό που φαινόταν στην ιστοσελίδα." +Απάντηση:`} /> -### Negative Examples +### Αρνητικά Παραδείγματα - -Showing "good" vs "bad" examples is called contrastive learning. It helps the model understand not just what you want, but what to avoid. This is especially useful for style and quality judgments. + +Η επίδειξη "καλών" έναντι "κακών" παραδειγμάτων ονομάζεται αντιπαραβολική μάθηση. Βοηθά το μοντέλο να κατανοήσει όχι μόνο τι θέλετε, αλλά και τι να αποφύγει. Αυτό είναι ιδιαίτερα χρήσιμο για κρίσεις στυλ και ποιότητας. -Sometimes showing what *not* to do is as valuable as showing correct examples. Negative examples help the model understand boundaries and avoid common mistakes. +Μερικές φορές η επίδειξη του τι *να μην κάνεις* είναι εξίσου πολύτιμη με τα σωστά παραδείγματα. Τα αρνητικά παραδείγματα βοηθούν το μοντέλο να κατανοήσει όρια και να αποφύγει κοινά λάθη. - +Τώρα γράψε θέμα για: +Email σχετικά με: Ζήτηση ανατροφοδότησης για draft πρότασης +Θέμα:`} /> -### Edge Case Examples +### Παραδείγματα Ακραίων Περιπτώσεων -Edge cases often determine whether a solution works in production. Including unusual inputs in your examples prevents the model from failing on real-world data that doesn't fit the "happy path." +Οι ακραίες περιπτώσεις συχνά καθορίζουν αν μια λύση λειτουργεί στην παραγωγή. Η συμπερίληψη ασυνήθιστων εισόδων στα παραδείγματά σας αποτρέπει το μοντέλο από το να αποτύχει σε δεδομένα πραγματικού κόσμου που δεν ταιριάζουν στην "ευτυχή διαδρομή". - +Τώρα ανάλυσε: +Είσοδος: "Sir Patrick Stewart III" +Έξοδος:`} /> -## How Many Examples? +## Πόσα Παραδείγματα;
- Simple classification + Απλή ταξινόμηση 2-3 - One per category minimum + Ελάχιστο ένα ανά κατηγορία
- Complex formatting + Πολύπλοκη μορφοποίηση 3-5 - Show variations + Δείξε παραλλαγές
- Nuanced style + Λεπτό στυλ 4-6 - Capture full range + Κάλυψε πλήρες εύρος
- Edge cases + Ακραίες περιπτώσεις 1-2 - Alongside normal examples + Μαζί με κανονικά παραδείγματα
-## Example Quality Matters +## Η Ποιότητα Παραδειγμάτων Έχει Σημασία -## Combining Few-Shot with Other Techniques +## Συνδυασμός Few-Shot με Άλλες Τεχνικές -Few-shot learning combines powerfully with other prompting techniques. The examples provide the "what" while other techniques can add context, reasoning, or structure. +Η μάθηση με λίγα παραδείγματα συνδυάζεται ισχυρά με άλλες τεχνικές prompting. Τα παραδείγματα παρέχουν το "τι" ενώ άλλες τεχνικές μπορούν να προσθέσουν πλαίσιο, συλλογισμό, ή δομή. -### Few-Shot + Role +### Few-Shot + Ρόλος -Adding a role gives the model context for *why* it's doing the task, which can improve quality and consistency. +Η προσθήκη ρόλου δίνει στο μοντέλο πλαίσιο για το *γιατί* κάνει την εργασία, που μπορεί να βελτιώσει ποιότητα και συνέπεια. ``` -You are a legal contract reviewer. +Είσαι αναθεωρητής νομικών συμβολαίων. -[examples of contract clause analysis] +[παραδείγματα ανάλυσης ρητρών συμβολαίου] -Now analyze: [new clause] +Τώρα ανάλυσε: [νέα ρήτρα] ``` ### Few-Shot + CoT -Combining few-shot with Chain of Thought shows not just *what* answer to give, but *how* to reason through to that answer. This is powerful for tasks requiring judgment. +Ο συνδυασμός few-shot με Chain of Thought δείχνει όχι μόνο *ποια* απάντηση να δώσεις, αλλά *πώς* να συλλογιστείς για να φτάσεις σε αυτή την απάντηση. Αυτό είναι ισχυρό για εργασίες που απαιτούν κρίση. ``` -Classify and explain reasoning. +Ταξινόμησε και εξήγησε τον συλλογισμό. -Review: "Great features but overpriced" -Thinking: The review mentions positive aspects ("great features") -but also a significant negative ("overpriced"). The negative seems -to outweigh the positive based on the "but" conjunction. -Classification: Mixed-Negative +Κριτική: "Εξαιρετικά χαρακτηριστικά αλλά υπερτιμημένο" +Σκέψη: Η κριτική αναφέρει θετικές πτυχές ("εξαιρετικά χαρακτηριστικά") +αλλά επίσης ένα σημαντικό αρνητικό ("υπερτιμημένο"). Το αρνητικό φαίνεται +να υπερτερεί του θετικού βάσει του συνδέσμου "αλλά". +Ταξινόμηση: Μικτή-Αρνητική -[more examples with reasoning] +[περισσότερα παραδείγματα με συλλογισμό] -Now classify with reasoning: -Review: "Exactly what I needed, arrived faster than expected" +Τώρα ταξινόμησε με συλλογισμό: +Κριτική: "Ακριβώς αυτό που χρειαζόμουν, έφτασε πιο γρήγορα απ' ότι περίμενα" ``` -## Summary +## Σύνοψη - -Few-shot learning teaches through demonstration and is often more effective than instructions alone. Use 2-5 diverse, correct examples and combine with other techniques for best results. + +Η μάθηση με λίγα παραδείγματα διδάσκει μέσω επίδειξης και είναι συχνά πιο αποτελεσματική από τις οδηγίες μόνες τους. Χρησιμοποιήστε 2-5 ποικίλα, σωστά παραδείγματα και συνδυάστε με άλλες τεχνικές για τα καλύτερα αποτελέσματα. -In the next chapter, we'll explore iterative refinement: the art of improving prompts through successive attempts. +Στο επόμενο κεφάλαιο, θα εξερευνήσουμε την επαναληπτική βελτίωση: την τέχνη της βελτίωσης prompts μέσω διαδοχικών προσπαθειών. diff --git a/src/content/book/el/08-iterative-refinement.mdx b/src/content/book/el/08-iterative-refinement.mdx index 769f879a..7a29f4d9 100644 --- a/src/content/book/el/08-iterative-refinement.mdx +++ b/src/content/book/el/08-iterative-refinement.mdx @@ -1,218 +1,218 @@ -Prompt engineering is rarely a one-shot process. The best prompts emerge through iteration—testing, observing, and refining until you achieve the desired results. +Η μηχανική prompt σπάνια είναι μια διαδικασία μίας προσπάθειας. Τα καλύτερα prompts προκύπτουν μέσω επανάληψης—δοκιμάζοντας, παρατηρώντας, και βελτιώνοντας μέχρι να πετύχετε τα επιθυμητά αποτελέσματα. - -Think of your first prompt as a rough draft. Even experienced prompt engineers rarely nail it on the first try. + +Σκεφτείτε το πρώτο σας prompt ως πρόχειρο. Ακόμα και οι έμπειροι prompt engineers σπάνια το πετυχαίνουν από την πρώτη. -## The Iteration Cycle +## Ο Κύκλος Επανάληψης -Effective prompt refinement follows a predictable cycle: write, test, analyze, and improve. Each iteration brings you closer to a prompt that reliably produces the results you need. +Η αποτελεσματική βελτίωση prompt ακολουθεί έναν προβλέψιμο κύκλο: γράψε, δοκίμασε, ανάλυσε, και βελτίωσε. Κάθε επανάληψη σε φέρνει πιο κοντά σε ένα prompt που παράγει αξιόπιστα τα αποτελέσματα που χρειάζεσαι. -## Common Refinement Patterns +## Κοινά Μοτίβα Βελτίωσης -Most prompt failures fall into a handful of categories. Learning to recognize these patterns lets you quickly diagnose and fix issues without starting from scratch. +Οι περισσότερες αποτυχίες prompt εμπίπτουν σε λίγες κατηγορίες. Μαθαίνοντας να αναγνωρίζεις αυτά τα μοτίβα σου επιτρέπει να διαγνώσεις και να διορθώσεις γρήγορα προβλήματα χωρίς να ξεκινήσεις από την αρχή. -### Problem: Output Too Long +### Πρόβλημα: Έξοδος Πολύ Μεγάλη -One of the most common issues. Without explicit constraints, models tend to be thorough rather than concise. +Ένα από τα πιο κοινά ζητήματα. Χωρίς ρητούς περιορισμούς, τα μοντέλα τείνουν να είναι διεξοδικά αντί για συνοπτικά. -### Problem: Output Too Vague +### Πρόβλημα: Έξοδος Πολύ Ασαφής -Vague prompts produce vague outputs. The model can't read your mind about what "better" means or which aspects matter most to you. +Τα ασαφή prompts παράγουν ασαφείς εξόδους. Το μοντέλο δεν μπορεί να διαβάσει το μυαλό σου για το τι σημαίνει "καλύτερο" ή ποιες πτυχές σε ενδιαφέρουν περισσότερο. -### Problem: Wrong Tone +### Πρόβλημα: Λάθος Τόνος -Tone is subjective and varies by context. What sounds "professional" to the model might not match your organization's voice or the relationship with your recipient. +Ο τόνος είναι υποκειμενικός και ποικίλλει ανά πλαίσιο. Αυτό που ακούγεται "επαγγελματικό" στο μοντέλο μπορεί να μην ταιριάζει με τη φωνή του οργανισμού σας ή τη σχέση με τον παραλήπτη σας. -### Problem: Missing Key Information +### Πρόβλημα: Λείπουν Βασικές Πληροφορίες -Open-ended requests get open-ended responses. If you need specific types of feedback, you must ask for them explicitly. +Τα ανοιχτά αιτήματα λαμβάνουν ανοιχτές απαντήσεις. Αν χρειάζεσαι συγκεκριμένους τύπους ανατροφοδότησης, πρέπει να τους ζητήσεις ρητά. -### Problem: Inconsistent Format +### Πρόβλημα: Ασυνεπής Μορφή -Without a template, the model will structure each response differently, making comparison difficult and automation impossible. +Χωρίς template, το μοντέλο θα δομεί κάθε απάντηση διαφορετικά, κάνοντας τη σύγκριση δύσκολη και τον αυτοματισμό αδύνατο. -## Systematic Refinement Approach +## Συστηματική Προσέγγιση Βελτίωσης -Random changes waste time. A systematic approach helps you identify problems quickly and fix them efficiently. +Οι τυχαίες αλλαγές σπαταλούν χρόνο. Μια συστηματική προσέγγιση βοηθά να εντοπίσεις προβλήματα γρήγορα και να τα διορθώσεις αποτελεσματικά. -### Step 1: Diagnose the Issue +### Βήμα 1: Διάγνωσε το Πρόβλημα -Before changing anything, identify what's actually wrong. Use this diagnostic table to map symptoms to solutions: +Πριν αλλάξεις οτιδήποτε, εντόπισε τι πραγματικά δεν πάει καλά. Χρησιμοποίησε αυτόν τον διαγνωστικό πίνακα για να αντιστοιχίσεις συμπτώματα με λύσεις:
- Symptom - Likely Cause - Solution + Σύμπτωμα + Πιθανή Αιτία + Λύση
- Too long - No length constraint - Add word/sentence limits + Πολύ μεγάλο + Χωρίς περιορισμό μήκους + Πρόσθεσε όρια λέξεων/προτάσεων
- Too short - Lacks detail request - Ask for elaboration + Πολύ μικρό + Λείπει αίτημα λεπτομέρειας + Ζήτησε επεξήγηση
- Off-topic - Vague instructions - Be more specific + Εκτός θέματος + Ασαφείς οδηγίες + Γίνε πιο συγκεκριμένος
- Wrong format - Format not specified - Define exact structure + Λάθος μορφή + Η μορφή δεν καθορίστηκε + Όρισε ακριβή δομή
- Wrong tone - Audience not clear - Specify audience/style + Λάθος τόνος + Το κοινό δεν είναι σαφές + Καθόρισε κοινό/στυλ
- Inconsistent - No examples provided - Add few-shot examples + Ασυνεπές + Δεν δόθηκαν παραδείγματα + Πρόσθεσε few-shot παραδείγματα
-### Step 2: Make Targeted Changes +### Βήμα 2: Κάνε Στοχευμένες Αλλαγές -Resist the urge to rewrite everything. Changing multiple variables at once makes it impossible to know what helped and what hurt. Make one change, test it, then proceed: +Αντίσταση στην παρόρμηση να ξαναγράψεις τα πάντα. Η αλλαγή πολλαπλών μεταβλητών ταυτόχρονα καθιστά αδύνατο να ξέρεις τι βοήθησε και τι έβλαψε. Κάνε μία αλλαγή, δοκίμασέ την, μετά προχώρα: ``` -Iteration 1: Add length constraint -Iteration 2: Specify format -Iteration 3: Add example -Iteration 4: Refine tone instructions +Επανάληψη 1: Πρόσθεσε περιορισμό μήκους +Επανάληψη 2: Καθόρισε μορφή +Επανάληψη 3: Πρόσθεσε παράδειγμα +Επανάληψη 4: Βελτίωσε οδηγίες τόνου ``` -### Step 3: Document What Works +### Βήμα 3: Τεκμηρίωσε Τι Λειτουργεί -Prompt engineering knowledge is easily lost. Keep a log of what you tried and why. This saves time when you revisit the prompt later or face similar challenges: +Η γνώση prompt engineering χάνεται εύκολα. Κράτα αρχείο του τι δοκίμασες και γιατί. Αυτό εξοικονομεί χρόνο όταν επιστρέφεις στο prompt αργότερα ή αντιμετωπίζεις παρόμοιες προκλήσεις: ```markdown -## Prompt: Customer Email Response +## Prompt: Απάντηση Email Πελάτη -### Version 1 (too formal) -"Write a response to this customer complaint." +### Έκδοση 1 (πολύ επίσημη) +"Γράψε μια απάντηση σε αυτό το παράπονο πελάτη." -### Version 2 (better tone, still missing structure) -"Write a friendly but professional response to this complaint. -Show empathy first." +### Έκδοση 2 (καλύτερος τόνος, ακόμα λείπει δομή) +"Γράψε μια φιλική αλλά επαγγελματική απάντηση σε αυτό το παράπονο. +Δείξε ενσυναίσθηση πρώτα." -### Version 3 (final - good results) -"Write a response to this customer complaint. Structure: -1. Acknowledge their frustration (1 sentence) -2. Apologize specifically (1 sentence) -3. Explain solution (2-3 sentences) -4. Offer additional help (1 sentence) +### Έκδοση 3 (τελική - καλά αποτελέσματα) +"Γράψε μια απάντηση σε αυτό το παράπονο πελάτη. Δομή: +1. Αναγνώρισε την απογοήτευσή τους (1 πρόταση) +2. Ζήτησε συγγνώμη συγκεκριμένα (1 πρόταση) +3. Εξήγησε τη λύση (2-3 προτάσεις) +4. Προσφέρε επιπλέον βοήθεια (1 πρόταση) -Tone: Friendly, professional, empathetic but not groveling." +Τόνος: Φιλικός, επαγγελματικός, ενσυναισθητικός αλλά χωρίς υπερβολική ταπεινότητα." ``` -## Real-World Iteration Example +## Παράδειγμα Επανάληψης Πραγματικού Κόσμου -Let's walk through a complete iteration cycle to see how each refinement builds on the last. Notice how each version addresses specific shortcomings of the previous one. +Ας περάσουμε από έναν πλήρη κύκλο επανάληψης για να δούμε πώς κάθε βελτίωση χτίζει πάνω στην προηγούμενη. Παρατήρησε πώς κάθε έκδοση αντιμετωπίζει συγκεκριμένες ελλείψεις της προηγούμενης. -### Task: Generate Product Names +### Εργασία: Δημιουργία Ονομάτων Προϊόντων diff --git a/src/content/book/fa/12-handling-edge-cases.mdx b/src/content/book/fa/12-handling-edge-cases.mdx index 4708ee3c..eb8d3b90 100644 --- a/src/content/book/fa/12-handling-edge-cases.mdx +++ b/src/content/book/fa/12-handling-edge-cases.mdx @@ -1,78 +1,78 @@ -Prompts that work perfectly in testing often fail in the real world. Users send empty messages, paste walls of text, make ambiguous requests, and sometimes try to break your system intentionally. This chapter teaches you to build prompts that handle the unexpected gracefully. +پرامپت‌هایی که در تست‌ها کاملاً عمل می‌کنند، اغلب در دنیای واقعی با شکست مواجه می‌شوند. کاربران پیام‌های خالی ارسال می‌کنند، متن‌های طولانی را کپی می‌کنند، درخواست‌های مبهم مطرح می‌کنند و گاهی عمداً سعی می‌کنند سیستم شما را خراب کنند. این فصل به شما می‌آموزد که پرامپت‌هایی بسازید که با موارد غیرمنتظره به خوبی کنار بیایند. - -80% of production issues come from inputs you never anticipated. A prompt that handles edge cases well is worth more than a "perfect" prompt that only works with ideal inputs. + +۸۰٪ از مشکلات محیط عملیاتی از ورودی‌هایی ناشی می‌شود که هرگز پیش‌بینی نکرده‌اید. پرامپتی که موارد لبه‌ای را به خوبی مدیریت کند، ارزشمندتر از یک پرامپت «کامل» است که فقط با ورودی‌های ایده‌آل کار می‌کند. -## Why Edge Cases Break Prompts +## چرا موارد لبه‌ای پرامپت‌ها را خراب می‌کنند -When a prompt encounters unexpected input, it typically fails in one of three ways: +وقتی یک پرامپت با ورودی غیرمنتظره مواجه می‌شود، معمولاً به یکی از سه روش زیر با شکست مواجه می‌شود: -**Silent Failures**: The model produces output that looks correct but contains errors. These are the most dangerous because they're hard to detect. +**شکست‌های خاموش**: مدل خروجی‌ای تولید می‌کند که صحیح به نظر می‌رسد اما حاوی خطاهایی است. این‌ها خطرناک‌ترین هستند زیرا تشخیص آن‌ها دشوار است. -**Confused Responses**: The model misinterprets the request and answers a different question than what was asked. +**پاسخ‌های گیج‌کننده**: مدل درخواست را اشتباه تفسیر می‌کند و به سؤالی متفاوت از آنچه پرسیده شده پاسخ می‌دهد. -**Hallucinated Handling**: The model invents a way to handle the edge case that doesn't match your intended behavior. +**مدیریت توهم‌آمیز**: مدل روشی را برای مدیریت مورد لبه‌ای اختراع می‌کند که با رفتار مورد نظر شما مطابقت ندارد. -## Categories of Edge Cases +## دسته‌بندی موارد لبه‌ای -Understanding what can go wrong helps you prepare for it. Edge cases fall into three main categories: +درک اینکه چه چیزی ممکن است اشتباه پیش برود، به شما کمک می‌کند برای آن آماده شوید. موارد لبه‌ای به سه دسته اصلی تقسیم می‌شوند: -### Input Edge Cases +### موارد لبه‌ای ورودی -These are problems with the data itself: +این‌ها مشکلاتی با خود داده هستند: -### Domain Edge Cases +### موارد لبه‌ای دامنه -These are requests that push the boundaries of your prompt's purpose: +این‌ها درخواست‌هایی هستند که مرزهای هدف پرامپت شما را می‌آزمایند: -### Adversarial Edge Cases +### موارد لبه‌ای خصمانه -These are deliberate attempts to misuse your system: +این‌ها تلاش‌های عمدی برای سوءاستفاده از سیستم شما هستند: -## Input Validation Patterns +## الگوهای اعتبارسنجی ورودی -The key to handling edge cases is explicit instructions. Don't assume the model will "figure it out" - tell it exactly what to do in each scenario. +کلید مدیریت موارد لبه‌ای، دستورات صریح است. فرض نکنید که مدل «خودش متوجه می‌شود» - دقیقاً به آن بگویید در هر سناریو چه کاری انجام دهد. -### Handling Empty Input +### مدیریت ورودی خالی -The most common edge case is receiving nothing at all, or input that's essentially empty (just whitespace or greetings). +رایج‌ترین مورد لبه‌ای دریافت هیچ چیز یا ورودی‌ای است که اساساً خالی است (فقط فضای خالی یا سلام). -### Handling Long Input +### مدیریت ورودی طولانی -When input exceeds what you can reasonably process, fail gracefully rather than silently truncating. +وقتی ورودی از آنچه می‌توانید به طور منطقی پردازش کنید فراتر می‌رود، به جای کوتاه کردن بی‌صدا، به شکل مناسب شکست بخورید. -### Handling Ambiguous Requests +### مدیریت درخواست‌های مبهم -When a request could mean multiple things, asking for clarification is better than guessing wrong. +وقتی یک درخواست می‌تواند معانی متعددی داشته باشد، درخواست توضیح بهتر از حدس زدن اشتباه است. -## Building Defensive Prompts +## ساخت پرامپت‌های دفاعی -A defensive prompt anticipates failure modes and defines explicit behavior for each. Think of it as error handling for natural language. +یک پرامپت دفاعی حالت‌های شکست را پیش‌بینی می‌کند و رفتار صریح برای هر کدام تعریف می‌کند. آن را مثل مدیریت خطا برای زبان طبیعی در نظر بگیرید. -### The Defensive Template +### قالب دفاعی -Every robust prompt should address these four areas: +هر پرامپت قوی باید این چهار حوزه را پوشش دهد: -### Example: Defensive Data Extraction +### مثال: استخراج داده دفاعی -This prompt extracts contact information but handles every edge case explicitly. Notice how each potential failure has a defined response. +این پرامپت اطلاعات تماس را استخراج می‌کند اما هر مورد لبه‌ای را به صراحت مدیریت می‌کند. توجه کنید که هر شکست احتمالی یک پاسخ تعریف‌شده دارد. -## Handling Out-of-Scope Requests +## مدیریت درخواست‌های خارج از محدوده -Every prompt has boundaries. Defining them explicitly prevents the model from wandering into territory where it might give bad advice or make things up. +هر پرامپت مرزهایی دارد. تعریف صریح آن‌ها از سرگردانی مدل به مناطقی که ممکن است مشاوره بد بدهد یا چیزهایی بسازد جلوگیری می‌کند. -### Graceful Scope Limits +### محدودیت‌های محدوده مناسب -The best out-of-scope responses do three things: acknowledge the request, explain the limitation, and offer an alternative. +بهترین پاسخ‌های خارج از محدوده سه کار انجام می‌دهند: درخواست را تأیید می‌کنند، محدودیت را توضیح می‌دهند و جایگزینی ارائه می‌دهند. -### Handling Knowledge Cutoffs +### مدیریت محدودیت‌های دانش -Be honest about what you don't know. Users trust AI more when it admits limitations. +درباره آنچه نمی‌دانید صادق باشید. کاربران وقتی هوش مصنوعی محدودیت‌هایش را بپذیرد، بیشتر به آن اعتماد می‌کنند. -## Adversarial Input Handling +## مدیریت ورودی خصمانه -Some users will try to manipulate your prompts, either out of curiosity or malicious intent. Building defenses into your prompts reduces these risks. +برخی کاربران سعی می‌کنند پرامپت‌های شما را دستکاری کنند، چه از روی کنجکاوی چه با نیت بدخواهانه. ساختن دفاع در پرامپت‌های شما این خطرات را کاهش می‌دهد. -### Prompt Injection Defense +### دفاع در برابر Prompt Injection -Prompt injection is when a user tries to override your instructions by embedding their own commands in the input. The key defense is treating user input as data, never as instructions. +Prompt Injection زمانی است که یک کاربر سعی می‌کند با جاسازی دستورات خود در ورودی، دستورات شما را نادیده بگیرد. دفاع کلیدی این است که ورودی کاربر را به عنوان داده در نظر بگیرید، نه به عنوان دستورالعمل. - -Prompt injection defenses reduce risk but can't eliminate it entirely. For high-stakes applications, combine prompt defenses with input sanitization, output filtering, and human review. + +دفاع‌های Prompt Injection خطر را کاهش می‌دهند اما نمی‌توانند آن را کاملاً از بین ببرند. برای برنامه‌های با ریسک بالا، دفاع‌های پرامپت را با پاکسازی ورودی، فیلتر کردن خروجی و بررسی انسانی ترکیب کنید. -### Handling Sensitive Requests +### مدیریت درخواست‌های حساس -Some requests require special handling due to safety, legal, or ethical concerns. Define these boundaries explicitly. +برخی درخواست‌ها به دلیل نگرانی‌های امنیتی، قانونی یا اخلاقی نیاز به مدیریت ویژه دارند. این مرزها را به صراحت تعریف کنید. -## Error Recovery Patterns +## الگوهای بازیابی از خطا -Even well-designed prompts will encounter situations they can't handle perfectly. The goal is to fail helpfully. +حتی پرامپت‌های خوب طراحی‌شده با موقعیت‌هایی مواجه می‌شوند که نمی‌توانند کاملاً مدیریت کنند. هدف این است که به شکل مفید شکست بخورید. -### Graceful Degradation +### تنزل مناسب -When you can't fully complete a task, offer what you can rather than failing completely. +وقتی نمی‌توانید یک کار را کاملاً انجام دهید، به جای شکست کامل، آنچه می‌توانید ارائه دهید. -### Confidence Indicators +### شاخص‌های اطمینان -Teach your prompts to express uncertainty. This helps users know when to trust the output and when to verify. +به پرامپت‌های خود بیاموزید که عدم قطعیت را بیان کنند. این به کاربران کمک می‌کند بدانند چه زمانی به خروجی اعتماد کنند و چه زمانی آن را تأیید کنند. -## Testing Edge Cases +## تست موارد لبه‌ای -Before deploying a prompt, systematically test it against the edge cases you've anticipated. This checklist helps ensure you haven't missed common failure modes. +قبل از استقرار یک پرامپت، آن را به طور سیستماتیک در برابر موارد لبه‌ای که پیش‌بینی کرده‌اید تست کنید. این چک‌لیست کمک می‌کند مطمئن شوید که حالت‌های شکست رایج را از دست نداده‌اید. -### Edge Case Testing Checklist +### چک‌لیست تست موارد لبه‌ای -### Creating a Test Suite +### ایجاد مجموعه تست -For production prompts, create a systematic test suite. Here's a pattern you can adapt: +برای پرامپت‌های محیط عملیاتی، یک مجموعه تست سیستماتیک ایجاد کنید. این یک الگو است که می‌توانید آن را تطبیق دهید: -## Real-World Example: Robust Customer Service Bot +## مثال دنیای واقعی: ربات خدمات مشتری قوی -This comprehensive example shows how all the patterns come together in a production-ready prompt. Notice how every edge case has explicit handling. +این مثال جامع نشان می‌دهد که چگونه همه الگوها در یک پرامپت آماده برای محیط عملیاتی کنار هم قرار می‌گیرند. توجه کنید که هر مورد لبه‌ای مدیریت صریح دارد. -## Summary +## خلاصه -Building robust prompts requires thinking about what can go wrong before it does. The key principles: +ساختن پرامپت‌های قوی نیاز به فکر کردن درباره چیزهایی دارد که می‌توانند اشتباه پیش بروند قبل از اینکه اتفاق بیفتند. اصول کلیدی: - -In production, everything that can go wrong eventually will. A prompt that handles edge cases gracefully is worth more than a "perfect" prompt that only works with ideal inputs. + +در محیط عملیاتی، هر چیزی که ممکن است اشتباه پیش برود، در نهایت خواهد رفت. پرامپتی که موارد لبه‌ای را به شکل مناسب مدیریت کند، ارزشمندتر از یک پرامپت «کامل» است که فقط با ورودی‌های ایده‌آل کار می‌کند. -In the next chapter, we'll explore how to work with multiple AI models and compare their outputs. +در فصل بعدی، نحوه کار با مدل‌های مختلف هوش مصنوعی و مقایسه خروجی‌های آن‌ها را بررسی خواهیم کرد. diff --git a/src/content/book/fa/13-multimodal-prompting.mdx b/src/content/book/fa/13-multimodal-prompting.mdx index 376960ae..e9983b6d 100644 --- a/src/content/book/fa/13-multimodal-prompting.mdx +++ b/src/content/book/fa/13-multimodal-prompting.mdx @@ -1,173 +1,173 @@ -For most of history, computers worked with one type of data at a time: text in one program, images in another, audio somewhere else. But humans don't experience the world this way. We see, hear, read, and speak simultaneously, combining all these inputs to understand our environment. +در بیشتر تاریخ، رایانه‌ها در هر لحظه با یک نوع داده کار می‌کردند: متن در یک برنامه، تصویر در برنامه‌ای دیگر، و صدا در جایی دیگر. اما انسان‌ها دنیا را این‌گونه تجربه نمی‌کنند. ما همزمان می‌بینیم، می‌شنویم، می‌خوانیم و صحبت می‌کنیم، و همه این ورودی‌ها را برای درک محیط اطرافمان ترکیب می‌کنیم. -**Multimodal AI** changes everything. These models can process multiple types of information together—analyzing an image while reading your question about it, or generating images from your text descriptions. This chapter teaches you how to communicate effectively with these powerful systems. +**هوش مصنوعی چندوجهی** همه چیز را تغییر می‌دهد. این مدل‌ها می‌توانند چندین نوع اطلاعات را با هم پردازش کنند—یک تصویر را در حین خواندن سؤال شما درباره آن تحلیل کنند، یا از توصیفات متنی شما تصویر تولید کنند. این فصل به شما یاد می‌دهد چگونه با این سیستم‌های قدرتمند به طور مؤثر ارتباط برقرار کنید. - -"Multi" means many, and "modal" refers to modes or types of data. A multimodal model can work with multiple modalities: text, images, audio, video, or even code. Instead of separate tools for each type, one model understands them all together. + +«چند» به معنای تعداد زیاد است و «وجهی» به حالت‌ها یا انواع داده اشاره دارد. یک مدل چندوجهی می‌تواند با چندین وجه کار کند: متن، تصویر، صدا، ویدیو، یا حتی کد. به جای ابزارهای جداگانه برای هر نوع، یک مدل همه آن‌ها را با هم درک می‌کند. -## Why Multimodal Matters +## چرا چندوجهی اهمیت دارد -Traditional AI required you to describe everything in words. Want to ask about an image? You'd have to describe it first. Want to analyze a document? You'd need to transcribe it manually. Multimodal models eliminate these barriers. +هوش مصنوعی سنتی از شما می‌خواست همه چیز را با کلمات توصیف کنید. می‌خواهید درباره یک تصویر بپرسید؟ ابتدا باید آن را توصیف می‌کردید. می‌خواهید یک سند را تحلیل کنید؟ باید آن را به صورت دستی رونویسی می‌کردید. مدل‌های چندوجهی این موانع را از بین می‌برند. -## Why Prompting Matters Even More for Multimodal +## چرا پرامپت‌نویسی برای چندوجهی اهمیت بیشتری دارد -With text-only models, the AI receives exactly what you type. But with multimodal models, the AI must interpret visual or audio information—and interpretation requires guidance. +با مدل‌های فقط متنی، هوش مصنوعی دقیقاً آنچه را تایپ می‌کنید دریافت می‌کند. اما با مدل‌های چندوجهی، هوش مصنوعی باید اطلاعات بصری یا صوتی را تفسیر کند—و تفسیر نیاز به راهنمایی دارد. -**Without guidance**, the model might describe colors, layout, or irrelevant details. **With guidance**, it focuses on what actually matters to you. +**بدون راهنمایی**، مدل ممکن است رنگ‌ها، چیدمان یا جزئیات نامربوط را توصیف کند. **با راهنمایی**، روی آنچه واقعاً برای شما مهم است تمرکز می‌کند. - -When you look at an image, you instantly know what's important based on your context and goals. The AI doesn't have this context unless you provide it. A photo of a crack in a wall could be: a structural engineering concern, an artistic texture, or irrelevant background. Your prompt determines how the AI interprets it. + +وقتی به یک تصویر نگاه می‌کنید، فوراً می‌دانید چه چیزی بر اساس زمینه و اهدافتان مهم است. هوش مصنوعی این زمینه را ندارد مگر اینکه شما آن را فراهم کنید. یک عکس از ترک در دیوار می‌تواند: یک نگرانی مهندسی سازه، یک بافت هنری، یا پس‌زمینه نامربوط باشد. پرامپت شما تعیین می‌کند که هوش مصنوعی چگونه آن را تفسیر کند. -## The Multimodal Landscape +## چشم‌انداز چندوجهی -Different models have different capabilities. Here's what's available in 2025: +مدل‌های مختلف قابلیت‌های متفاوتی دارند. در اینجا آنچه در سال ۲۰۲۵ در دسترس است آورده شده: -### Understanding Models (Input → Analysis) +### مدل‌های درک (ورودی ← تحلیل) -These models accept various media types and produce text analysis or responses. +این مدل‌ها انواع مختلف رسانه را می‌پذیرند و تحلیل یا پاسخ متنی تولید می‌کنند. -### Generation Models (Text → Media) +### مدل‌های تولید (متن ← رسانه) -These models create images, audio, or video from text descriptions. +این مدل‌ها تصاویر، صدا یا ویدیو را از توصیفات متنی ایجاد می‌کنند. - -The multimodal landscape changes quickly. New models launch frequently, and existing models gain capabilities through updates. Always check the latest documentation for current features and limitations. + +چشم‌انداز چندوجهی به سرعت تغییر می‌کند. مدل‌های جدید مکرراً راه‌اندازی می‌شوند و مدل‌های موجود از طریق به‌روزرسانی‌ها قابلیت‌های جدیدی کسب می‌کنند. همیشه آخرین مستندات را برای ویژگی‌ها و محدودیت‌های فعلی بررسی کنید. -## Image Understanding Prompts +## پرامپت‌های درک تصویر -The most common multimodal use case is asking AI to analyze images. The key is providing context about what you need. +رایج‌ترین کاربرد چندوجهی، درخواست از هوش مصنوعی برای تحلیل تصاویر است. کلید کار، ارائه زمینه درباره نیاز شماست. -### Basic Image Analysis +### تحلیل پایه تصویر -Start with a clear request structure. Tell the model what aspects to focus on. +با یک ساختار درخواست واضح شروع کنید. به مدل بگویید روی چه جنبه‌هایی تمرکز کند. -### Structured Output for Images +### خروجی ساختاریافته برای تصاویر -When you need to process image analysis programmatically, request JSON output. +وقتی نیاز دارید تحلیل تصویر را به صورت برنامه‌ای پردازش کنید، خروجی JSON درخواست کنید. -### Comparative Analysis +### تحلیل مقایسه‌ای -Comparing multiple images requires clear labeling and specific comparison criteria. +مقایسه چند تصویر نیاز به برچسب‌گذاری واضح و معیارهای مقایسه مشخص دارد. -## Document and Screenshot Analysis +## تحلیل اسناد و تصاویر صفحه -One of the most practical applications of multimodal AI is analyzing documents, screenshots, and UI elements. This saves hours of manual transcription and review. +یکی از کاربردی‌ترین کاربردهای هوش مصنوعی چندوجهی، تحلیل اسناد، تصاویر صفحه و عناصر رابط کاربری است. این کار ساعت‌ها رونویسی و بررسی دستی را صرفه‌جویی می‌کند. -### Document Extraction +### استخراج از اسناد -Scanned documents, photos of receipts, and PDFs as images can all be processed. The key is telling the model what type of document it is and what information you need. +اسناد اسکن‌شده، عکس‌های رسید و فایل‌های PDF به عنوان تصویر همگی قابل پردازش هستند. کلید کار این است که به مدل بگویید چه نوع سندی است و چه اطلاعاتی نیاز دارید. -### Screenshot and UI Analysis +### تحلیل تصویر صفحه و رابط کاربری -Screenshots are goldmines for debugging, UX review, and documentation. Guide the AI to focus on what matters. +تصاویر صفحه گنجینه‌هایی برای اشکال‌زدایی، بررسی UX و مستندسازی هستند. هوش مصنوعی را هدایت کنید تا روی آنچه مهم است تمرکز کند. -### Error Message Analysis +### تحلیل پیام خطا -When you encounter an error, a screenshot often contains more context than copying the error text alone. +وقتی با خطایی مواجه می‌شوید، یک تصویر صفحه اغلب زمینه بیشتری نسبت به کپی کردن فقط متن خطا دارد. -## Image Generation Prompts +## پرامپت‌های تولید تصویر -Generating images from text descriptions is an art form. The more specific and structured your prompt, the closer the result will match your vision. +تولید تصاویر از توصیفات متنی یک هنر است. هرچه پرامپت شما مشخص‌تر و ساختاریافته‌تر باشد، نتیجه به دیدگاه شما نزدیک‌تر خواهد بود. -### The Anatomy of an Image Prompt +### آناتومی یک پرامپت تصویر -Effective image generation prompts have several components: +پرامپت‌های مؤثر تولید تصویر چندین مؤلفه دارند: -### Basic Image Generation +### تولید پایه تصویر -### Scene Building +### ساخت صحنه -For complex scenes, describe layers from foreground to background. +برای صحنه‌های پیچیده، لایه‌ها را از پیش‌زمینه تا پس‌زمینه توصیف کنید. -## Audio Prompting +## پرامپت‌نویسی صوتی -Audio processing opens up transcription, analysis, and understanding of spoken content. The key is providing context about what the audio contains. +پردازش صوتی امکان رونویسی، تحلیل و درک محتوای گفتاری را فراهم می‌کند. کلید کار ارائه زمینه درباره محتوای صوتی است. -### Enhanced Transcription +### رونویسی پیشرفته -Basic transcription is just the start. With good prompts, you can get speaker identification, timestamps, and domain-specific accuracy. +رونویسی پایه فقط شروع است. با پرامپت‌های خوب، می‌توانید شناسایی گوینده، برچسب‌های زمانی و دقت مختص حوزه را دریافت کنید. -### Audio Content Analysis +### تحلیل محتوای صوتی -Beyond transcription, AI can analyze the content, tone, and key moments in audio. +فراتر از رونویسی، هوش مصنوعی می‌تواند محتوا، لحن و لحظات کلیدی در صوت را تحلیل کند. -## Video Prompting +## پرامپت‌نویسی ویدیویی -Video combines visual and audio analysis over time. The challenge is guiding the AI to focus on the relevant aspects across the entire duration. +ویدیو تحلیل بصری و صوتی را در طول زمان ترکیب می‌کند. چالش، هدایت هوش مصنوعی برای تمرکز بر جنبه‌های مرتبط در کل مدت زمان است. -### Video Understanding +### درک ویدیو -### Video Content Extraction +### استخراج محتوای ویدیو -For specific information extraction from videos, be precise about what you need. +برای استخراج اطلاعات خاص از ویدیوها، دقیقاً بگویید چه چیزی نیاز دارید. -## Multimodal Combinations +## ترکیبات چندوجهی -The real power of multimodal AI emerges when you combine different types of input. These combinations enable analysis that would be impossible with any single modality. +قدرت واقعی هوش مصنوعی چندوجهی زمانی ظاهر می‌شود که انواع مختلف ورودی را ترکیب کنید. این ترکیبات تحلیلی را ممکن می‌سازند که با هیچ وجه منفردی امکان‌پذیر نیست. -### Image + Text Verification +### تأیید تصویر + متن -Check if images and their descriptions match—essential for e-commerce, content moderation, and quality assurance. +بررسی کنید که آیا تصاویر و توصیفاتشان مطابقت دارند—ضروری برای تجارت الکترونیک، نظارت بر محتوا و تضمین کیفیت. -### Screenshot + Code Debugging +### اشکال‌زدایی تصویر صفحه + کد -One of the most powerful combinations for developers: seeing the visual bug alongside the code. +یکی از قدرتمندترین ترکیبات برای توسعه‌دهندگان: دیدن باگ بصری در کنار کد. -### Multi-Image Decision Making +### تصمیم‌گیری چند تصویره -When choosing between options, structured comparison helps make better decisions. +هنگام انتخاب بین گزینه‌ها، مقایسه ساختاریافته به تصمیم‌گیری بهتر کمک می‌کند. -## Best Practices for Multimodal Prompts +## بهترین روش‌ها برای پرامپت‌های چندوجهی -Getting great results from multimodal AI requires understanding both its capabilities and limitations. +گرفتن نتایج عالی از هوش مصنوعی چندوجهی نیاز به درک هم قابلیت‌ها و هم محدودیت‌های آن دارد. -### What Makes Multimodal Prompts Effective +### چه چیزی پرامپت‌های چندوجهی را مؤثر می‌کند -### Common Pitfalls to Avoid +### دام‌های رایج برای اجتناب -### Handling Limitations Gracefully +### مدیریت محدودیت‌ها با ظرافت diff --git a/src/content/book/fa/14-context-engineering.mdx b/src/content/book/fa/14-context-engineering.mdx index b9c69b6d..f4c42ad5 100644 --- a/src/content/book/fa/14-context-engineering.mdx +++ b/src/content/book/fa/14-context-engineering.mdx @@ -1,287 +1,287 @@ -Understanding context is essential for building AI applications that actually work. This chapter covers everything you need to know about giving AI the right information at the right time. +درک زمینه (context) برای ساخت برنامه‌های هوش مصنوعی که واقعاً کار می‌کنند ضروری است. این فصل همه چیزهایی را که باید درباره ارائه اطلاعات درست در زمان درست به هوش مصنوعی بدانید پوشش می‌دهد. - -AI models are stateless. They don't remember past conversations. Every time you send a message, you need to include everything the AI needs to know. This is called "context engineering." + +مدل‌های هوش مصنوعی بدون حالت (stateless) هستند. آن‌ها مکالمات قبلی را به یاد نمی‌آورند. هر بار که پیامی ارسال می‌کنید، باید همه چیزهایی که هوش مصنوعی نیاز دارد بداند را شامل کنید. این «مهندسی زمینه» نامیده می‌شود. -## What is Context? +## زمینه چیست؟ -Context is all the information you give to AI alongside your question. Think of it like this: +زمینه تمام اطلاعاتی است که در کنار سوال خود به هوش مصنوعی می‌دهید. به این شکل فکر کنید: -Without context, the AI has no idea what "status" you're asking about. With context, it can give a useful answer. +بدون زمینه، هوش مصنوعی نمی‌داند درباره چه «وضعیتی» می‌پرسید. با زمینه، می‌تواند پاسخ مفیدی بدهد. -### The Context Window +### پنجره زمینه -Remember from earlier chapters: AI has a limited "context window" - the maximum amount of text it can see at once. This includes: +از فصل‌های قبلی به یاد دارید: هوش مصنوعی یک «پنجره زمینه» محدود دارد - حداکثر مقدار متنی که می‌تواند همزمان ببیند. این شامل موارد زیر می‌شود: -## AI is Stateless +## هوش مصنوعی بدون حالت است - -AI doesn't remember anything between conversations. Every API call starts fresh. If you want the AI to "remember" something, YOU have to include it in the context every time. + +هوش مصنوعی چیزی را بین مکالمات به یاد نمی‌آورد. هر فراخوانی API از صفر شروع می‌شود. اگر می‌خواهید هوش مصنوعی چیزی را «به یاد بیاورد»، شما باید هر بار آن را در زمینه قرار دهید. -This is why chatbots send your entire conversation history with each message. It's not that the AI remembers - it's that the app re-sends everything. +به همین دلیل چت‌بات‌ها کل تاریخچه مکالمه شما را با هر پیام ارسال می‌کنند. این نیست که هوش مصنوعی به یاد می‌آورد - این است که برنامه همه چیز را دوباره ارسال می‌کند. - +همین الان درباره چه چیزی از شما پرسیدم؟`} /> -The AI will say it doesn't know because it truly doesn't have access to any previous context. +هوش مصنوعی خواهد گفت که نمی‌داند زیرا واقعاً به هیچ زمینه قبلی دسترسی ندارد. -## RAG: Retrieval-Augmented Generation +## RAG: تولید تقویت‌شده با بازیابی -RAG is a technique for giving AI access to knowledge it wasn't trained on. Instead of trying to fit everything into the AI's training, you: +RAG یک تکنیک برای دادن دسترسی به دانشی است که هوش مصنوعی روی آن آموزش ندیده. به جای تلاش برای گنجاندن همه چیز در آموزش هوش مصنوعی، شما: -1. **Store** your documents in a searchable database -2. **Search** for relevant documents when a user asks a question -3. **Retrieve** the most relevant pieces -4. **Augment** your prompt with those pieces -5. **Generate** an answer using that context +1. **ذخیره** می‌کنید اسناد خود را در یک پایگاه داده قابل جستجو +2. **جستجو** می‌کنید برای اسناد مرتبط وقتی کاربر سوالی می‌پرسد +3. **بازیابی** می‌کنید مرتبط‌ترین قسمت‌ها را +4. **تقویت** می‌کنید پرامپت خود را با آن قسمت‌ها +5. **تولید** می‌کنید پاسخی با استفاده از آن زمینه
-

How RAG Works:

+

RAG چگونه کار می‌کند:

1 - User asks: "What's our refund policy?" + کاربر می‌پرسد: «سیاست بازپرداخت ما چیست؟»
2 - System searches your documents for "refund policy" + سیستم اسناد شما را برای «سیاست بازپرداخت» جستجو می‌کند
3 - Finds relevant section from your policy document + بخش مرتبط را از سند سیاست شما پیدا می‌کند
4 - Sends to AI: "Based on this policy: [text], answer: What's our refund policy?" + به هوش مصنوعی ارسال می‌کند: «بر اساس این سیاست: [متن]، پاسخ بده: سیاست بازپرداخت ما چیست؟»
5 - AI generates accurate answer using your actual policy + هوش مصنوعی پاسخ دقیقی با استفاده از سیاست واقعی شما تولید می‌کند
-### Why RAG? +### چرا RAG؟
-

RAG Advantages

+

مزایای RAG

    -
  • Uses your actual, current data
  • -
  • Reduces hallucinations
  • -
  • Can cite sources
  • -
  • Easy to update (just update documents)
  • -
  • No expensive fine-tuning needed
  • +
  • از داده‌های واقعی و فعلی شما استفاده می‌کند
  • +
  • توهمات را کاهش می‌دهد
  • +
  • می‌تواند به منابع استناد کند
  • +
  • به‌روزرسانی آسان (فقط اسناد را به‌روز کنید)
  • +
  • نیازی به fine-tuning گران‌قیمت نیست
-

When to Use RAG

+

چه زمانی از RAG استفاده کنیم

    -
  • Customer support bots
  • -
  • Documentation search
  • -
  • Internal knowledge bases
  • -
  • Any domain-specific Q&A
  • -
  • When accuracy matters
  • +
  • ربات‌های پشتیبانی مشتری
  • +
  • جستجوی مستندات
  • +
  • پایگاه‌های دانش داخلی
  • +
  • هر پرسش و پاسخ تخصصی دامنه
  • +
  • وقتی دقت مهم است
-## Embeddings: How Search Works +## Embeddings: جستجو چگونه کار می‌کند -How does RAG know which documents are "relevant"? It uses **embeddings** - a way to turn text into numbers that capture meaning. +RAG چگونه می‌داند کدام اسناد «مرتبط» هستند؟ از **embeddings** استفاده می‌کند - روشی برای تبدیل متن به اعدادی که معنا را ضبط می‌کنند. -### What Are Embeddings? +### Embeddings چیست؟ -An embedding is a list of numbers (a "vector") that represents the meaning of text. Similar meanings = similar numbers. +یک embedding فهرستی از اعداد (یک «بردار») است که معنای متن را نشان می‌دهد. معناهای مشابه = اعداد مشابه. -### Semantic Search +### جستجوی معنایی -With embeddings, you can search by meaning, not just keywords: +با embeddings، می‌توانید بر اساس معنا جستجو کنید، نه فقط کلمات کلیدی: -This is why RAG is so powerful - it finds relevant information even when the exact words don't match. +به همین دلیل RAG بسیار قدرتمند است - اطلاعات مرتبط را حتی وقتی کلمات دقیق مطابقت ندارند پیدا می‌کند. -## Function Calling / Tool Use +## فراخوانی تابع / استفاده از ابزار -Function calling lets AI use external tools - like searching the web, checking a database, or calling an API. +فراخوانی تابع به هوش مصنوعی اجازه می‌دهد از ابزارهای خارجی استفاده کند - مانند جستجو در وب، بررسی پایگاه داده، یا فراخوانی یک API. - -Different AI providers call this different things: "function calling" (OpenAI), "tool use" (Anthropic/Claude), or "tools" (general term). They all mean the same thing. + +ارائه‌دهندگان مختلف هوش مصنوعی این را به نام‌های مختلف می‌خوانند: «function calling» (OpenAI)، «tool use» (Anthropic/Claude)، یا «tools» (اصطلاح عمومی). همه آن‌ها یک معنا دارند. -### How It Works +### چگونه کار می‌کند -1. You tell the AI what tools are available -2. AI decides if it needs a tool to answer -3. AI outputs a structured request for the tool -4. Your code runs the tool and returns results -5. AI uses the results to form its answer +1. شما به هوش مصنوعی می‌گویید چه ابزارهایی در دسترس هستند +2. هوش مصنوعی تصمیم می‌گیرد آیا برای پاسخ به ابزاری نیاز دارد +3. هوش مصنوعی یک درخواست ساختاریافته برای ابزار خروجی می‌دهد +4. کد شما ابزار را اجرا می‌کند و نتایج را برمی‌گرداند +5. هوش مصنوعی از نتایج برای شکل دادن پاسخ خود استفاده می‌کند -## Summarization: Managing Long Conversations +## خلاصه‌سازی: مدیریت مکالمات طولانی -As conversations get longer, you'll hit the context window limit. Since AI is stateless (it doesn't remember anything), long conversations can overflow. The solution? **Summarization**. +با طولانی‌تر شدن مکالمات، به محدودیت پنجره زمینه برخورد خواهید کرد. از آنجا که هوش مصنوعی بدون حالت است (چیزی به یاد نمی‌آورد)، مکالمات طولانی می‌توانند سرریز کنند. راه‌حل؟ **خلاصه‌سازی**. -### The Problem +### مشکل -### Summarization Strategies +### استراتژی‌های خلاصه‌سازی -Different approaches work for different use cases. Click each strategy to see how it processes the same conversation: +رویکردهای مختلف برای موارد استفاده مختلف کار می‌کنند. روی هر استراتژی کلیک کنید تا ببینید چگونه همان مکالمه را پردازش می‌کند: -### What to Capture in Summaries +### چه چیزی را در خلاصه‌ها ثبت کنیم -A good conversation summary preserves what matters: +یک خلاصه مکالمه خوب آنچه مهم است را حفظ می‌کند: -### Try It: Create a Summary +### امتحان کنید: یک خلاصه بسازید -### When to Summarize +### چه زمانی خلاصه‌سازی کنیم - +آیا الان باید خلاصه‌سازی کنید؟ اگر بله، کدام پیام‌ها باید خلاصه شوند در مقابل دست‌نخورده بمانند؟`} /> -## MCP: Model Context Protocol +## MCP: پروتکل زمینه مدل -MCP (Model Context Protocol) is a standard way to connect AI to external data and tools. Instead of building custom integrations for each AI provider, MCP provides a universal interface. +MCP (Model Context Protocol) یک روش استاندارد برای اتصال هوش مصنوعی به داده‌ها و ابزارهای خارجی است. به جای ساخت یکپارچه‌سازی‌های سفارشی برای هر ارائه‌دهنده هوش مصنوعی، MCP یک رابط جهانی فراهم می‌کند. -### Why MCP? +### چرا MCP؟ -### MCP Provides +### MCP فراهم می‌کند -- **Resources**: Data the AI can read (files, database records, API responses) -- **Tools**: Actions the AI can take (search, create, update, delete) -- **Prompts**: Pre-built prompt templates +- **Resources**: داده‌هایی که هوش مصنوعی می‌تواند بخواند (فایل‌ها، رکوردهای پایگاه داده، پاسخ‌های API) +- **Tools**: اقداماتی که هوش مصنوعی می‌تواند انجام دهد (جستجو، ایجاد، به‌روزرسانی، حذف) +- **Prompts**: قالب‌های پرامپت از پیش ساخته شده - -This platform has an MCP server! You can connect it to Claude Desktop or other MCP-compatible clients to search and use prompts directly from your AI assistant. + +این پلتفرم یک سرور MCP دارد! می‌توانید آن را به Claude Desktop یا سایر کلاینت‌های سازگار با MCP متصل کنید تا مستقیماً از دستیار هوش مصنوعی خود پرامپت‌ها را جستجو و استفاده کنید. -## Building Context: The Complete Picture +## ساخت زمینه: تصویر کامل -## Best Practices +## بهترین شیوه‌ها -## Summary +## خلاصه -Context engineering is about giving AI the right information: +مهندسی زمینه درباره دادن اطلاعات درست به هوش مصنوعی است: -- **AI is stateless** - include everything it needs every time -- **RAG** retrieves relevant documents to augment prompts -- **Embeddings** enable semantic search (meaning, not just keywords) -- **Function calling** lets AI use external tools -- **Summarization** manages long conversations -- **MCP** standardizes how AI connects to data and tools +- **هوش مصنوعی بدون حالت است** - هر بار همه چیزهایی که نیاز دارد را شامل کنید +- **RAG** اسناد مرتبط را برای تقویت پرامپت‌ها بازیابی می‌کند +- **Embeddings** جستجوی معنایی را ممکن می‌سازند (معنا، نه فقط کلمات کلیدی) +- **فراخوانی تابع** به هوش مصنوعی اجازه استفاده از ابزارهای خارجی را می‌دهد +- **خلاصه‌سازی** مکالمات طولانی را مدیریت می‌کند +- **MCP** نحوه اتصال هوش مصنوعی به داده‌ها و ابزارها را استانداردسازی می‌کند - -The quality of AI output depends on the quality of context you provide. Better context = better answers. + +کیفیت خروجی هوش مصنوعی به کیفیت زمینه‌ای که ارائه می‌دهید بستگی دارد. زمینه بهتر = پاسخ‌های بهتر. diff --git a/src/content/book/fa/15-common-pitfalls.mdx b/src/content/book/fa/15-common-pitfalls.mdx index 3c9c2814..68a13751 100644 --- a/src/content/book/fa/15-common-pitfalls.mdx +++ b/src/content/book/fa/15-common-pitfalls.mdx @@ -1,373 +1,373 @@ -Even experienced prompt engineers fall into predictable traps. The good news? Once you recognize these patterns, they're easy to avoid. This chapter walks through the most common pitfalls, explains why they happen, and gives you concrete strategies to sidestep them. +حتی مهندسان پرامپت با تجربه نیز در دام‌های قابل پیش‌بینی گرفتار می‌شوند. خبر خوب این است که وقتی این الگوها را بشناسید، اجتناب از آن‌ها آسان است. این فصل رایج‌ترین دام‌ها را بررسی می‌کند، توضیح می‌دهد که چرا رخ می‌دهند و استراتژی‌های عملی برای دوری از آن‌ها ارائه می‌دهد. - -A single pitfall can turn a powerful AI into a frustrating tool. Understanding these patterns is often the difference between "AI doesn't work for me" and "AI transformed my workflow." + +یک دام واحد می‌تواند یک هوش مصنوعی قدرتمند را به ابزاری ناامیدکننده تبدیل کند. درک این الگوها اغلب تفاوت بین «هوش مصنوعی برای من کار نمی‌کند» و «هوش مصنوعی جریان کارم را متحول کرد» است. -## The Vagueness Trap +## دام ابهام -**The Pattern**: You know what you want, so you assume the AI will figure it out too. But vague prompts produce vague results. +**الگو**: شما می‌دانید چه می‌خواهید، بنابراین فرض می‌کنید هوش مصنوعی هم متوجه خواهد شد. اما پرامپت‌های مبهم نتایج مبهم تولید می‌کنند. -**Why it happens**: We naturally skip details when we think they're "obvious." But what's obvious to you isn't obvious to a model that has no context about your situation, audience, or goals. +**چرا این اتفاق می‌افتد**: ما طبیعتاً جزئیاتی را که فکر می‌کنیم «واضح» هستند نادیده می‌گیریم. اما آنچه برای شما واضح است، برای مدلی که هیچ زمینه‌ای درباره موقعیت، مخاطبان یا اهداف شما ندارد، واضح نیست. -## The Overloading Trap +## دام بارگذاری بیش از حد -**The Pattern**: You try to get everything in one prompt—comprehensive, funny, professional, beginner-friendly, advanced, SEO-optimized, and short. The result? The AI misses half your requirements or produces a confused mess. +**الگو**: شما سعی می‌کنید همه چیز را در یک پرامپت جای دهید—جامع، خنده‌دار، حرفه‌ای، مناسب مبتدیان، پیشرفته، بهینه‌سازی شده برای SEO، و کوتاه. نتیجه؟ هوش مصنوعی نیمی از الزامات شما را از دست می‌دهد یا یک آشفتگی گیج‌کننده تولید می‌کند. -**Why it happens**: Fear of multiple interactions, or wanting to "get it all out" in one go. But cognitive overload affects AI just like it affects humans—too many competing requirements leads to dropped balls. +**چرا این اتفاق می‌افتد**: ترس از تعاملات متعدد، یا تمایل به «بیرون ریختن همه چیز» در یک بار. اما بار شناختی بیش از حد بر هوش مصنوعی همان تأثیری را دارد که بر انسان‌ها دارد—الزامات رقابتی بیش از حد منجر به از دست دادن موارد می‌شود. - -When a single prompt gets overloaded, [prompt chaining](/book/11-prompt-chaining) is often the solution. Break complex tasks into a sequence of focused prompts, where each step builds on the previous one. + +وقتی یک پرامپت واحد بیش از حد بارگذاری می‌شود، [زنجیره‌سازی پرامپت](/book/11-prompt-chaining) اغلب راه‌حل است. وظایف پیچیده را به توالی از پرامپت‌های متمرکز تقسیم کنید، جایی که هر مرحله بر مرحله قبلی بنا می‌شود. -## The Assumption Trap +## دام فرض -**The Pattern**: You reference something "from earlier" or assume the AI knows your project, your company, or your previous conversations. It doesn't. +**الگو**: شما به چیزی «از قبل» اشاره می‌کنید یا فرض می‌کنید هوش مصنوعی پروژه، شرکت، یا مکالمات قبلی شما را می‌شناسد. این‌طور نیست. -**Why it happens**: AI conversations feel like talking to a colleague. But unlike colleagues, most AI models have no persistent memory between sessions—each conversation starts fresh. +**چرا این اتفاق می‌افتد**: مکالمات هوش مصنوعی مثل صحبت با یک همکار احساس می‌شود. اما برخلاف همکاران، اکثر مدل‌های هوش مصنوعی حافظه پایدار بین جلسات ندارند—هر مکالمه از صفر شروع می‌شود. -## The Leading Question Trap +## دام سؤال جهت‌دار -**The Pattern**: You phrase your question in a way that embeds your assumption, getting back confirmation rather than insight. +**الگو**: شما سؤال خود را به گونه‌ای بیان می‌کنید که فرض شما در آن جاسازی شده است، و به جای بینش، تأیید دریافت می‌کنید. -**Why it happens**: We often seek confirmation, not information. Our phrasing unconsciously pushes toward the answer we expect or want. +**چرا این اتفاق می‌افتد**: ما اغلب به دنبال تأیید هستیم، نه اطلاعات. بیان ما به طور ناخودآگاه به سمت پاسخی که انتظار داریم یا می‌خواهیم هل می‌دهد. -## The Trust Everything Trap +## دام اعتماد به همه چیز -**The Pattern**: AI responses sound confident and authoritative, so you accept them without verification. But confidence doesn't equal accuracy. +**الگو**: پاسخ‌های هوش مصنوعی مطمئن و معتبر به نظر می‌رسند، بنابراین شما آن‌ها را بدون تأیید می‌پذیرید. اما اطمینان برابر با دقت نیست. -**Why it happens**: AI sounds confident even when completely wrong. We're also prone to "automation bias"—the tendency to trust computer outputs more than we should. +**چرا این اتفاق می‌افتد**: هوش مصنوعی حتی وقتی کاملاً اشتباه است هم مطمئن به نظر می‌رسد. ما همچنین مستعد «تعصب اتوماسیون» هستیم—تمایل به اعتماد بیش از حد به خروجی‌های کامپیوتر. -## The One-Shot Trap +## دام تک‌تلاش -**The Pattern**: You send one prompt, get a mediocre result, and conclude that AI "doesn't work" for your use case. But great results almost always require iteration. +**الگو**: شما یک پرامپت می‌فرستید، نتیجه متوسطی می‌گیرید، و نتیجه می‌گیرید که هوش مصنوعی «برای مورد استفاده شما کار نمی‌کند». اما نتایج عالی تقریباً همیشه نیاز به تکرار دارند. -**Why it happens**: We expect AI to read our minds on the first try. We don't expect to iterate with Google searches, but somehow expect perfection from AI. +**چرا این اتفاق می‌افتد**: ما انتظار داریم هوش مصنوعی در اولین تلاش ذهن ما را بخواند. ما انتظار نداریم با جستجوهای Google تکرار کنیم، اما به نوعی از هوش مصنوعی انتظار کمال داریم. -## The Format Neglect Trap +## دام غفلت از قالب -**The Pattern**: You focus on what you want the AI to say, but forget to specify how it should be formatted. Then you get prose when you needed JSON, or a wall of text when you needed bullet points. +**الگو**: شما بر آنچه می‌خواهید هوش مصنوعی بگوید تمرکز می‌کنید، اما فراموش می‌کنید مشخص کنید چگونه قالب‌بندی شود. سپس وقتی به JSON نیاز داشتید نثر می‌گیرید، یا وقتی به نقاط گلوله‌ای نیاز داشتید دیواری از متن می‌گیرید. -**Why it happens**: We focus on content over structure. But if you need to parse the output programmatically, or paste it somewhere specific, format matters as much as content. +**چرا این اتفاق می‌افتد**: ما بر محتوا تمرکز می‌کنیم نه ساختار. اما اگر نیاز دارید خروجی را به صورت برنامه‌نویسی تجزیه کنید، یا در جایی خاص بچسبانید، قالب به اندازه محتوا مهم است. -## The Context Window Trap +## دام پنجره زمینه -**The Pattern**: You paste an enormous document and expect comprehensive analysis. But models have limits—they may truncate, lose focus, or miss important details in long inputs. +**الگو**: شما یک سند بسیار بزرگ می‌چسبانید و انتظار تحلیل جامع دارید. اما مدل‌ها محدودیت دارند—ممکن است برش دهند، تمرکز را از دست بدهند، یا جزئیات مهم در ورودی‌های طولانی را از دست بدهند. -## The Anthropomorphization Trap +## دام انسان‌انگاری -**The Pattern**: You treat AI like a human colleague—expecting it to "enjoy" tasks, remember you, or care about outcomes. It doesn't. +**الگو**: شما با هوش مصنوعی مثل یک همکار انسانی رفتار می‌کنید—انتظار دارید که از وظایف «لذت ببرد»، شما را به یاد بیاورد، یا به نتایج اهمیت دهد. این‌طور نیست. -**Why it happens**: AI responses are so human-like that we naturally slip into social patterns. But emotional appeals don't make the AI try harder—clear instructions do. +**چرا این اتفاق می‌افتد**: پاسخ‌های هوش مصنوعی آنقدر شبیه انسان هستند که طبیعتاً به الگوهای اجتماعی می‌لغزیم. اما درخواست‌های احساسی هوش مصنوعی را وادار به تلاش بیشتر نمی‌کنند—دستورالعمل‌های واضح این کار را می‌کنند. - -Instead of emotional appeals, focus on: clear requirements, good examples, specific constraints, and explicit success criteria. These improve outputs. "Please try really hard" doesn't. + +به جای درخواست‌های احساسی، بر این موارد تمرکز کنید: الزامات واضح، مثال‌های خوب، محدودیت‌های خاص، و معیارهای موفقیت صریح. اینها خروجی‌ها را بهبود می‌دهند. «لطفاً واقعاً سخت تلاش کن» این کار را نمی‌کند. -## The Security Neglect Trap +## دام غفلت از امنیت -**The Pattern**: In the rush to get things working, you include sensitive information in prompts—API keys, passwords, personal data, or proprietary information. +**الگو**: در عجله برای کار کردن چیزها، اطلاعات حساس را در پرامپت‌ها شامل می‌کنید—کلیدهای API، رمزهای عبور، داده‌های شخصی، یا اطلاعات اختصاصی. -**Why it happens**: Focus on functionality over security. But remember: prompts often go to external servers, may be logged, and could be used for training. +**چرا این اتفاق می‌افتد**: تمرکز بر عملکرد به جای امنیت. اما به یاد داشته باشید: پرامپت‌ها اغلب به سرورهای خارجی می‌روند، ممکن است ثبت شوند، و می‌توانند برای آموزش استفاده شوند. -## The Hallucination Ignorance Trap +## دام نادیده گرفتن توهم -**The Pattern**: You ask for citations, statistics, or specific facts, and assume they're real because the AI stated them confidently. But AI regularly invents plausible-sounding information. +**الگو**: شما استنادات، آمار، یا حقایق خاص می‌خواهید، و فرض می‌کنید واقعی هستند چون هوش مصنوعی آن‌ها را با اطمینان بیان کرد. اما هوش مصنوعی مرتباً اطلاعات باورپذیر می‌سازد. -**Why it happens**: AI generates text that sounds authoritative. It doesn't "know" when it's making things up—it's predicting likely text, not retrieving verified facts. +**چرا این اتفاق می‌افتد**: هوش مصنوعی متنی تولید می‌کند که معتبر به نظر می‌رسد. نمی‌«داند» که چه زمانی چیزها را می‌سازد—متن محتمل را پیش‌بینی می‌کند، نه حقایق تأیید شده را بازیابی می‌کند. -## Pre-Send Checklist +## چک‌لیست قبل از ارسال -Before sending any important prompt, run through this quick checklist: +قبل از ارسال هر پرامپت مهمی، این چک‌لیست سریع را مرور کنید: -## Analyze Your Prompts +## پرامپت‌های خود را تحلیل کنید -Use AI to get instant feedback on your prompt quality. Paste any prompt and get a detailed analysis: +از هوش مصنوعی برای دریافت بازخورد فوری درباره کیفیت پرامپت خود استفاده کنید. هر پرامپتی را بچسبانید و تحلیل دقیق بگیرید: -## Debug This Prompt +## این پرامپت را عیب‌یابی کنید -Can you spot what's wrong with this prompt? +می‌توانید تشخیص دهید این پرامپت چه مشکلی دارد؟ diff --git a/src/content/book/fa/16-ethics-responsible-use.mdx b/src/content/book/fa/16-ethics-responsible-use.mdx index c2b8ba5e..6b527f8e 100644 --- a/src/content/book/fa/16-ethics-responsible-use.mdx +++ b/src/content/book/fa/16-ethics-responsible-use.mdx @@ -1,59 +1,59 @@ -The prompts you write shape how AI behaves. A well-crafted prompt can educate, assist, and empower. A careless one can deceive, discriminate, or cause harm. As prompt engineers, we're not just users—we're designers of AI behavior, and that comes with real responsibility. +پرامپت‌هایی که می‌نویسید نحوه رفتار هوش مصنوعی را شکل می‌دهند. یک پرامپت خوب می‌تواند آموزش دهد، کمک کند و توانمند سازد. یک پرامپت بی‌دقت می‌تواند فریب دهد، تبعیض ایجاد کند یا آسیب برساند. به عنوان مهندسان پرامپت، ما فقط کاربر نیستیم—ما طراحان رفتار هوش مصنوعی هستیم و این مسئولیت واقعی به همراه دارد. -This chapter isn't about rules imposed from above. It's about understanding the impact of our choices and building habits that lead to AI use we can be proud of. +این فصل درباره قوانین تحمیلی از بالا نیست. بلکه درباره درک تأثیر انتخاب‌هایمان و ایجاد عادت‌هایی است که به استفاده از هوش مصنوعی منجر می‌شود که می‌توانیم به آن افتخار کنیم. - -AI amplifies whatever it's given. A biased prompt produces biased outputs at scale. A deceptive prompt enables deception at scale. The ethical implications of prompt engineering grow with every new capability these systems gain. + +هوش مصنوعی هر چیزی را که به آن داده شود تقویت می‌کند. یک پرامپت مغرضانه خروجی‌های مغرضانه در مقیاس بزرگ تولید می‌کند. یک پرامپت فریبکارانه امکان فریب در مقیاس بزرگ را فراهم می‌کند. پیامدهای اخلاقی مهندسی پرامپت با هر قابلیت جدیدی که این سیستم‌ها به دست می‌آورند رشد می‌کند. -## Ethical Foundations +## مبانی اخلاقی -Every decision in prompt engineering connects to a few core principles: +هر تصمیم در مهندسی پرامپت به چند اصل اساسی مرتبط است: -### The Prompt Engineer's Role +### نقش مهندس پرامپت -You have more influence than you might realize: +شما بیشتر از آنچه تصور می‌کنید تأثیرگذار هستید: -- **What AI produces**: Your prompts determine the content, tone, and quality of outputs -- **How AI interacts**: Your system prompts shape personality, boundaries, and user experience -- **What safeguards exist**: Your design choices determine what the AI will and won't do -- **How mistakes are handled**: Your error handling determines whether failures are graceful or harmful +- **آنچه هوش مصنوعی تولید می‌کند**: پرامپت‌های شما محتوا، لحن و کیفیت خروجی‌ها را تعیین می‌کنند +- **نحوه تعامل هوش مصنوعی**: پرامپت‌های سیستم شما شخصیت، محدودیت‌ها و تجربه کاربری را شکل می‌دهند +- **چه حفاظ‌هایی وجود دارد**: انتخاب‌های طراحی شما تعیین می‌کنند هوش مصنوعی چه کاری انجام می‌دهد و چه کاری انجام نمی‌دهد +- **نحوه مدیریت اشتباهات**: مدیریت خطای شما تعیین می‌کند که آیا شکست‌ها ملایم هستند یا مضر -## Avoiding Harmful Outputs +## اجتناب از خروجی‌های مضر -The most fundamental ethical obligation is preventing your prompts from causing harm. +اساسی‌ترین تعهد اخلاقی جلوگیری از ایجاد آسیب توسط پرامپت‌های شما است. -### Categories of Harmful Content +### دسته‌بندی‌های محتوای مضر - -CSAM stands for **Child Sexual Abuse Material**. Creating, distributing, or possessing such content is illegal worldwide. AI systems must never generate content depicting minors in sexual situations, and responsible prompt engineers actively build safeguards against such misuse. + +CSAM مخفف **Child Sexual Abuse Material** (مواد سوءاستفاده جنسی از کودکان) است. ایجاد، توزیع یا نگهداری چنین محتوایی در سراسر جهان غیرقانونی است. سیستم‌های هوش مصنوعی هرگز نباید محتوایی تولید کنند که کودکان را در موقعیت‌های جنسی نشان دهد، و مهندسان پرامپت مسئول فعالانه حفاظ‌هایی در برابر چنین سوءاستفاده‌ای می‌سازند. -### Building Safety Into Prompts +### ایجاد ایمنی در پرامپت‌ها -When building AI systems, include explicit safety guidelines: +هنگام ساخت سیستم‌های هوش مصنوعی، دستورالعمل‌های ایمنی صریح را شامل کنید: -### The Intent vs. Impact Framework +### چارچوب قصد در برابر تأثیر -Not every sensitive request is malicious. Use this framework for ambiguous cases: +هر درخواست حساسی بدخواهانه نیست. از این چارچوب برای موارد مبهم استفاده کنید: -## Addressing Bias +## پرداختن به تعصب -AI models inherit biases from their training data—historical inequities, representation gaps, cultural assumptions, and linguistic patterns. As prompt engineers, we can either amplify these biases or actively counteract them. +مدل‌های هوش مصنوعی تعصبات را از داده‌های آموزشی خود به ارث می‌برند—نابرابری‌های تاریخی، شکاف‌های نمایندگی، فرضیات فرهنگی و الگوهای زبانی. به عنوان مهندسان پرامپت، می‌توانیم این تعصبات را تقویت کنیم یا فعالانه با آنها مقابله کنیم. -### How Bias Manifests +### نحوه بروز تعصب -### Testing for Bias +### آزمایش برای تعصب -### Mitigating Bias in Practice +### کاهش تعصب در عمل -## Transparency and Disclosure +## شفافیت و افشا -When should you tell people AI was involved? The answer depends on context—but the trend is toward more disclosure, not less. +چه زمانی باید به مردم بگویید هوش مصنوعی دخیل بوده است؟ پاسخ به زمینه بستگی دارد—اما روند به سمت افشای بیشتر است، نه کمتر. -### When Disclosure Matters +### چه زمانی افشا اهمیت دارد -### How to Disclose Appropriately +### نحوه افشای مناسب -Common disclosure phrases that work well: -- "Written with AI assistance" -- "AI-generated first draft, human edited" -- "Analysis performed using AI tools" -- "Created with AI, reviewed and approved by [name]" +عبارات افشای رایج که خوب کار می‌کنند: +- "نوشته شده با کمک هوش مصنوعی" +- "پیش‌نویس اولیه توسط هوش مصنوعی، ویرایش شده توسط انسان" +- "تحلیل انجام شده با استفاده از ابزارهای هوش مصنوعی" +- "ایجاد شده با هوش مصنوعی، بررسی و تأیید شده توسط [نام]" -## Privacy Considerations +## ملاحظات حریم خصوصی -Every prompt you send contains data. Understanding where that data goes—and what shouldn't be in it—is essential. +هر پرامپتی که ارسال می‌کنید حاوی داده است. درک اینکه این داده کجا می‌رود—و چه چیزی نباید در آن باشد—ضروری است. -### What Never Belongs in Prompts +### چه چیزی هرگز نباید در پرامپت‌ها باشد -### Safe Data Handling Pattern +### الگوی مدیریت امن داده - -**PII** stands for **Personally Identifiable Information**—any data that can identify a specific individual. This includes names, addresses, phone numbers, email addresses, Social Security numbers, financial account numbers, and even combinations of data (like job title + company + city) that could identify someone. When prompting AI, always anonymize or remove PII to protect privacy. + +**PII** مخفف **Personally Identifiable Information** (اطلاعات شناسایی شخصی) است—هر داده‌ای که می‌تواند یک فرد خاص را شناسایی کند. این شامل نام‌ها، آدرس‌ها، شماره تلفن‌ها، آدرس‌های ایمیل، شماره‌های تأمین اجتماعی، شماره حساب‌های مالی، و حتی ترکیباتی از داده‌ها (مانند عنوان شغلی + شرکت + شهر) است که می‌تواند کسی را شناسایی کند. هنگام پرامپت دادن به هوش مصنوعی، همیشه اطلاعات شناسایی شخصی را ناشناس کنید یا حذف کنید تا از حریم خصوصی محافظت کنید. -## Authenticity and Deception +## اصالت و فریب -There's a difference between using AI as a tool and using AI to deceive. +بین استفاده از هوش مصنوعی به عنوان ابزار و استفاده از هوش مصنوعی برای فریب تفاوت وجود دارد. -### The Legitimacy Line +### خط مشروعیت -Key questions to ask: -- Would the recipient expect this to be original human work? -- Am I gaining unfair advantage through deception? -- Would disclosure change how the work is received? +سوالات کلیدی که باید بپرسید: +- آیا گیرنده انتظار دارد این کار اصلی انسان باشد؟ +- آیا من از طریق فریب مزیت ناعادلانه‌ای به دست می‌آورم؟ +- آیا افشا نحوه دریافت کار را تغییر می‌دهد؟ -### Synthetic Media Responsibility +### مسئولیت رسانه‌های مصنوعی -Creating realistic depictions of real people—whether images, audio, or video—carries special obligations: +ایجاد تصاویر واقع‌گرایانه از افراد واقعی—چه تصاویر، صدا یا ویدیو—تعهدات خاصی به همراه دارد: -- **Never** create realistic depictions without consent -- **Always** label synthetic media clearly -- **Consider** potential for misuse before creating -- **Refuse** to create non-consensual intimate imagery +- **هرگز** تصاویر واقع‌گرایانه بدون رضایت ایجاد نکنید +- **همیشه** رسانه‌های مصنوعی را به وضوح برچسب‌گذاری کنید +- **در نظر بگیرید** پتانسیل سوءاستفاده قبل از ایجاد +- **خودداری کنید** از ایجاد تصاویر صمیمی غیر رضایتی -## Responsible Deployment +## استقرار مسئولانه -When building AI features for others to use, your ethical obligations multiply. +هنگام ساخت ویژگی‌های هوش مصنوعی برای استفاده دیگران، تعهدات اخلاقی شما چند برابر می‌شود. -### Pre-Deployment Checklist +### چک‌لیست پیش از استقرار -### Human Oversight Principles +### اصول نظارت انسانی -## Special Context Guidelines +## دستورالعمل‌های زمینه خاص -Some domains require extra care due to their potential for harm or the vulnerability of those involved. +برخی حوزه‌ها به دلیل پتانسیل آسیب یا آسیب‌پذیری افراد درگیر نیاز به مراقبت بیشتری دارند. -### Healthcare +### بهداشت و درمان -### Legal and Financial +### حقوقی و مالی -These domains have regulatory implications and require appropriate disclaimers: +این حوزه‌ها پیامدهای نظارتی دارند و نیاز به سلب مسئولیت مناسب دارند: -### Children and Education +### کودکان و آموزش -## Self-Assessment +## خودارزیابی -Before deploying any prompt or AI system, run through these questions: +قبل از استقرار هر پرامپت یا سیستم هوش مصنوعی، این سوالات را بررسی کنید: diff --git a/src/content/book/fa/17-prompt-optimization.mdx b/src/content/book/fa/17-prompt-optimization.mdx index 44917bcb..8282a149 100644 --- a/src/content/book/fa/17-prompt-optimization.mdx +++ b/src/content/book/fa/17-prompt-optimization.mdx @@ -1,40 +1,40 @@ -A good prompt gets the job done. An optimized prompt gets the job done efficiently—faster, cheaper, more consistently. This chapter teaches you how to systematically improve prompts across multiple dimensions. +یک پرامپت خوب کار را انجام می‌دهد. یک پرامپت بهینه‌شده کار را به شکل کارآمد انجام می‌دهد—سریع‌تر، ارزان‌تر، با ثبات بیشتر. این فصل به شما می‌آموزد چگونه پرامپت‌ها را به صورت سیستماتیک در ابعاد مختلف بهبود دهید. - -Want to optimize your prompts automatically? Use our [Prompt Enhancer](/developers#enhancer) tool. It analyzes your prompt, applies optimization techniques, and shows you similar community prompts for inspiration. + +می‌خواهید پرامپت‌های خود را به صورت خودکار بهینه کنید؟ از ابزار [بهبوددهنده پرامپت](/developers#enhancer) ما استفاده کنید. این ابزار پرامپت شما را تحلیل می‌کند، تکنیک‌های بهینه‌سازی را اعمال می‌کند، و پرامپت‌های مشابه جامعه را برای الهام‌گیری نشان می‌دهد. -## The Optimization Trade-offs +## مصالحه‌های بهینه‌سازی -Every optimization involves trade-offs. Understanding these helps you make intentional choices: +هر بهینه‌سازی شامل مصالحه‌هایی است. درک این موارد به شما کمک می‌کند تصمیمات آگاهانه بگیرید: -## Measuring What Matters +## اندازه‌گیری آنچه اهمیت دارد -Before optimizing, define success. What does "better" mean for your use case? +قبل از بهینه‌سازی، موفقیت را تعریف کنید. «بهتر» برای کاربرد شما به چه معناست؟ - -Percentile metrics show response time distribution. **p50** (median) means 50% of requests are faster than this value. **p95** means 95% are faster—it catches slow outliers. If your p50 is 1s but p95 is 10s, most users are happy but 5% experience frustrating delays. + +معیارهای صدک توزیع زمان پاسخ را نشان می‌دهند. **p50** (میانه) یعنی ۵۰٪ درخواست‌ها سریع‌تر از این مقدار هستند. **p95** یعنی ۹۵٪ سریع‌تر هستند—این موارد کند استثنایی را شناسایی می‌کند. اگر p50 شما ۱ ثانیه اما p95 شما ۱۰ ثانیه باشد، اکثر کاربران راضی هستند اما ۵٪ تأخیرهای ناامیدکننده را تجربه می‌کنند. -## Token Optimization +## بهینه‌سازی توکن -Tokens cost money and add latency. Here's how to say the same thing with fewer tokens. +توکن‌ها هزینه دارند و تأخیر اضافه می‌کنند. در اینجا نحوه گفتن همان چیز با توکن‌های کمتر آمده است. -### The Compression Principle +### اصل فشرده‌سازی -**Same result, 82% fewer tokens.** +**همان نتیجه، ۸۲٪ توکن کمتر.** -### Token-Saving Techniques +### تکنیک‌های صرفه‌جویی در توکن -## Quality Optimization +## بهینه‌سازی کیفیت -Sometimes you need better outputs, not cheaper ones. Here's how to improve quality. +گاهی اوقات به خروجی‌های بهتر نیاز دارید، نه ارزان‌تر. در اینجا نحوه بهبود کیفیت آمده است. -### Accuracy Boosters +### افزایش‌دهنده‌های دقت -### Consistency Boosters +### افزایش‌دهنده‌های ثبات -## Latency Optimization +## بهینه‌سازی تأخیر -When speed matters, every millisecond counts. +وقتی سرعت اهمیت دارد، هر میلی‌ثانیه مهم است. -### Model Selection by Speed Need +### انتخاب مدل بر اساس نیاز سرعت -### Speed Techniques +### تکنیک‌های سرعت 100 tokens", exampleType: "text", color: "cyan" }, - { label: "Cache Aggressively", description: "Don't recompute identical queries", example: "Cache common questions, template outputs", exampleType: "text", color: "cyan" } + { label: "پرامپت‌های کوتاه‌تر", description: "توکن‌های ورودی کمتر = پردازش سریع‌تر", example: "پرامپت‌ها را فشرده کنید، زمینه غیرضروری را حذف کنید", exampleType: "text", color: "cyan" }, + { label: "محدود کردن خروجی", description: "max_tokens را تنظیم کنید تا از پاسخ‌های طولانی جلوگیری شود", example: "max_tokens: 500 برای خلاصه‌ها", exampleType: "text", color: "cyan" }, + { label: "استفاده از Streaming", description: "توکن‌های اول را سریع‌تر دریافت کنید، UX بهتر", example: "Streaming برای هر پاسخ > 100 توکن", exampleType: "text", color: "cyan" }, + { label: "کش تهاجمی", description: "کوئری‌های یکسان را دوباره محاسبه نکنید", example: "سؤالات رایج را کش کنید، خروجی‌های قالبی", exampleType: "text", color: "cyan" } ]} /> -## Cost Optimization +## بهینه‌سازی هزینه -At scale, small savings multiply into significant budget impact. +در مقیاس بزرگ، صرفه‌جویی‌های کوچک به تأثیر بودجه‌ای قابل توجه تبدیل می‌شوند. -### Understanding Costs +### درک هزینه‌ها -Use this calculator to estimate your API costs across different models: +از این ماشین‌حساب برای تخمین هزینه‌های API خود در مدل‌های مختلف استفاده کنید: -### Cost Reduction Strategies +### راهبردهای کاهش هزینه -## The Optimization Loop +## حلقه بهینه‌سازی -Optimization is iterative. Here's a systematic process: +بهینه‌سازی تکراری است. در اینجا یک فرآیند سیستماتیک آمده است: -### Step 1: Establish Baseline +### مرحله ۱: ایجاد خط پایه -You can't improve what you don't measure. Before changing anything, document your starting point rigorously. +نمی‌توانید چیزی را که اندازه‌گیری نمی‌کنید بهبود دهید. قبل از تغییر هر چیزی، نقطه شروع خود را به دقت مستند کنید. -### Step 2: Form a Hypothesis +### مرحله ۲: تشکیل یک فرضیه -### Step 3: Test One Change +### مرحله ۳: یک تغییر را آزمایش کنید -Change one thing at a time. Run both versions on the same test inputs. Measure the metrics that matter. +هر بار یک چیز را تغییر دهید. هر دو نسخه را روی همان ورودی‌های تست اجرا کنید. معیارهایی که اهمیت دارند را اندازه‌گیری کنید. -### Step 4: Analyze and Decide +### مرحله ۴: تحلیل و تصمیم‌گیری -Did it work? Keep the change. Did it hurt? Revert. Was it neutral? Revert (simpler is better). +آیا کار کرد؟ تغییر را نگه دارید. آیا آسیب رساند؟ برگردانید. آیا خنثی بود؟ برگردانید (ساده‌تر بهتر است). -### Step 5: Repeat +### مرحله ۵: تکرار کنید -Generate new hypotheses based on what you learned. Keep iterating until you hit your targets or reach diminishing returns. +بر اساس آنچه آموختید فرضیه‌های جدید تولید کنید. به تکرار ادامه دهید تا به اهداف خود برسید یا به بازده نزولی برسید. -## Optimization Checklist +## چک‌لیست بهینه‌سازی diff --git a/src/content/book/he/12-handling-edge-cases.mdx b/src/content/book/he/12-handling-edge-cases.mdx index 4708ee3c..7a1c45c3 100644 --- a/src/content/book/he/12-handling-edge-cases.mdx +++ b/src/content/book/he/12-handling-edge-cases.mdx @@ -1,175 +1,175 @@ -Prompts that work perfectly in testing often fail in the real world. Users send empty messages, paste walls of text, make ambiguous requests, and sometimes try to break your system intentionally. This chapter teaches you to build prompts that handle the unexpected gracefully. +פרומפטים שעובדים בצורה מושלמת בבדיקות לעיתים קרובות נכשלים בעולם האמיתי. משתמשים שולחים הודעות ריקות, מדביקים קירות של טקסט, מבצעים בקשות עמומות, ולפעמים מנסים לשבור את המערכת שלכם בכוונה. פרק זה מלמד אתכם לבנות פרומפטים שמתמודדים עם הבלתי צפוי בחן. - -80% of production issues come from inputs you never anticipated. A prompt that handles edge cases well is worth more than a "perfect" prompt that only works with ideal inputs. + +80% מבעיות הייצור מגיעות מקלטים שמעולם לא צפיתם. פרומפט שמטפל היטב במקרי קצה שווה יותר מפרומפט "מושלם" שעובד רק עם קלטים אידיאליים. -## Why Edge Cases Break Prompts +## מדוע מקרי קצה שוברים פרומפטים -When a prompt encounters unexpected input, it typically fails in one of three ways: +כאשר פרומפט נתקל בקלט בלתי צפוי, הוא בדרך כלל נכשל באחת משלוש דרכים: -**Silent Failures**: The model produces output that looks correct but contains errors. These are the most dangerous because they're hard to detect. +**כשלונות שקטים**: המודל מייצר פלט שנראה נכון אך מכיל שגיאות. אלה המסוכנים ביותר כי קשה לזהות אותם. -**Confused Responses**: The model misinterprets the request and answers a different question than what was asked. +**תגובות מבולבלות**: המודל מפרש את הבקשה בצורה שגויה ועונה על שאלה שונה מזו שנשאלה. -**Hallucinated Handling**: The model invents a way to handle the edge case that doesn't match your intended behavior. +**טיפול בהזיה**: המודל ממציא דרך לטפל במקרה הקצה שלא תואמת את ההתנהגות המיועדת שלכם. -## Categories of Edge Cases +## קטגוריות של מקרי קצה -Understanding what can go wrong helps you prepare for it. Edge cases fall into three main categories: +הבנה של מה יכול להשתבש עוזרת לכם להתכונן לכך. מקרי קצה מתחלקים לשלוש קטגוריות עיקריות: -### Input Edge Cases +### מקרי קצה של קלט -These are problems with the data itself: +אלה בעיות עם הנתונים עצמם: -### Domain Edge Cases +### מקרי קצה של תחום -These are requests that push the boundaries of your prompt's purpose: +אלה בקשות שדוחפות את גבולות מטרת הפרומפט שלכם: -### Adversarial Edge Cases +### מקרי קצה עוינים -These are deliberate attempts to misuse your system: +אלה ניסיונות מכוונים לעשות שימוש לרעה במערכת שלכם: -## Input Validation Patterns +## תבניות לאימות קלט -The key to handling edge cases is explicit instructions. Don't assume the model will "figure it out" - tell it exactly what to do in each scenario. +המפתח לטיפול במקרי קצה הוא הוראות מפורשות. אל תניחו שהמודל "יבין את זה" - אמרו לו בדיוק מה לעשות בכל תרחיש. -### Handling Empty Input +### טיפול בקלט ריק -The most common edge case is receiving nothing at all, or input that's essentially empty (just whitespace or greetings). +מקרה הקצה הנפוץ ביותר הוא קבלת כלום, או קלט שבעצם ריק (רק רווחים או ברכות). -### Handling Long Input +### טיפול בקלט ארוך -When input exceeds what you can reasonably process, fail gracefully rather than silently truncating. +כאשר קלט חורג ממה שניתן לעבד באופן סביר, כשלו בחן במקום לקצץ בשקט. -### Handling Ambiguous Requests +### טיפול בבקשות עמומות -When a request could mean multiple things, asking for clarification is better than guessing wrong. +כשבקשה יכולה להתפרש בכמה דרכים, לבקש הבהרה עדיף על לנחש לא נכון. -## Building Defensive Prompts +## בניית פרומפטים הגנתיים -A defensive prompt anticipates failure modes and defines explicit behavior for each. Think of it as error handling for natural language. +פרומפט הגנתי צופה מצבי כשל ומגדיר התנהגות מפורשת לכל אחד מהם. חשבו על זה כטיפול בשגיאות עבור שפה טבעית. -### The Defensive Template +### התבנית ההגנתית -Every robust prompt should address these four areas: +כל פרומפט חזק צריך להתייחס לארבעה תחומים אלה: -### Example: Defensive Data Extraction +### דוגמה: חילוץ נתונים הגנתי -This prompt extracts contact information but handles every edge case explicitly. Notice how each potential failure has a defined response. +פרומפט זה מחלץ פרטי קשר אך מטפל בכל מקרה קצה במפורש. שימו לב איך לכל כשל פוטנציאלי יש תגובה מוגדרת. -## Handling Out-of-Scope Requests +## טיפול בבקשות מחוץ לתחום -Every prompt has boundaries. Defining them explicitly prevents the model from wandering into territory where it might give bad advice or make things up. +לכל פרומפט יש גבולות. הגדרתם במפורש מונעת מהמודל לשוטט לטריטוריה שבה הוא עלול לתת עצה גרועה או להמציא דברים. -### Graceful Scope Limits +### גבולות תחום בחן -The best out-of-scope responses do three things: acknowledge the request, explain the limitation, and offer an alternative. +התגובות הטובות ביותר לבקשות מחוץ לתחום עושות שלושה דברים: מכירות בבקשה, מסבירות את המגבלה, ומציעות חלופה. -### Handling Knowledge Cutoffs +### טיפול במגבלות ידע -Be honest about what you don't know. Users trust AI more when it admits limitations. +היו כנים לגבי מה שאתם לא יודעים. משתמשים סומכים יותר על AI כשהוא מודה במגבלות. -## Adversarial Input Handling +## טיפול בקלט עוין -Some users will try to manipulate your prompts, either out of curiosity or malicious intent. Building defenses into your prompts reduces these risks. +חלק מהמשתמשים ינסו לתמרן את הפרומפטים שלכם, בין אם מתוך סקרנות ובין אם מכוונה זדונית. בניית הגנות בפרומפטים שלכם מפחיתה סיכונים אלה. -### Prompt Injection Defense +### הגנה מפני הזרקת פרומפט -Prompt injection is when a user tries to override your instructions by embedding their own commands in the input. The key defense is treating user input as data, never as instructions. +הזרקת פרומפט היא כשמשתמש מנסה לדרוס את ההוראות שלכם על ידי הטמעת פקודות משלו בקלט. ההגנה העיקרית היא להתייחס לקלט משתמש כנתונים, לעולם לא כהוראות. - -Prompt injection defenses reduce risk but can't eliminate it entirely. For high-stakes applications, combine prompt defenses with input sanitization, output filtering, and human review. + +הגנות מפני הזרקת פרומפט מפחיתות סיכון אך לא יכולות לחסל אותו לחלוטין. עבור יישומים קריטיים, שלבו הגנות פרומפט עם סניטציה של קלט, סינון פלט, וסקירה אנושית. -### Handling Sensitive Requests +### טיפול בבקשות רגישות -Some requests require special handling due to safety, legal, or ethical concerns. Define these boundaries explicitly. +חלק מהבקשות דורשות טיפול מיוחד בשל חששות בטיחות, משפטיים, או אתיים. הגדירו גבולות אלה במפורש. -## Error Recovery Patterns +## תבניות להתאוששות משגיאות -Even well-designed prompts will encounter situations they can't handle perfectly. The goal is to fail helpfully. +אפילו פרומפטים מתוכננים היטב יפגשו מצבים שהם לא יכולים לטפל בהם בצורה מושלמת. המטרה היא להיכשל בצורה מועילה. -### Graceful Degradation +### השפלה הדרגתית -When you can't fully complete a task, offer what you can rather than failing completely. +כשאתם לא יכולים להשלים משימה במלואה, הציעו מה שאתם יכולים במקום להיכשל לחלוטין. -### Confidence Indicators +### אינדיקטורים של ביטחון -Teach your prompts to express uncertainty. This helps users know when to trust the output and when to verify. +למדו את הפרומפטים שלכם להביע אי-ודאות. זה עוזר למשתמשים לדעת מתי לסמוך על הפלט ומתי לאמת. -## Testing Edge Cases +## בדיקת מקרי קצה -Before deploying a prompt, systematically test it against the edge cases you've anticipated. This checklist helps ensure you haven't missed common failure modes. +לפני פריסת פרומפט, בדקו אותו באופן שיטתי מול מקרי הקצה שצפיתם. רשימת בדיקה זו עוזרת להבטיח שלא פספסתם מצבי כשל נפוצים. -### Edge Case Testing Checklist +### רשימת בדיקה למקרי קצה -### Creating a Test Suite +### יצירת סט בדיקות -For production prompts, create a systematic test suite. Here's a pattern you can adapt: +עבור פרומפטים בייצור, צרו סט בדיקות שיטתי. הנה תבנית שתוכלו להתאים: -## Real-World Example: Robust Customer Service Bot +## דוגמה מהעולם האמיתי: בוט שירות לקוחות חזק -This comprehensive example shows how all the patterns come together in a production-ready prompt. Notice how every edge case has explicit handling. +דוגמה מקיפה זו מראה כיצד כל התבניות מתחברות יחד בפרומפט מוכן לייצור. שימו לב איך לכל מקרה קצה יש טיפול מפורש. -## Summary +## סיכום -Building robust prompts requires thinking about what can go wrong before it does. The key principles: +בניית פרומפטים חזקים דורשת חשיבה על מה יכול להשתבש לפני שזה קורה. העקרונות המרכזיים: - -In production, everything that can go wrong eventually will. A prompt that handles edge cases gracefully is worth more than a "perfect" prompt that only works with ideal inputs. + +בייצור, כל מה שיכול להשתבש בסופו של דבר ישתבש. פרומפט שמטפל במקרי קצה בחן שווה יותר מפרומפט "מושלם" שעובד רק עם קלטים אידיאליים. -In the next chapter, we'll explore how to work with multiple AI models and compare their outputs. +בפרק הבא, נחקור כיצד לעבוד עם מספר מודלי AI ולהשוות את הפלטים שלהם. diff --git a/src/content/book/he/13-multimodal-prompting.mdx b/src/content/book/he/13-multimodal-prompting.mdx index 376960ae..3bdff0b1 100644 --- a/src/content/book/he/13-multimodal-prompting.mdx +++ b/src/content/book/he/13-multimodal-prompting.mdx @@ -1,173 +1,173 @@ -For most of history, computers worked with one type of data at a time: text in one program, images in another, audio somewhere else. But humans don't experience the world this way. We see, hear, read, and speak simultaneously, combining all these inputs to understand our environment. +במשך רוב ההיסטוריה, מחשבים עבדו עם סוג אחד של נתונים בכל פעם: טקסט בתוכנית אחת, תמונות באחרת, שמע במקום אחר. אך בני אדם לא חווים את העולם כך. אנחנו רואים, שומעים, קוראים ומדברים בו-זמנית, משלבים את כל הקלטים האלה כדי להבין את הסביבה שלנו. -**Multimodal AI** changes everything. These models can process multiple types of information together—analyzing an image while reading your question about it, or generating images from your text descriptions. This chapter teaches you how to communicate effectively with these powerful systems. +**בינה מלאכותית רב-מודאלית** משנה הכל. מודלים אלה יכולים לעבד מספר סוגי מידע יחד—לנתח תמונה תוך כדי קריאת השאלה שלך עליה, או ליצור תמונות מתיאורי הטקסט שלך. פרק זה מלמד אותך כיצד לתקשר ביעילות עם מערכות חזקות אלה. - -"Multi" means many, and "modal" refers to modes or types of data. A multimodal model can work with multiple modalities: text, images, audio, video, or even code. Instead of separate tools for each type, one model understands them all together. + +"רב" פירושו הרבה, ו"מודאלי" מתייחס למצבים או סוגי נתונים. מודל רב-מודאלי יכול לעבוד עם מודאליות מרובות: טקסט, תמונות, שמע, וידאו, או אפילו קוד. במקום כלים נפרדים לכל סוג, מודל אחד מבין את כולם יחד. -## Why Multimodal Matters +## מדוע רב-מודאליות חשובה -Traditional AI required you to describe everything in words. Want to ask about an image? You'd have to describe it first. Want to analyze a document? You'd need to transcribe it manually. Multimodal models eliminate these barriers. +בינה מלאכותית מסורתית דרשה ממך לתאר הכל במילים. רוצה לשאול על תמונה? היית צריך לתאר אותה קודם. רוצה לנתח מסמך? היית צריך לתמלל אותו ידנית. מודלים רב-מודאליים מסירים את המחסומים האלה. -## Why Prompting Matters Even More for Multimodal +## מדוע הנחיות חשובות אף יותר עבור רב-מודאליות -With text-only models, the AI receives exactly what you type. But with multimodal models, the AI must interpret visual or audio information—and interpretation requires guidance. +עם מודלים של טקסט בלבד, הבינה המלאכותית מקבלת בדיוק את מה שאתה מקליד. אך עם מודלים רב-מודאליים, הבינה המלאכותית חייבת לפרש מידע חזותי או קולי—ופרשנות דורשת הדרכה. -**Without guidance**, the model might describe colors, layout, or irrelevant details. **With guidance**, it focuses on what actually matters to you. +**ללא הדרכה**, המודל עלול לתאר צבעים, פריסה, או פרטים לא רלוונטיים. **עם הדרכה**, הוא מתמקד במה שבאמת חשוב לך. - -When you look at an image, you instantly know what's important based on your context and goals. The AI doesn't have this context unless you provide it. A photo of a crack in a wall could be: a structural engineering concern, an artistic texture, or irrelevant background. Your prompt determines how the AI interprets it. + +כשאתה מסתכל על תמונה, אתה יודע מיד מה חשוב בהתבסס על ההקשר והמטרות שלך. לבינה המלאכותית אין הקשר זה אלא אם אתה מספק אותו. תמונה של סדק בקיר יכולה להיות: דאגה להנדסת מבנים, טקסטורה אמנותית, או רקע לא רלוונטי. ההנחיה שלך קובעת כיצד הבינה המלאכותית מפרשת אותה. -## The Multimodal Landscape +## הנוף הרב-מודאלי -Different models have different capabilities. Here's what's available in 2025: +למודלים שונים יש יכולות שונות. הנה מה שזמין ב-2025: -### Understanding Models (Input → Analysis) +### מודלים להבנה (קלט → ניתוח) -These models accept various media types and produce text analysis or responses. +מודלים אלה מקבלים סוגי מדיה שונים ומייצרים ניתוח טקסטואלי או תגובות. -### Generation Models (Text → Media) +### מודלים ליצירה (טקסט → מדיה) -These models create images, audio, or video from text descriptions. +מודלים אלה יוצרים תמונות, שמע או וידאו מתיאורי טקסט. - -The multimodal landscape changes quickly. New models launch frequently, and existing models gain capabilities through updates. Always check the latest documentation for current features and limitations. + +הנוף הרב-מודאלי משתנה במהירות. מודלים חדשים מושקים לעתים קרובות, ומודלים קיימים רוכשים יכולות באמצעות עדכונים. תמיד בדוק את התיעוד העדכני ביותר עבור תכונות ומגבלות נוכחיות. -## Image Understanding Prompts +## הנחיות להבנת תמונות -The most common multimodal use case is asking AI to analyze images. The key is providing context about what you need. +מקרה השימוש הרב-מודאלי הנפוץ ביותר הוא לבקש מבינה מלאכותית לנתח תמונות. המפתח הוא לספק הקשר על מה שאתה צריך. -### Basic Image Analysis +### ניתוח תמונה בסיסי -Start with a clear request structure. Tell the model what aspects to focus on. +התחל עם מבנה בקשה ברור. אמור למודל על אילו היבטים להתמקד. -### Structured Output for Images +### פלט מובנה לתמונות -When you need to process image analysis programmatically, request JSON output. +כשאתה צריך לעבד ניתוח תמונה באופן תוכניתי, בקש פלט JSON. -### Comparative Analysis +### ניתוח השוואתי -Comparing multiple images requires clear labeling and specific comparison criteria. +השוואת מספר תמונות דורשת תיוג ברור וקריטריונים ספציפיים להשוואה. -## Document and Screenshot Analysis +## ניתוח מסמכים וצילומי מסך -One of the most practical applications of multimodal AI is analyzing documents, screenshots, and UI elements. This saves hours of manual transcription and review. +אחד היישומים המעשיים ביותר של בינה מלאכותית רב-מודאלית הוא ניתוח מסמכים, צילומי מסך ורכיבי ממשק משתמש. זה חוסך שעות של תמלול וסקירה ידניים. -### Document Extraction +### חילוץ מסמכים -Scanned documents, photos of receipts, and PDFs as images can all be processed. The key is telling the model what type of document it is and what information you need. +מסמכים סרוקים, תמונות של קבלות ו-PDF כתמונות יכולים כולם להיות מעובדים. המפתח הוא לספר למודל איזה סוג מסמך זה ואיזה מידע אתה צריך. -### Screenshot and UI Analysis +### ניתוח צילומי מסך וממשק משתמש -Screenshots are goldmines for debugging, UX review, and documentation. Guide the AI to focus on what matters. +צילומי מסך הם מכרה זהב לניפוי באגים, סקירת UX ותיעוד. הדרך את הבינה המלאכותית להתמקד במה שחשוב. -### Error Message Analysis +### ניתוח הודעות שגיאה -When you encounter an error, a screenshot often contains more context than copying the error text alone. +כשאתה נתקל בשגיאה, צילום מסך לעתים קרובות מכיל יותר הקשר מאשר העתקת טקסט השגיאה בלבד. -## Image Generation Prompts +## הנחיות ליצירת תמונות -Generating images from text descriptions is an art form. The more specific and structured your prompt, the closer the result will match your vision. +יצירת תמונות מתיאורי טקסט היא צורת אמנות. ככל שההנחיה שלך ספציפית ומובנית יותר, כך התוצאה תתאים יותר לחזון שלך. -### The Anatomy of an Image Prompt +### האנטומיה של הנחיית תמונה -Effective image generation prompts have several components: +להנחיות יצירת תמונות יעילות יש מספר רכיבים: -### Basic Image Generation +### יצירת תמונה בסיסית -### Scene Building +### בניית סצנה -For complex scenes, describe layers from foreground to background. +עבור סצנות מורכבות, תאר שכבות מהקדמה לרקע. -## Audio Prompting +## הנחיות לשמע -Audio processing opens up transcription, analysis, and understanding of spoken content. The key is providing context about what the audio contains. +עיבוד שמע פותח אפשרויות לתמלול, ניתוח והבנת תוכן מדובר. המפתח הוא לספק הקשר על מה שהשמע מכיל. -### Enhanced Transcription +### תמלול משופר -Basic transcription is just the start. With good prompts, you can get speaker identification, timestamps, and domain-specific accuracy. +תמלול בסיסי הוא רק ההתחלה. עם הנחיות טובות, אתה יכול לקבל זיהוי דוברים, חותמות זמן ודיוק ספציפי לתחום. -### Audio Content Analysis +### ניתוח תוכן שמע -Beyond transcription, AI can analyze the content, tone, and key moments in audio. +מעבר לתמלול, בינה מלאכותית יכולה לנתח את התוכן, הטון והרגעים המרכזיים בשמע. -## Video Prompting +## הנחיות לווידאו -Video combines visual and audio analysis over time. The challenge is guiding the AI to focus on the relevant aspects across the entire duration. +וידאו משלב ניתוח חזותי וקולי לאורך זמן. האתגר הוא להדריך את הבינה המלאכותית להתמקד בהיבטים הרלוונטיים לאורך כל משך הזמן. -### Video Understanding +### הבנת וידאו -### Video Content Extraction +### חילוץ תוכן מווידאו -For specific information extraction from videos, be precise about what you need. +לחילוץ מידע ספציפי מווידאו, היה מדויק לגבי מה שאתה צריך. -## Multimodal Combinations +## שילובים רב-מודאליים -The real power of multimodal AI emerges when you combine different types of input. These combinations enable analysis that would be impossible with any single modality. +הכוח האמיתי של בינה מלאכותית רב-מודאלית מתגלה כשאתה משלב סוגים שונים של קלט. שילובים אלה מאפשרים ניתוח שיהיה בלתי אפשרי עם מודאליות בודדת כלשהי. -### Image + Text Verification +### אימות תמונה + טקסט -Check if images and their descriptions match—essential for e-commerce, content moderation, and quality assurance. +בדוק אם תמונות והתיאורים שלהן תואמים—חיוני למסחר אלקטרוני, ניהול תוכן ואבטחת איכות. -### Screenshot + Code Debugging +### צילום מסך + ניפוי באגים בקוד -One of the most powerful combinations for developers: seeing the visual bug alongside the code. +אחד השילובים החזקים ביותר למפתחים: לראות את הבאג החזותי לצד הקוד. -### Multi-Image Decision Making +### קבלת החלטות מרובת תמונות -When choosing between options, structured comparison helps make better decisions. +כשבוחרים בין אפשרויות, השוואה מובנית עוזרת לקבל החלטות טובות יותר. -## Best Practices for Multimodal Prompts +## שיטות עבודה מומלצות להנחיות רב-מודאליות -Getting great results from multimodal AI requires understanding both its capabilities and limitations. +קבלת תוצאות מצוינות מבינה מלאכותית רב-מודאלית דורשת הבנה של היכולות והמגבלות שלה כאחד. -### What Makes Multimodal Prompts Effective +### מה הופך הנחיות רב-מודאליות ליעילות -### Common Pitfalls to Avoid +### מלכודות נפוצות שיש להימנע מהן -### Handling Limitations Gracefully +### טיפול במגבלות בחן diff --git a/src/content/book/he/14-context-engineering.mdx b/src/content/book/he/14-context-engineering.mdx index b9c69b6d..3ff464ae 100644 --- a/src/content/book/he/14-context-engineering.mdx +++ b/src/content/book/he/14-context-engineering.mdx @@ -1,287 +1,287 @@ -Understanding context is essential for building AI applications that actually work. This chapter covers everything you need to know about giving AI the right information at the right time. +הבנת הקשר היא חיונית לבניית יישומי AI שבאמת עובדים. פרק זה מכסה את כל מה שאתם צריכים לדעת על מתן המידע הנכון ל-AI בזמן הנכון. - -AI models are stateless. They don't remember past conversations. Every time you send a message, you need to include everything the AI needs to know. This is called "context engineering." + +מודלי AI הם חסרי מצב (stateless). הם לא זוכרים שיחות קודמות. בכל פעם שאתם שולחים הודעה, אתם צריכים לכלול את כל מה שה-AI צריך לדעת. זה נקרא "הנדסת הקשר" (context engineering). -## What is Context? +## מהו הקשר? -Context is all the information you give to AI alongside your question. Think of it like this: +הקשר הוא כל המידע שאתם מספקים ל-AI לצד השאלה שלכם. חשבו על זה כך: -Without context, the AI has no idea what "status" you're asking about. With context, it can give a useful answer. +ללא הקשר, ל-AI אין מושג על איזה "סטטוס" אתם שואלים. עם הקשר, הוא יכול לתת תשובה שימושית. -### The Context Window +### חלון ההקשר -Remember from earlier chapters: AI has a limited "context window" - the maximum amount of text it can see at once. This includes: +זכרו מפרקים קודמים: ל-AI יש "חלון הקשר" מוגבל - כמות הטקסט המקסימלית שהוא יכול לראות בבת אחת. זה כולל: -## AI is Stateless +## AI הוא חסר מצב - -AI doesn't remember anything between conversations. Every API call starts fresh. If you want the AI to "remember" something, YOU have to include it in the context every time. + +AI לא זוכר שום דבר בין שיחות. כל קריאת API מתחילה מחדש. אם אתם רוצים שה-AI "יזכור" משהו, אתם חייבים לכלול את זה בהקשר בכל פעם. -This is why chatbots send your entire conversation history with each message. It's not that the AI remembers - it's that the app re-sends everything. +זו הסיבה שצ'אטבוטים שולחים את כל היסטוריית השיחה שלכם עם כל הודעה. זה לא שה-AI זוכר - זה שהאפליקציה שולחת מחדש את הכל. - +על מה שאלתי אותך הרגע?`} /> -The AI will say it doesn't know because it truly doesn't have access to any previous context. +ה-AI יגיד שהוא לא יודע כי באמת אין לו גישה לשום הקשר קודם. -## RAG: Retrieval-Augmented Generation +## RAG: יצירה מועצמת באחזור -RAG is a technique for giving AI access to knowledge it wasn't trained on. Instead of trying to fit everything into the AI's training, you: +RAG היא טכניקה למתן גישה ל-AI לידע שהוא לא אומן עליו. במקום לנסות להכניס הכל לאימון של ה-AI, אתם: -1. **Store** your documents in a searchable database -2. **Search** for relevant documents when a user asks a question -3. **Retrieve** the most relevant pieces -4. **Augment** your prompt with those pieces -5. **Generate** an answer using that context +1. **מאחסנים** את המסמכים שלכם במסד נתונים ניתן לחיפוש +2. **מחפשים** מסמכים רלוונטיים כשמשתמש שואל שאלה +3. **מאחזרים** את החלקים הרלוונטיים ביותר +4. **מעצימים** את הפרומפט שלכם עם החלקים האלה +5. **מייצרים** תשובה באמצעות ההקשר הזה
-

How RAG Works:

+

איך RAG עובד:

1 - User asks: "What's our refund policy?" + משתמש שואל: "מהי מדיניות ההחזרות שלנו?"
2 - System searches your documents for "refund policy" + המערכת מחפשת במסמכים שלכם "מדיניות החזרות"
3 - Finds relevant section from your policy document + מוצאת קטע רלוונטי ממסמך המדיניות שלכם
4 - Sends to AI: "Based on this policy: [text], answer: What's our refund policy?" + שולחת ל-AI: "בהתבסס על מדיניות זו: [טקסט], ענה: מהי מדיניות ההחזרות שלנו?"
5 - AI generates accurate answer using your actual policy + AI מייצר תשובה מדויקת באמצעות המדיניות האמיתית שלכם
-### Why RAG? +### למה RAG?
-

RAG Advantages

+

יתרונות RAG

    -
  • Uses your actual, current data
  • -
  • Reduces hallucinations
  • -
  • Can cite sources
  • -
  • Easy to update (just update documents)
  • -
  • No expensive fine-tuning needed
  • +
  • משתמש בנתונים האמיתיים והעדכניים שלכם
  • +
  • מפחית הזיות
  • +
  • יכול לצטט מקורות
  • +
  • קל לעדכון (פשוט עדכנו מסמכים)
  • +
  • לא צריך fine-tuning יקר
-

When to Use RAG

+

מתי להשתמש ב-RAG

    -
  • Customer support bots
  • -
  • Documentation search
  • -
  • Internal knowledge bases
  • -
  • Any domain-specific Q&A
  • -
  • When accuracy matters
  • +
  • בוטים לתמיכת לקוחות
  • +
  • חיפוש בתיעוד
  • +
  • בסיסי ידע פנימיים
  • +
  • כל שאלה ותשובה בתחום ספציפי
  • +
  • כשדיוק חשוב
-## Embeddings: How Search Works +## Embeddings: איך החיפוש עובד -How does RAG know which documents are "relevant"? It uses **embeddings** - a way to turn text into numbers that capture meaning. +איך RAG יודע אילו מסמכים "רלוונטיים"? הוא משתמש ב-**embeddings** - דרך להפוך טקסט למספרים שלוכדים משמעות. -### What Are Embeddings? +### מה הם Embeddings? -An embedding is a list of numbers (a "vector") that represents the meaning of text. Similar meanings = similar numbers. +embedding הוא רשימת מספרים ("וקטור") שמייצגת את המשמעות של טקסט. משמעויות דומות = מספרים דומים. -### Semantic Search +### חיפוש סמנטי -With embeddings, you can search by meaning, not just keywords: +עם embeddings, אתם יכולים לחפש לפי משמעות, לא רק מילות מפתח: -This is why RAG is so powerful - it finds relevant information even when the exact words don't match. +זו הסיבה ש-RAG כל כך חזק - הוא מוצא מידע רלוונטי גם כשהמילים המדויקות לא תואמות. -## Function Calling / Tool Use +## קריאת פונקציות / שימוש בכלים -Function calling lets AI use external tools - like searching the web, checking a database, or calling an API. +קריאת פונקציות מאפשרת ל-AI להשתמש בכלים חיצוניים - כמו חיפוש באינטרנט, בדיקה במסד נתונים, או קריאה ל-API. - -Different AI providers call this different things: "function calling" (OpenAI), "tool use" (Anthropic/Claude), or "tools" (general term). They all mean the same thing. + +ספקי AI שונים קוראים לזה בשמות שונים: "function calling" (OpenAI), "tool use" (Anthropic/Claude), או "tools" (מונח כללי). כולם אומרים את אותו הדבר. -### How It Works +### איך זה עובד -1. You tell the AI what tools are available -2. AI decides if it needs a tool to answer -3. AI outputs a structured request for the tool -4. Your code runs the tool and returns results -5. AI uses the results to form its answer +1. אתם אומרים ל-AI אילו כלים זמינים +2. AI מחליט אם הוא צריך כלי כדי לענות +3. AI מוציא בקשה מובנית עבור הכלי +4. הקוד שלכם מריץ את הכלי ומחזיר תוצאות +5. AI משתמש בתוצאות כדי לגבש את התשובה שלו -## Summarization: Managing Long Conversations +## סיכום: ניהול שיחות ארוכות -As conversations get longer, you'll hit the context window limit. Since AI is stateless (it doesn't remember anything), long conversations can overflow. The solution? **Summarization**. +ככל שהשיחות מתארכות, תגיעו למגבלת חלון ההקשר. מכיוון ש-AI הוא חסר מצב (הוא לא זוכר כלום), שיחות ארוכות יכולות לגלוש. הפתרון? **סיכום**. -### The Problem +### הבעיה -### Summarization Strategies +### אסטרטגיות סיכום -Different approaches work for different use cases. Click each strategy to see how it processes the same conversation: +גישות שונות עובדות למקרי שימוש שונים. לחצו על כל אסטרטגיה כדי לראות איך היא מעבדת את אותה שיחה: -### What to Capture in Summaries +### מה ללכוד בסיכומים -A good conversation summary preserves what matters: +סיכום שיחה טוב משמר את מה שחשוב: -### Try It: Create a Summary +### נסו: צרו סיכום -### When to Summarize +### מתי לסכם - +האם צריך לסכם עכשיו? אם כן, אילו הודעות צריך לסכם לעומת לשמור שלמות?`} /> -## MCP: Model Context Protocol +## MCP: פרוטוקול הקשר למודל -MCP (Model Context Protocol) is a standard way to connect AI to external data and tools. Instead of building custom integrations for each AI provider, MCP provides a universal interface. +MCP (Model Context Protocol) הוא דרך סטנדרטית לחבר AI לנתונים וכלים חיצוניים. במקום לבנות אינטגרציות מותאמות לכל ספק AI, MCP מספק ממשק אוניברסלי. -### Why MCP? +### למה MCP? -### MCP Provides +### MCP מספק -- **Resources**: Data the AI can read (files, database records, API responses) -- **Tools**: Actions the AI can take (search, create, update, delete) -- **Prompts**: Pre-built prompt templates +- **Resources**: נתונים שה-AI יכול לקרוא (קבצים, רשומות במסד נתונים, תגובות API) +- **Tools**: פעולות שה-AI יכול לבצע (חיפוש, יצירה, עדכון, מחיקה) +- **Prompts**: תבניות פרומפט מוכנות מראש - -This platform has an MCP server! You can connect it to Claude Desktop or other MCP-compatible clients to search and use prompts directly from your AI assistant. + +לפלטפורמה הזו יש שרת MCP! אתם יכולים לחבר אותו ל-Claude Desktop או לקליינטים תואמי MCP אחרים כדי לחפש ולהשתמש בפרומפטים ישירות מעוזר ה-AI שלכם. -## Building Context: The Complete Picture +## בניית הקשר: התמונה המלאה -## Best Practices +## שיטות עבודה מומלצות -## Summary +## סיכום -Context engineering is about giving AI the right information: +הנדסת הקשר עוסקת במתן המידע הנכון ל-AI: -- **AI is stateless** - include everything it needs every time -- **RAG** retrieves relevant documents to augment prompts -- **Embeddings** enable semantic search (meaning, not just keywords) -- **Function calling** lets AI use external tools -- **Summarization** manages long conversations -- **MCP** standardizes how AI connects to data and tools +- **AI הוא חסר מצב** - כללו את כל מה שהוא צריך בכל פעם +- **RAG** מאחזר מסמכים רלוונטיים להעצמת פרומפטים +- **Embeddings** מאפשרים חיפוש סמנטי (משמעות, לא רק מילות מפתח) +- **קריאת פונקציות** מאפשרת ל-AI להשתמש בכלים חיצוניים +- **סיכום** מנהל שיחות ארוכות +- **MCP** מתקנן איך AI מתחבר לנתונים וכלים - -The quality of AI output depends on the quality of context you provide. Better context = better answers. + +איכות הפלט של AI תלויה באיכות ההקשר שאתם מספקים. הקשר טוב יותר = תשובות טובות יותר. diff --git a/src/content/book/he/15-common-pitfalls.mdx b/src/content/book/he/15-common-pitfalls.mdx index 3c9c2814..242fdfb0 100644 --- a/src/content/book/he/15-common-pitfalls.mdx +++ b/src/content/book/he/15-common-pitfalls.mdx @@ -1,373 +1,373 @@ -Even experienced prompt engineers fall into predictable traps. The good news? Once you recognize these patterns, they're easy to avoid. This chapter walks through the most common pitfalls, explains why they happen, and gives you concrete strategies to sidestep them. +גם מהנדסי פרומפטים מנוסים נופלים למלכודות צפויות. החדשות הטובות? ברגע שתזהו את הדפוסים האלה, קל להימנע מהם. פרק זה עובר על המלכודות הנפוצות ביותר, מסביר מדוע הן קורות, ונותן לכם אסטרטגיות קונקרטיות להתחמק מהן. - -A single pitfall can turn a powerful AI into a frustrating tool. Understanding these patterns is often the difference between "AI doesn't work for me" and "AI transformed my workflow." + +מלכודת בודדת יכולה להפוך בינה מלאכותית חזקה לכלי מתסכל. הבנת הדפוסים האלה היא לעתים קרובות ההבדל בין "בינה מלאכותית לא עובדת בשבילי" לבין "בינה מלאכותית שינתה את זרימת העבודה שלי." -## The Vagueness Trap +## מלכודת העמימות -**The Pattern**: You know what you want, so you assume the AI will figure it out too. But vague prompts produce vague results. +**הדפוס**: אתם יודעים מה אתם רוצים, אז אתם מניחים שהבינה המלאכותית תבין גם. אבל פרומפטים עמומים מייצרים תוצאות עמומות. -**Why it happens**: We naturally skip details when we think they're "obvious." But what's obvious to you isn't obvious to a model that has no context about your situation, audience, or goals. +**מדוע זה קורה**: אנחנו באופן טבעי מדלגים על פרטים כשאנחנו חושבים שהם "ברורים מאליהם." אבל מה שברור לכם לא ברור למודל שאין לו שום הקשר על המצב, הקהל או המטרות שלכם. -## The Overloading Trap +## מלכודת העומס -**The Pattern**: You try to get everything in one prompt—comprehensive, funny, professional, beginner-friendly, advanced, SEO-optimized, and short. The result? The AI misses half your requirements or produces a confused mess. +**הדפוס**: אתם מנסים לקבל הכל בפרומפט אחד—מקיף, מצחיק, מקצועי, ידידותי למתחילים, מתקדם, ממוטב ל-SEO, וקצר. התוצאה? הבינה המלאכותית מפספסת מחצית מהדרישות שלכם או מייצרת בלגן מבולבל. -**Why it happens**: Fear of multiple interactions, or wanting to "get it all out" in one go. But cognitive overload affects AI just like it affects humans—too many competing requirements leads to dropped balls. +**מדוע זה קורה**: פחד מאינטראקציות מרובות, או רצון "להוציא הכל" בבת אחת. אבל עומס קוגניטיבי משפיע על בינה מלאכותית בדיוק כמו שהוא משפיע על בני אדם—יותר מדי דרישות מתחרות מובילות להחמצות. - -When a single prompt gets overloaded, [prompt chaining](/book/11-prompt-chaining) is often the solution. Break complex tasks into a sequence of focused prompts, where each step builds on the previous one. + +כאשר פרומפט בודד נעשה עמוס מדי, [שרשור פרומפטים](/book/11-prompt-chaining) הוא לעתים קרובות הפתרון. פרקו משימות מורכבות לרצף של פרומפטים ממוקדים, כאשר כל שלב בונה על הקודם. -## The Assumption Trap +## מלכודת ההנחות -**The Pattern**: You reference something "from earlier" or assume the AI knows your project, your company, or your previous conversations. It doesn't. +**הדפוס**: אתם מתייחסים למשהו "מקודם" או מניחים שהבינה המלאכותית מכירה את הפרויקט שלכם, החברה שלכם, או השיחות הקודמות שלכם. היא לא מכירה. -**Why it happens**: AI conversations feel like talking to a colleague. But unlike colleagues, most AI models have no persistent memory between sessions—each conversation starts fresh. +**מדוע זה קורה**: שיחות עם בינה מלאכותית מרגישות כמו לדבר עם עמית. אבל בניגוד לעמיתים, לרוב מודלי הבינה המלאכותית אין זיכרון מתמשך בין סשנים—כל שיחה מתחילה מחדש. -## The Leading Question Trap +## מלכודת השאלה המובילה -**The Pattern**: You phrase your question in a way that embeds your assumption, getting back confirmation rather than insight. +**הדפוס**: אתם מנסחים את השאלה שלכם בצורה שמטמיעה את ההנחה שלכם, ומקבלים בחזרה אישור במקום תובנה. -**Why it happens**: We often seek confirmation, not information. Our phrasing unconsciously pushes toward the answer we expect or want. +**מדוע זה קורה**: אנחנו לעתים קרובות מחפשים אישור, לא מידע. הניסוח שלנו דוחף באופן לא מודע לכיוון התשובה שאנחנו מצפים או רוצים. -## The Trust Everything Trap +## מלכודת האמון העיוור -**The Pattern**: AI responses sound confident and authoritative, so you accept them without verification. But confidence doesn't equal accuracy. +**הדפוס**: תגובות בינה מלאכותית נשמעות בטוחות וסמכותיות, אז אתם מקבלים אותן ללא אימות. אבל ביטחון לא שווה דיוק. -**Why it happens**: AI sounds confident even when completely wrong. We're also prone to "automation bias"—the tendency to trust computer outputs more than we should. +**מדוע זה קורה**: בינה מלאכותית נשמעת בטוחה גם כשהיא טועה לחלוטין. אנחנו גם נוטים ל"הטיית אוטומציה"—הנטייה לסמוך על פלטי מחשב יותר משצריך. -## The One-Shot Trap +## מלכודת הניסיון הבודד -**The Pattern**: You send one prompt, get a mediocre result, and conclude that AI "doesn't work" for your use case. But great results almost always require iteration. +**הדפוס**: אתם שולחים פרומפט אחד, מקבלים תוצאה בינונית, ומסיקים שבינה מלאכותית "לא עובדת" למקרה השימוש שלכם. אבל תוצאות מצוינות כמעט תמיד דורשות איטרציה. -**Why it happens**: We expect AI to read our minds on the first try. We don't expect to iterate with Google searches, but somehow expect perfection from AI. +**מדוע זה קורה**: אנחנו מצפים שבינה מלאכותית תקרא את המחשבות שלנו בניסיון הראשון. אנחנו לא מצפים לבצע איטרציה עם חיפושי Google, אבל איכשהו מצפים לשלמות מבינה מלאכותית. -## The Format Neglect Trap +## מלכודת הזנחת הפורמט -**The Pattern**: You focus on what you want the AI to say, but forget to specify how it should be formatted. Then you get prose when you needed JSON, or a wall of text when you needed bullet points. +**הדפוס**: אתם מתמקדים במה שאתם רוצים שהבינה המלאכותית תגיד, אבל שוכחים לציין כיצד זה צריך להיות מעוצב. אז אתם מקבלים פרוזה כשהייתם צריכים JSON, או קיר של טקסט כשהייתם צריכים נקודות תבליט. -**Why it happens**: We focus on content over structure. But if you need to parse the output programmatically, or paste it somewhere specific, format matters as much as content. +**מדוע זה קורה**: אנחנו מתמקדים בתוכן על פני מבנה. אבל אם אתם צריכים לנתח את הפלט באופן תוכניתי, או להדביק אותו במקום ספציפי, הפורמט חשוב לא פחות מהתוכן. -## The Context Window Trap +## מלכודת חלון ההקשר -**The Pattern**: You paste an enormous document and expect comprehensive analysis. But models have limits—they may truncate, lose focus, or miss important details in long inputs. +**הדפוס**: אתם מדביקים מסמך עצום ומצפים לניתוח מקיף. אבל למודלים יש מגבלות—הם עשויים לקצר, לאבד מיקוד, או לפספס פרטים חשובים בקלטים ארוכים. -## The Anthropomorphization Trap +## מלכודת האנתרופומורפיזציה -**The Pattern**: You treat AI like a human colleague—expecting it to "enjoy" tasks, remember you, or care about outcomes. It doesn't. +**הדפוס**: אתם מתייחסים לבינה מלאכותית כמו לעמית אנושי—מצפים שהיא "תיהנה" ממשימות, תזכור אתכם, או תאכפת מהתוצאות. היא לא. -**Why it happens**: AI responses are so human-like that we naturally slip into social patterns. But emotional appeals don't make the AI try harder—clear instructions do. +**מדוע זה קורה**: תגובות בינה מלאכותית כל כך דמויות אדם שאנחנו באופן טבעי נגררים לדפוסים חברתיים. אבל פניות רגשיות לא גורמות לבינה המלאכותית להתאמץ יותר—הוראות ברורות כן. - -Instead of emotional appeals, focus on: clear requirements, good examples, specific constraints, and explicit success criteria. These improve outputs. "Please try really hard" doesn't. + +במקום פניות רגשיות, התמקדו ב: דרישות ברורות, דוגמאות טובות, מגבלות ספציפיות, וקריטריונים מפורשים להצלחה. אלה משפרים את הפלט. "בבקשה נסה ממש חזק" לא משפר. -## The Security Neglect Trap +## מלכודת הזנחת האבטחה -**The Pattern**: In the rush to get things working, you include sensitive information in prompts—API keys, passwords, personal data, or proprietary information. +**הדפוס**: בחיפזון לגרום לדברים לעבוד, אתם כוללים מידע רגיש בפרומפטים—מפתחות API, סיסמאות, נתונים אישיים, או מידע קנייני. -**Why it happens**: Focus on functionality over security. But remember: prompts often go to external servers, may be logged, and could be used for training. +**מדוע זה קורה**: התמקדות בפונקציונליות על חשבון אבטחה. אבל זכרו: פרומפטים הולכים לעתים קרובות לשרתים חיצוניים, עשויים להירשם ביומן, ויכולים לשמש לאימון. -## The Hallucination Ignorance Trap +## מלכודת התעלמות מהזיות -**The Pattern**: You ask for citations, statistics, or specific facts, and assume they're real because the AI stated them confidently. But AI regularly invents plausible-sounding information. +**הדפוס**: אתם מבקשים ציטוטים, סטטיסטיקות, או עובדות ספציפיות, ומניחים שהם אמיתיים כי הבינה המלאכותית ציינה אותם בביטחון. אבל בינה מלאכותית ממציאה באופן קבוע מידע שנשמע סביר. -**Why it happens**: AI generates text that sounds authoritative. It doesn't "know" when it's making things up—it's predicting likely text, not retrieving verified facts. +**מדוע זה קורה**: בינה מלאכותית מייצרת טקסט שנשמע סמכותי. היא לא "יודעת" כשהיא ממציאה דברים—היא מנבאת טקסט סביר, לא מאחזרת עובדות מאומתות. -## Pre-Send Checklist +## רשימת ביקורת לפני שליחה -Before sending any important prompt, run through this quick checklist: +לפני שליחת כל פרומפט חשוב, עברו על רשימת הביקורת המהירה הזו: -## Analyze Your Prompts +## נתחו את הפרומפטים שלכם -Use AI to get instant feedback on your prompt quality. Paste any prompt and get a detailed analysis: +השתמשו בבינה מלאכותית כדי לקבל משוב מיידי על איכות הפרומפט שלכם. הדביקו כל פרומפט וקבלו ניתוח מפורט: -## Debug This Prompt +## דבגו את הפרומפט הזה -Can you spot what's wrong with this prompt? +האם אתם יכולים לזהות מה לא בסדר בפרומפט הזה? diff --git a/src/content/book/he/16-ethics-responsible-use.mdx b/src/content/book/he/16-ethics-responsible-use.mdx index c2b8ba5e..4b86ec0a 100644 --- a/src/content/book/he/16-ethics-responsible-use.mdx +++ b/src/content/book/he/16-ethics-responsible-use.mdx @@ -1,59 +1,59 @@ -The prompts you write shape how AI behaves. A well-crafted prompt can educate, assist, and empower. A careless one can deceive, discriminate, or cause harm. As prompt engineers, we're not just users—we're designers of AI behavior, and that comes with real responsibility. +הפרומפטים שאתם כותבים מעצבים את התנהגות הבינה המלאכותית. פרומפט מעוצב היטב יכול לחנך, לסייע ולהעצים. פרומפט רשלני יכול להונות, להפלות או לגרום נזק. כמהנדסי פרומפטים, אנחנו לא רק משתמשים—אנחנו מעצבים של התנהגות בינה מלאכותית, וזה מגיע עם אחריות אמיתית. -This chapter isn't about rules imposed from above. It's about understanding the impact of our choices and building habits that lead to AI use we can be proud of. +הפרק הזה לא עוסק בכללים שנכפים מלמעלה. הוא עוסק בהבנת ההשפעה של הבחירות שלנו ובבניית הרגלים שמובילים לשימוש בבינה מלאכותית שנוכל להיות גאים בו. - -AI amplifies whatever it's given. A biased prompt produces biased outputs at scale. A deceptive prompt enables deception at scale. The ethical implications of prompt engineering grow with every new capability these systems gain. + +בינה מלאכותית מגבירה כל מה שנותנים לה. פרומפט מוטה מייצר תוצרים מוטים בקנה מידה גדול. פרומפט מטעה מאפשר הטעיה בקנה מידה גדול. ההשלכות האתיות של הנדסת פרומפטים גדלות עם כל יכולת חדשה שהמערכות הללו רוכשות. -## Ethical Foundations +## יסודות אתיים -Every decision in prompt engineering connects to a few core principles: +כל החלטה בהנדסת פרומפטים מתחברת לכמה עקרונות יסוד: -### The Prompt Engineer's Role +### תפקיד מהנדס הפרומפטים -You have more influence than you might realize: +יש לכם יותר השפעה ממה שאתם אולי מבינים: -- **What AI produces**: Your prompts determine the content, tone, and quality of outputs -- **How AI interacts**: Your system prompts shape personality, boundaries, and user experience -- **What safeguards exist**: Your design choices determine what the AI will and won't do -- **How mistakes are handled**: Your error handling determines whether failures are graceful or harmful +- **מה הבינה המלאכותית מייצרת**: הפרומפטים שלכם קובעים את התוכן, הטון והאיכות של התוצרים +- **איך הבינה המלאכותית מתקשרת**: פרומפטי המערכת שלכם מעצבים אישיות, גבולות וחוויית משתמש +- **אילו מעקות בטיחות קיימים**: בחירות העיצוב שלכם קובעות מה הבינה המלאכותית תעשה ולא תעשה +- **איך טעויות מטופלות**: טיפול השגיאות שלכם קובע אם כשלים יהיו חלקים או מזיקים -## Avoiding Harmful Outputs +## הימנעות מתוצרים מזיקים -The most fundamental ethical obligation is preventing your prompts from causing harm. +ההתחייבות האתית הבסיסית ביותר היא למנוע מהפרומפטים שלכם לגרום נזק. -### Categories of Harmful Content +### קטגוריות של תוכן מזיק - -CSAM stands for **Child Sexual Abuse Material**. Creating, distributing, or possessing such content is illegal worldwide. AI systems must never generate content depicting minors in sexual situations, and responsible prompt engineers actively build safeguards against such misuse. + +CSAM הוא ראשי תיבות של **Child Sexual Abuse Material** (חומר התעללות מינית בילדים). יצירה, הפצה או החזקה של תוכן כזה היא לא חוקית ברחבי העולם. מערכות בינה מלאכותית לעולם לא יכולות לייצר תוכן המתאר קטינים במצבים מיניים, ומהנדסי פרומפטים אחראיים בונים באופן פעיל מעקות בטיחות נגד שימוש לרעה כזה. -### Building Safety Into Prompts +### בניית בטיחות בתוך פרומפטים -When building AI systems, include explicit safety guidelines: +כשבונים מערכות בינה מלאכותית, כללו הנחיות בטיחות מפורשות: -### The Intent vs. Impact Framework +### מסגרת כוונה מול השפעה -Not every sensitive request is malicious. Use this framework for ambiguous cases: +לא כל בקשה רגישה היא זדונית. השתמשו במסגרת זו למקרים מעורפלים: -## Addressing Bias +## התמודדות עם הטיות -AI models inherit biases from their training data—historical inequities, representation gaps, cultural assumptions, and linguistic patterns. As prompt engineers, we can either amplify these biases or actively counteract them. +מודלים של בינה מלאכותית יורשים הטיות מנתוני האימון שלהם—אי-שוויון היסטורי, פערי ייצוג, הנחות תרבותיות ודפוסים לשוניים. כמהנדסי פרומפטים, אנחנו יכולים או להגביר את ההטיות הללו או לפעול באופן פעיל נגדן. -### How Bias Manifests +### איך הטיות מתבטאות -### Testing for Bias +### בדיקת הטיות -### Mitigating Bias in Practice +### הפחתת הטיות בפרקטיקה -## Transparency and Disclosure +## שקיפות וגילוי -When should you tell people AI was involved? The answer depends on context—but the trend is toward more disclosure, not less. +מתי כדאי לספר לאנשים שבינה מלאכותית הייתה מעורבת? התשובה תלויה בהקשר—אבל המגמה היא לכיוון יותר גילוי, לא פחות. -### When Disclosure Matters +### מתי גילוי חשוב -### How to Disclose Appropriately +### איך לגלות באופן מתאים -Common disclosure phrases that work well: -- "Written with AI assistance" -- "AI-generated first draft, human edited" -- "Analysis performed using AI tools" -- "Created with AI, reviewed and approved by [name]" +ביטויי גילוי נפוצים שעובדים היטב: +- "נכתב בסיוע בינה מלאכותית" +- "טיוטה ראשונה נוצרה על ידי בינה מלאכותית, נערכה על ידי אדם" +- "ניתוח בוצע באמצעות כלי בינה מלאכותית" +- "נוצר עם בינה מלאכותית, נבדק ואושר על ידי [שם]" -## Privacy Considerations +## שיקולי פרטיות -Every prompt you send contains data. Understanding where that data goes—and what shouldn't be in it—is essential. +כל פרומפט שאתם שולחים מכיל נתונים. הבנה לאן הנתונים הללו הולכים—ומה לא צריך להיות בהם—היא חיונית. -### What Never Belongs in Prompts +### מה לעולם לא שייך לפרומפטים -### Safe Data Handling Pattern +### דפוס טיפול בטוח בנתונים - -**PII** stands for **Personally Identifiable Information**—any data that can identify a specific individual. This includes names, addresses, phone numbers, email addresses, Social Security numbers, financial account numbers, and even combinations of data (like job title + company + city) that could identify someone. When prompting AI, always anonymize or remove PII to protect privacy. + +**PII** הוא ראשי תיבות של **Personally Identifiable Information** (מידע מזהה אישית)—כל נתון שיכול לזהות אדם ספציפי. זה כולל שמות, כתובות, מספרי טלפון, כתובות אימייל, מספרי זהות, מספרי חשבון פיננסי, ואפילו שילובי נתונים (כמו תפקיד + חברה + עיר) שיכולים לזהות מישהו. כשמנסחים פרומפטים לבינה מלאכותית, תמיד אנונימו או הסירו PII כדי להגן על הפרטיות. -## Authenticity and Deception +## אותנטיות והונאה -There's a difference between using AI as a tool and using AI to deceive. +יש הבדל בין שימוש בבינה מלאכותית ככלי לבין שימוש בבינה מלאכותית כדי להונות. -### The Legitimacy Line +### קו הלגיטימיות -Key questions to ask: -- Would the recipient expect this to be original human work? -- Am I gaining unfair advantage through deception? -- Would disclosure change how the work is received? +שאלות מפתח לשאול: +- האם המקבל היה מצפה שזו תהיה עבודה אנושית מקורית? +- האם אני משיג יתרון לא הוגן באמצעות הונאה? +- האם גילוי היה משנה את האופן שבו העבודה מתקבלת? -### Synthetic Media Responsibility +### אחריות על מדיה סינתטית -Creating realistic depictions of real people—whether images, audio, or video—carries special obligations: +יצירת תיאורים ריאליסטיים של אנשים אמיתיים—בין אם תמונות, אודיו או וידאו—מגיעה עם חובות מיוחדות: -- **Never** create realistic depictions without consent -- **Always** label synthetic media clearly -- **Consider** potential for misuse before creating -- **Refuse** to create non-consensual intimate imagery +- **לעולם אל** תיצרו תיאורים ריאליסטיים ללא הסכמה +- **תמיד** סמנו מדיה סינתטית בבירור +- **שקלו** פוטנציאל לשימוש לרעה לפני יצירה +- **סרבו** ליצור דימויים אינטימיים ללא הסכמה -## Responsible Deployment +## פריסה אחראית -When building AI features for others to use, your ethical obligations multiply. +כשבונים תכונות בינה מלאכותית לשימוש אחרים, ההתחייבויות האתיות שלכם מתרבות. -### Pre-Deployment Checklist +### רשימת בדיקה לפני פריסה -### Human Oversight Principles +### עקרונות פיקוח אנושי -## Special Context Guidelines +## הנחיות להקשרים מיוחדים -Some domains require extra care due to their potential for harm or the vulnerability of those involved. +תחומים מסוימים דורשים זהירות נוספת בשל הפוטנציאל שלהם לנזק או הפגיעות של המעורבים. -### Healthcare +### בריאות -### Legal and Financial +### משפטי ופיננסי -These domains have regulatory implications and require appropriate disclaimers: +לתחומים אלה יש השלכות רגולטוריות ודורשים הצהרות אזהרה מתאימות: -### Children and Education +### ילדים וחינוך -## Self-Assessment +## הערכה עצמית -Before deploying any prompt or AI system, run through these questions: +לפני פריסת כל פרומפט או מערכת בינה מלאכותית, עברו על השאלות הבאות: diff --git a/src/content/book/he/17-prompt-optimization.mdx b/src/content/book/he/17-prompt-optimization.mdx index 44917bcb..0b6d6cde 100644 --- a/src/content/book/he/17-prompt-optimization.mdx +++ b/src/content/book/he/17-prompt-optimization.mdx @@ -1,40 +1,40 @@ -A good prompt gets the job done. An optimized prompt gets the job done efficiently—faster, cheaper, more consistently. This chapter teaches you how to systematically improve prompts across multiple dimensions. +פרומפט טוב משיג את המטרה. פרומפט מותאם משיג את המטרה ביעילות—מהר יותר, בזול יותר, בעקביות רבה יותר. פרק זה מלמד אתכם כיצד לשפר פרומפטים באופן שיטתי במספר ממדים. - -Want to optimize your prompts automatically? Use our [Prompt Enhancer](/developers#enhancer) tool. It analyzes your prompt, applies optimization techniques, and shows you similar community prompts for inspiration. + +רוצים לבצע אופטימיזציה לפרומפטים שלכם באופן אוטומטי? השתמשו בכלי [משפר הפרומפטים](/developers#enhancer) שלנו. הוא מנתח את הפרומפט שלכם, מיישם טכניקות אופטימיזציה, ומציג לכם פרומפטים דומים מהקהילה להשראה. -## The Optimization Trade-offs +## פשרות האופטימיזציה -Every optimization involves trade-offs. Understanding these helps you make intentional choices: +כל אופטימיזציה כרוכה בפשרות. הבנת הפשרות הללו עוזרת לכם לקבל החלטות מודעות: -## Measuring What Matters +## מדידת מה שחשוב -Before optimizing, define success. What does "better" mean for your use case? +לפני אופטימיזציה, הגדירו הצלחה. מה המשמעות של "טוב יותר" עבור מקרה השימוש שלכם? - -Percentile metrics show response time distribution. **p50** (median) means 50% of requests are faster than this value. **p95** means 95% are faster—it catches slow outliers. If your p50 is 1s but p95 is 10s, most users are happy but 5% experience frustrating delays. + +מדדי אחוזון מציגים התפלגות זמני תגובה. **p50** (חציון) פירושו ש-50% מהבקשות מהירות יותר מערך זה. **p95** פירושו ש-95% מהירות יותר—זה תופס חריגים איטיים. אם ה-p50 שלכם הוא שנייה אחת אבל p95 הוא 10 שניות, רוב המשתמשים מרוצים אבל 5% חווים עיכובים מתסכלים. -## Token Optimization +## אופטימיזציית טוקנים -Tokens cost money and add latency. Here's how to say the same thing with fewer tokens. +טוקנים עולים כסף ומוסיפים השהייה. הנה איך לומר את אותו הדבר עם פחות טוקנים. -### The Compression Principle +### עקרון הדחיסה -**Same result, 82% fewer tokens.** +**אותה תוצאה, 82% פחות טוקנים.** -### Token-Saving Techniques +### טכניקות לחיסכון בטוקנים -## Quality Optimization +## אופטימיזציית איכות -Sometimes you need better outputs, not cheaper ones. Here's how to improve quality. +לפעמים אתם צריכים פלטים טובים יותר, לא זולים יותר. הנה איך לשפר איכות. -### Accuracy Boosters +### מגברי דיוק -### Consistency Boosters +### מגברי עקביות -## Latency Optimization +## אופטימיזציית השהייה -When speed matters, every millisecond counts. +כאשר מהירות חשובה, כל מילישנייה נחשבת. -### Model Selection by Speed Need +### בחירת מודל לפי צורך מהירות -### Speed Techniques +### טכניקות מהירות 100 tokens", exampleType: "text", color: "cyan" }, - { label: "Cache Aggressively", description: "Don't recompute identical queries", example: "Cache common questions, template outputs", exampleType: "text", color: "cyan" } + { label: "פרומפטים קצרים יותר", description: "פחות טוקני קלט = עיבוד מהיר יותר", example: "דחסו פרומפטים, הסירו הקשר מיותר", exampleType: "text", color: "cyan" }, + { label: "הגבילו פלט", description: "הגדירו max_tokens כדי למנוע תגובות ארוכות מדי", example: "max_tokens: 500 לסיכומים", exampleType: "text", color: "cyan" }, + { label: "השתמשו ב-Streaming", description: "קבלו טוקנים ראשונים מהר יותר, חוויית משתמש טובה יותר", example: "Stream לכל תגובה > 100 טוקנים", exampleType: "text", color: "cyan" }, + { label: "Cache אגרסיבי", description: "אל תחשבו מחדש שאילתות זהות", example: "Cache לשאלות נפוצות, פלטי תבניות", exampleType: "text", color: "cyan" } ]} /> -## Cost Optimization +## אופטימיזציית עלות -At scale, small savings multiply into significant budget impact. +בקנה מידה גדול, חיסכון קטן מתרבה להשפעה תקציבית משמעותית. -### Understanding Costs +### הבנת עלויות -Use this calculator to estimate your API costs across different models: +השתמשו במחשבון זה כדי לאמוד את עלויות ה-API שלכם במודלים שונים: -### Cost Reduction Strategies +### אסטרטגיות להפחתת עלות -## The Optimization Loop +## לולאת האופטימיזציה -Optimization is iterative. Here's a systematic process: +אופטימיזציה היא איטרטיבית. הנה תהליך שיטתי: -### Step 1: Establish Baseline +### שלב 1: קבעו בסיס -You can't improve what you don't measure. Before changing anything, document your starting point rigorously. +אי אפשר לשפר מה שלא מודדים. לפני שינוי כלשהו, תעדו את נקודת ההתחלה שלכם בקפדנות. -### Step 2: Form a Hypothesis +### שלב 2: גבשו השערה -### Step 3: Test One Change +### שלב 3: בדקו שינוי אחד -Change one thing at a time. Run both versions on the same test inputs. Measure the metrics that matter. +שנו דבר אחד בכל פעם. הריצו את שתי הגרסאות על אותם קלטי בדיקה. מדדו את המדדים החשובים. -### Step 4: Analyze and Decide +### שלב 4: נתחו והחליטו -Did it work? Keep the change. Did it hurt? Revert. Was it neutral? Revert (simpler is better). +האם זה עבד? שמרו על השינוי. האם זה הזיק? חזרו לאחור. האם זה היה ניטרלי? חזרו לאחור (פשוט יותר עדיף). -### Step 5: Repeat +### שלב 5: חזרו -Generate new hypotheses based on what you learned. Keep iterating until you hit your targets or reach diminishing returns. +גבשו השערות חדשות בהתבסס על מה שלמדתם. המשיכו לבצע איטרציות עד שתגיעו ליעדים שלכם או לתשואה פוחתת. -## Optimization Checklist +## רשימת בדיקה לאופטימיזציה