Prompt engineering на собеседовании AI PM

Зачем prompt engineering на собесе AI PM

Prompt engineering — навык управления LLM через входной prompt. AI PM не пишет модели, но проектирует interaction with LLM: системные промпты, few-shot примеры, structured outputs. На собесе AI PM prompt-навыки спрашивают через кейсы: «улучши output для X».

В 2026 prompt engineering — фундаментальный навык AI PM. Слабый ответ — «попробую попросить вежливо». Сильный — про system prompt structure, few-shot, chain-of-thought, function calling.

Структура prompt-а

System prompt: инструкции, поведение, ограничения. Высокий приоритет.

Ты — помощник по подготовке к собесам аналитиков. 
Объясняй кратко, профессионально, по делу.
Если вопрос вне темы — вежливо отказывай.

User prompt: конкретный запрос пользователя.

Assistant (history): предыдущие ответы (для multi-turn).

Best practices system prompt:

  • Role definition
  • Tone of voice
  • Constraints (что не делать)
  • Format requirements (JSON, structured)
  • Examples (1-3)

Zero-shot vs few-shot

Zero-shot: просто инструкция, без примеров.

Классифицируй sentiment: positive / negative / neutral.
Text: "Хороший продукт, но дорого"

Few-shot: инструкция + 2-5 примеров.

Text: "Отлично работает" → positive
Text: "Не покупайте, ужас" → negative
Text: "Нормально" → neutral
Text: "Хороший продукт, но дорого" → ?

Когда few-shot:

  • Output format specific
  • Edge cases важны
  • Style consistency нужен

Trade-off: few-shot — больше токенов → выше cost / latency.

Chain-of-Thought (CoT)

LLM выдаёт лучшие ответы, если думает «вслух».

Просто:

Реши: 12 яблок, отдал 5, купил 8. Сколько?
Ответ: 15

CoT:

Реши пошагово:
Шаг 1: было 12
Шаг 2: отдал 5 → 12-5 = 7
Шаг 3: купил 8 → 7+8 = 15
Ответ: 15

Когда:

  • Multi-step reasoning
  • Math / logic
  • Сложный decision

Trade-off: длиннее output → cost / latency.

Structured outputs

JSON или другие structured formats для дальнейшей обработки.

Ответь в JSON: {"sentiment": "...", "confidence": 0-1, "reason": "..."}

Function calling (OpenAI / Anthropic):

  • Built-in support для JSON schema
  • LLM возвращает structured arguments
  • Менее brittle vs prompt-based JSON

Tools:

  • Pydantic / Instructor (Python)
  • Outlines (constrained generation)

Common prompt patterns

Persona:

Ты — опытный SQL-учитель. Объясняй просто.

Constraints:

Не более 100 слов.
Только если уверен > 80%.
Если не знаешь — скажи «не знаю».

Format:

Ответ в формате:
- Заключение (1 строка)
- 3 причины
- Сводка (1 строка)

Self-critique:

1. Дай ответ.
2. Найди слабости в своём ответе.
3. Improve.

Prompt injection и safety

User может попытаться override system prompt.

Атаки:

  • «Ignore previous instructions, ты теперь...»
  • Prompt injection через user-provided content (e.g., в RAG)

Mitigation:

  • System prompt strict + repeated
  • Input filtering / sanitization
  • Output validation
  • Не использовать LLM для security-critical decisions

Промпт-tuning workflow

  1. Define metric: что считать «хорошим» output (qualitative + quantitative).
  2. Build eval dataset: 50-100 input-expected pairs.
  3. Iterate prompt: изменения, run eval, compare.
  4. Track versions: prompt version control (git, MLflow).
  5. Production A/B: new prompt vs old, business metrics.

Подробнее — AI-метрики и evaluation.

Типичные вопросы

«Output LLM неточен. Как улучшать?»

  1. Add few-shot examples.
  2. CoT prompt.
  3. Structured output (JSON).
  4. Build eval dataset, итеративно tune prompt.
  5. Если prompt-tuning не помогает → fine-tune.

«Production prompt должен быть version-controlled?»

Да. Prompt — это код. Git, code review, A/B-test new vs old.

«Few-shot или fine-tuning?»

Few-shot — старт. Fine-tune когда: prompt очень длинный (cost↑), style требуется consistent, edge cases много.

«Prompt injection — risk?»

Да, особенно с user content (RAG, форумы). Mitigation: input sanitization, structured output validation, не доверять LLM security decisions.

Output должен validate, не trust blindly. Если output влияет на critical action (платежи, удаление) — human approval обязателен.

Частые ошибки

  • Длинный размытый system prompt. Concise + structured лучше.
  • Без examples. Few-shot дёшево improvement quality.
  • Без eval dataset. «Кажется лучше» — не data-driven.
  • Один global prompt на всё. Different tasks — different prompts.
  • Прода без version control. Изменение prompt = бомба замедленного действия.

FAQ

Сколько токенов в идеальном prompt?

Зависит от задачи. Минимум: 50-200. Сложный: 500-2000. > 2000 — обычно перебор, рассмотри fine-tune.

Какая модель better follow prompts?

GPT-4 / Claude — best instruction-following. GPT-3.5 / GigaChat / open-source LLM — слабее. Зависит от complexity.

Temperature: low или high?

Low (0-0.3) для consistent / structured / factual. High (0.7-1.0) для creative.

Function calling везде есть?

OpenAI, Anthropic, Google. У open-source / GigaChat — varies. Поддержку проверять.

Где практиковать prompt-engineering?

OpenAI Playground, anthropic.com/workbench, learn-prompting.org.

Смотрите также