liveBook · Manning

Prompt engineering

As explained in Deep Learning with JAX

The practice of shaping input prompts to get better outputs from a pretrained language model without changing its weights.

Prompt engineering structures input text so a pretrained language model produces results closer to the task you want. It is often the first practical step when using an existing model, but results may still need checking or additional orchestration. section 11.3.1 section 11.3.2

A prompt-engineering workflow should account for both prompt design and output limitations:

  • Inspect generated results instead of assuming they are directly usable: outputs may include formatting text, multiple answers, repetition, or syntax errors. section 11.3.1
  • Move beyond prompting when quality remains insufficient, using orchestration, fine-tuning, retrieval-augmented generation, or pretraining as appropriate. section 11.3.1 section 11.3.2

Generating SQL from natural language

A prompt can ask a causal language model to generate SQL from text enclosed in triple backticks, then pass the prompt through a tokenizer and generation call. The resulting SQL still requires validation: generated text may surround the commands, contain several alternatives, repeat indefinitely, or include errors such as an unmatched quote. section 11.3.1

How Deep Learning with JAX covers it

How deep it goes
Defines prompt structuring and names chain of thought, but defers detailed techniques and implementation.
Examples
Uses a GPT-J prompt that requests SQL from natural language enclosed in triple backticks.
What it assumes
Assumes access to a pretrained language model, tokenizer, and text-generation interface.
What you can do after
Evaluate generated outputs for formatting, multiplicity, repetition, and syntax errors before using them.
How it connects
Links pretrained models, text generation, orchestration, fine-tuning, pretraining, and retrieval-augmented generation.

Also explained in

Compare how 38 books explain prompt engineering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with JAX. The section links point to the parts of the book it draws on.