|
5 | 5 | "cell_type": "markdown",
|
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
| 8 | + "<a href=\"https://colab.research.google.com/github/meta-llama/llama-recipes/blob/main/recipes/quickstart/Prompt_Engineering_with_Llama_3.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n", |
| 9 | + "\n", |
8 | 10 | "# Prompt Engineering with Llama 3\n",
|
9 | 11 | "\n",
|
10 | 12 | "Prompt engineering is using natural language to produce a desired response from a large language model (LLM).\n",
|
|
45 | 47 | "\n",
|
46 | 48 | "#### Llama 3\n",
|
47 | 49 | "1. `llama-3-8b` - base pretrained 8 billion parameter model\n",
|
48 |
| - "1. `llama-3-70b` - base pretrained 8 billion parameter model\n", |
| 50 | + "1. `llama-3-70b` - base pretrained 70 billion parameter model\n", |
49 | 51 | "1. `llama-3-8b-instruct` - instruction fine-tuned 8 billion parameter model\n",
|
50 | 52 | "1. `llama-3-70b-instruct` - instruction fine-tuned 70 billion parameter model (flagship)\n",
|
51 | 53 | "\n",
|
|
75 | 77 | "1. `codellama-7b` - code fine-tuned 7 billion parameter model\n",
|
76 | 78 | "1. `codellama-13b` - code fine-tuned 13 billion parameter model\n",
|
77 | 79 | "1. `codellama-34b` - code fine-tuned 34 billion parameter model\n",
|
| 80 | + "1. `codellama-70b` - code fine-tuned 70 billion parameter model\n", |
78 | 81 | "1. `codellama-7b-instruct` - code & instruct fine-tuned 7 billion parameter model\n",
|
79 | 82 | "2. `codellama-13b-instruct` - code & instruct fine-tuned 13 billion parameter model\n",
|
80 | 83 | "3. `codellama-34b-instruct` - code & instruct fine-tuned 34 billion parameter model\n",
|
| 84 | + "3. `codellama-70b-instruct` - code & instruct fine-tuned 70 billion parameter model\n", |
81 | 85 | "1. `codellama-7b-python` - Python fine-tuned 7 billion parameter model\n",
|
82 | 86 | "2. `codellama-13b-python` - Python fine-tuned 13 billion parameter model\n",
|
83 |
| - "3. `codellama-34b-python` - Python fine-tuned 34 billion parameter model" |
| 87 | + "3. `codellama-34b-python` - Python fine-tuned 34 billion parameter model\n", |
| 88 | + "3. `codellama-70b-python` - Python fine-tuned 70 billion parameter model" |
84 | 89 | ]
|
85 | 90 | },
|
86 | 91 | {
|
|
124 | 129 | "\n",
|
125 | 130 | "> Our destiny is written in the stars.\n",
|
126 | 131 | "\n",
|
127 |
| - "...is tokenized into `[\"Our\", \"destiny\", \"is\", \"written\", \"in\", \"the\", \"stars\", \".\"]` for Llama 3.\n", |
| 132 | + "...is tokenized into `[\"Our\", \" destiny\", \" is\", \" written\", \" in\", \" the\", \" stars\", \".\"]` for Llama 3. See [this](https://tiktokenizer.vercel.app/?model=meta-llama%2FMeta-Llama-3-8B) for an interactive tokenizer tool.\n", |
128 | 133 | "\n",
|
129 | 134 | "Tokens matter most when you consider API pricing and internal behavior (ex. hyperparameters).\n",
|
130 | 135 | "\n",
|
131 |
| - "Each model has a maximum context length that your prompt cannot exceed. That's 8K tokens for Llama 3 and 100K for Code Llama. \n" |
| 136 | + "Each model has a maximum context length that your prompt cannot exceed. That's 8K tokens for Llama 3, 4K for Llama 2, and 100K for Code Llama. \n" |
132 | 137 | ]
|
133 | 138 | },
|
134 | 139 | {
|
|
164 | 169 | "from groq import Groq\n",
|
165 | 170 | "\n",
|
166 | 171 | "# Get a free API key from https://console.groq.com/keys\n",
|
167 |
| - "# os.environ[\"GROQ_API_KEY\"] = \"YOUR_KEY_HERE\"\n", |
| 172 | + "os.environ[\"GROQ_API_KEY\"] = \"YOUR_GROQ_API_KEY\"\n", |
168 | 173 | "\n",
|
169 | 174 | "LLAMA3_70B_INSTRUCT = \"llama3-70b-8192\"\n",
|
170 | 175 | "LLAMA3_8B_INSTRUCT = \"llama3-8b-8192\"\n",
|
|
699 | 704 | "source": [
|
700 | 705 | "### Limiting Extraneous Tokens\n",
|
701 | 706 | "\n",
|
702 |
| - "A common struggle is getting output without extraneous tokens (ex. \"Sure! Here's more information on...\").\n", |
| 707 | + "A common struggle with Llama 2 is getting output without extraneous tokens (ex. \"Sure! Here's more information on...\"), even if explicit instructions are given to Llama 2 to be concise and no preamble. Llama 3 can better follow instructions.\n", |
703 | 708 | "\n",
|
704 | 709 | "Check out this improvement that combines a role, rules and restrictions, explicit instructions, and an example:"
|
705 | 710 | ]
|
|
766 | 771 | "name": "python",
|
767 | 772 | "nbconvert_exporter": "python",
|
768 | 773 | "pygments_lexer": "ipython3",
|
769 |
| - "version": "3.12.3" |
| 774 | + "version": "3.10.14" |
770 | 775 | },
|
771 | 776 | "last_base_url": "https://bento.edge.x2p.facebook.net/",
|
772 | 777 | "last_kernel_id": "161e2a7b-2d2b-4995-87f3-d1539860ecac",
|
|
0 commit comments