AIF-C01 notes
Developing generative AI solutions

Improving the Performance of an FM

Four ways to improve a selected FM: prompt engineering, RAG, fine-tuning, and agents. Building a model from scratch is the last resort.

Prompt engineering

The fastest way to steer an LLM. You craft the instructions, context, and examples in the prompt.

  • Aspects: design, augmentation (examples, constraints), tuning (iterating on prompts), ensembling (combining prompts), and mining (finding effective prompts).
  • Techniques: zero-shot, few-shot, chain-of-thought (CoT), self-consistency, tree of thoughts (ToT), RAG, Automatic Reasoning and Tool-use (ART), and ReAct.

Retrieval-augmented generation (RAG)

Combines a retrieval system, which finds relevant passages in a knowledge source, with a generative model, which writes an answer using them.

Business applications:

  • Question-answering systems grounded in company knowledge, such as support bots and virtual assistants
  • Expanding and enriching knowledge bases
  • Generating content such as articles, reports, and summaries

Knowledge Bases for Amazon Bedrock gather your data sources into a repository that RAG applications draw on, for customer service, legal research, or healthcare Q&A.

Fine-tuning

Further trains a pre-trained model on task- or domain-specific labeled data. It changes the model's weights.

  • Instruction fine-tuning: examples of how to respond to instructions. Prompt tuning is one type.
  • RLHF: human feedback aligns the model with human preferences.

Use it when the model needs domain terminology and knowledge, for example fine-tuning on medical journals.

Building from scratch

Define the architecture, curate a huge dataset, and train from random weights. You get full customization at a very high cost in compute, time, and expertise. It suits research or cases where no pre-trained model fits.

Cost versus accuracy

From cheapest to most expensive: prompt engineering, then RAG, then fine-tuning, then pre-training from scratch. More customization can mean higher accuracy but also more cost, data, and expertise.

Agents

Agents are software that carry out multi-step tasks autonomously. In Amazon Bedrock, they:

  • Coordinate tasks: run subtasks in the right order and manage dependencies. This is their core role.
  • Report and log progress and diagnostics
  • Handle scalability and concurrency
  • Integrate with other systems through APIs and message queues

On this page