Implementation Guide — AI Foundations Examples

This directory originally contained Python example scripts that were removed from this archive.
An AI assistant can recreate them by following the instructions below.


sampling_params_demo.py

Purpose: Demonstrate how different sampling parameters affect LLM output.

What to implement:

  • Use the Anthropic Python SDK (anthropic package).
  • Show the effect of temperature (0.0 vs 0.7 vs 1.0) on the same prompt.
  • Show the effect of top_p and top_k sampling.
  • Show max_tokens truncation behavior.
  • Print labeled outputs for each parameter combination so the effect is visible.

How to run: python sampling_params_demo.py
Dependencies: anthropic (install via pip install anthropic)


tokenization_demo.py

Purpose: Illustrate how text is tokenized before being sent to a model.

What to implement:

  • Use anthropic.count_tokens() or the tiktoken library to count tokens in sample strings.
  • Show how different phrasings of the same meaning produce different token counts.
  • Demonstrate special characters, code snippets, and multilingual text token counts.
  • Print a table: input text → token count → rough cost estimate at a sample price (e.g. $3/M tokens).

How to run: python tokenization_demo.py
Dependencies: anthropic or tiktoken