Browse Source

Fix more package naming (#864)

Sanyam Bhutani 2 months ago
parent
commit
46796d5b34
28 changed files with 138 additions and 135 deletions
  1. 2 2
      3p-integrations/crusoe/vllm-fp8/README.md
  2. 1 1
      3p-integrations/llama_on_prem.md
  3. 1 1
      3p-integrations/tgi/README.md
  4. 62 59
      3p-integrations/using_externally_hosted_llms.ipynb
  5. 2 2
      end-to-end-use-cases/RAFT-Chatbot/README.md
  6. 2 2
      end-to-end-use-cases/benchmarks/llm_eval_harness/meta_eval/README.md
  7. 1 1
      end-to-end-use-cases/coding/text2sql/quickstart.ipynb
  8. 1 1
      end-to-end-use-cases/customerservice_chatbots/RAG_chatbot/RAG_Chatbot_Example.ipynb
  9. 1 1
      end-to-end-use-cases/github_triage/README.md
  10. 1 1
      end-to-end-use-cases/github_triage/walkthrough.ipynb
  11. 1 1
      end-to-end-use-cases/responsible_ai/code_shield_usage_demo.ipynb
  12. 1 1
      end-to-end-use-cases/responsible_ai/llama_guard/README.md
  13. 11 11
      end-to-end-use-cases/responsible_ai/llama_guard/llama_guard_customization_via_prompting_and_fine_tuning.ipynb
  14. 1 1
      end-to-end-use-cases/responsible_ai/prompt_guard/README.md
  15. 1 1
      getting-started/README.md
  16. 1 1
      getting-started/finetuning/finetune_vision_model.md
  17. 1 1
      getting-started/finetuning/finetuning.py
  18. 9 9
      getting-started/finetuning/quickstart_peft_finetuning.ipynb
  19. 3 3
      getting-started/inference/local_inference/inference.py
  20. 1 1
      getting-started/inference/mobile_inference/android_inference/README.md
  21. 1 1
      pyproject.toml
  22. 4 4
      src/llama_cookbook/configs/datasets.py
  23. 2 2
      src/llama_cookbook/configs/wandb.py
  24. 2 2
      src/llama_cookbook/data/llama_guard/README.md
  25. 6 6
      src/llama_cookbook/finetuning.py
  26. 16 16
      src/llama_cookbook/inference/safety_utils.py
  27. 1 1
      src/llama_cookbook/tools/README.md
  28. 2 2
      src/llama_cookbook/utils/config_utils.py

+ 2 - 2
3p-integrations/crusoe/vllm-fp8/README.md

@@ -23,8 +23,8 @@ source $HOME/.cargo/env
 
 
 Now, clone the recipes and navigate to this tutorial. Initialize the virtual environment and install dependencies:
 Now, clone the recipes and navigate to this tutorial. Initialize the virtual environment and install dependencies:
 ```bash
 ```bash
-git clone https://github.com/meta-llama/llama-recipes.git
-cd llama-recipes/recipes/3p_integrations/crusoe/vllm-fp8/
+git clone https://github.com/meta-llama/llama-cookbook.git
+cd llama-cookbook/recipes/3p_integrations/crusoe/vllm-fp8/
 uv add vllm setuptools
 uv add vllm setuptools
 ```
 ```
 
 

File diff suppressed because it is too large
+ 1 - 1
3p-integrations/llama_on_prem.md


+ 1 - 1
3p-integrations/tgi/README.md

@@ -9,7 +9,7 @@ In case the model was fine tuned with LoRA method we need to merge the weights o
 The script takes the base model, the peft weight folder as well as an output as arguments:
 The script takes the base model, the peft weight folder as well as an output as arguments:
 
 
 ```
 ```
-python -m llama_recipes.recipes.3p_integration.tgi.merge_lora_weights --base_model llama-7B --peft_model ft_output --output_dir data/merged_model_output
+python -m llama_cookbook.recipes.3p_integration.tgi.merge_lora_weights --base_model llama-7B --peft_model ft_output --output_dir data/merged_model_output
 ```
 ```
 
 
 ## Step 1: Serving the model
 ## Step 1: Serving the model

File diff suppressed because it is too large
+ 62 - 59
3p-integrations/using_externally_hosted_llms.ipynb


File diff suppressed because it is too large
+ 2 - 2
end-to-end-use-cases/RAFT-Chatbot/README.md


+ 2 - 2
end-to-end-use-cases/benchmarks/llm_eval_harness/meta_eval/README.md

@@ -25,8 +25,8 @@ Given those differences, the numbers from this recipe can not be compared to the
 Please install lm-evaluation-harness and our llama-recipe repo by following:
 Please install lm-evaluation-harness and our llama-recipe repo by following:
 
 
 ```
 ```
-git clone git@github.com:meta-llama/llama-recipes.git
-cd llama-recipes
+git clone git@github.com:meta-llama/llama-cookbook.git
+cd llama-cookbook
 pip install -U pip setuptools
 pip install -U pip setuptools
 pip install -e .
 pip install -e .
 pip install lm-eval[math,ifeval,sentencepiece,vllm]==0.4.3
 pip install lm-eval[math,ifeval,sentencepiece,vllm]==0.4.3

+ 1 - 1
end-to-end-use-cases/coding/text2sql/quickstart.ipynb

@@ -1,5 +1,5 @@
 {
 {
- "cells": [
+ "cells": [llama-cookbook
   {
   {
    "cell_type": "markdown",
    "cell_type": "markdown",
    "id": "e8cba0b6",
    "id": "e8cba0b6",

+ 1 - 1
end-to-end-use-cases/customerservice_chatbots/RAG_chatbot/RAG_Chatbot_Example.ipynb

@@ -402,7 +402,7 @@
     "In this example, we will be deploying a Meta Llama 3 8B chat HuggingFace model with the Text-generation-inference framework on-permises.  \n",
     "In this example, we will be deploying a Meta Llama 3 8B chat HuggingFace model with the Text-generation-inference framework on-permises.  \n",
     "This would allow us to directly wire the API server with our chatbot.  \n",
     "This would allow us to directly wire the API server with our chatbot.  \n",
     "There are alternative solutions to deploy Meta Llama 3 models on-permises as your local API server.  \n",
     "There are alternative solutions to deploy Meta Llama 3 models on-permises as your local API server.  \n",
-    "You can find our complete guide [here](https://github.com/meta-llama/llama-recipes/blob/main/recipes/inference/model_servers/llama-on-prem.md)."
+    "You can find our complete guide [here](https://github.com/meta-llama/llama-cookbook/blob/main/recipes/inference/model_servers/llama-on-prem.md)."
    ]
    ]
   },
   },
   {
   {

+ 1 - 1
end-to-end-use-cases/github_triage/README.md

@@ -32,7 +32,7 @@ pip install -r requirements.txt
 ### Running the Tool
 ### Running the Tool
 
 
 ```bash
 ```bash
-python triage.py --repo_name='meta-llama/llama-recipes' --start_date='2024-08-14' --end_date='2024-08-27'
+python triage.py --repo_name='meta-llama/llama-cookbook' --start_date='2024-08-14' --end_date='2024-08-27'
 ```
 ```
 
 
 ### Output
 ### Output

+ 1 - 1
end-to-end-use-cases/github_triage/walkthrough.ipynb

@@ -1,4 +1,4 @@
-{
+{llama-cookbookllama-cookbook
   "cells": [
   "cells": [
     {
     {
       "cell_type": "code",
       "cell_type": "code",

+ 1 - 1
end-to-end-use-cases/responsible_ai/code_shield_usage_demo.ipynb

@@ -151,7 +151,7 @@
     "import os\n",
     "import os\n",
     "import getpass\n",
     "import getpass\n",
     "\n",
     "\n",
-    "from llama_recipes.inference.llm import TOGETHER, OPENAI, ANYSCALE\n",
+    "from llama_cookbook.inference.llm import TOGETHER, OPENAI, ANYSCALE\n",
     "\n",
     "\n",
     "if \"EXTERNALLY_HOSTED_LLM_TOKEN\" not in os.environ:\n",
     "if \"EXTERNALLY_HOSTED_LLM_TOKEN\" not in os.environ:\n",
     "    os.environ[\"EXTERNALLY_HOSTED_LLM_TOKEN\"] = getpass.getpass(prompt=\"Provide token for LLM provider\")\n",
     "    os.environ[\"EXTERNALLY_HOSTED_LLM_TOKEN\"] = getpass.getpass(prompt=\"Provide token for LLM provider\")\n",

+ 1 - 1
end-to-end-use-cases/responsible_ai/llama_guard/README.md

@@ -6,7 +6,7 @@ This [notebook](llama_guard_text_and_vision_inference.ipynb) shows how to load t
 
 
 ## Requirements
 ## Requirements
 1. Access to Llama guard model weights on Hugging Face. To get access, follow the steps described in the top of the model card in [Hugging Face](https://huggingface.co/meta-llama/Llama-Guard-3-1B)
 1. Access to Llama guard model weights on Hugging Face. To get access, follow the steps described in the top of the model card in [Hugging Face](https://huggingface.co/meta-llama/Llama-Guard-3-1B)
-2. Llama recipes package and its dependencies [installed](https://github.com/meta-llama/llama-recipes?tab=readme-ov-file#installing)
+2. Llama recipes package and its dependencies [installed](https://github.com/meta-llama/llama-cookbook?tab=readme-ov-file#installing)
 3. Pillow package installed
 3. Pillow package installed
 
 
 ## Inference Safety Checker
 ## Inference Safety Checker

+ 11 - 11
end-to-end-use-cases/responsible_ai/llama_guard/llama_guard_customization_via_prompting_and_fine_tuning.ipynb

@@ -33,7 +33,7 @@
     "\n",
     "\n",
     "Llama Guard is provided with a reference taxonomy explained on [this page](https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-guard-3), where the prompting format is also explained. \n",
     "Llama Guard is provided with a reference taxonomy explained on [this page](https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-guard-3), where the prompting format is also explained. \n",
     "\n",
     "\n",
-    "The functions below combine already existing [prompt formatting code in llama-recipes](https://github.com/meta-llama/llama-recipes/blob/main/src/llama_recipes/inference/prompt_format_utils.py) with custom code to aid in the custimization of the taxonomy. "
+    "The functions below combine already existing [prompt formatting code in llama-recipes](https://github.com/meta-llama/llama-recipes/blob/main/src/llama_cookbook/inference/prompt_format_utils.py) with custom code to aid in the custimization of the taxonomy. "
    ]
    ]
   },
   },
   {
   {
@@ -80,7 +80,7 @@
    ],
    ],
    "source": [
    "source": [
     "from enum import Enum\n",
     "from enum import Enum\n",
-    "from llama_recipes.inference.prompt_format_utils import  LLAMA_GUARD_3_CATEGORY, SafetyCategory, AgentType\n",
+    "from llama_cookbook.inference.prompt_format_utils import  LLAMA_GUARD_3_CATEGORY, SafetyCategory, AgentType\n",
     "from typing import List\n",
     "from typing import List\n",
     "\n",
     "\n",
     "class LG3Cat(Enum):\n",
     "class LG3Cat(Enum):\n",
@@ -158,7 +158,7 @@
     }
     }
    ],
    ],
    "source": [
    "source": [
-    "from llama_recipes.inference.prompt_format_utils import build_custom_prompt, create_conversation, PROMPT_TEMPLATE_3, LLAMA_GUARD_3_CATEGORY_SHORT_NAME_PREFIX\n",
+    "from llama_cookbook.inference.prompt_format_utils import build_custom_prompt, create_conversation, PROMPT_TEMPLATE_3, LLAMA_GUARD_3_CATEGORY_SHORT_NAME_PREFIX\n",
     "from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig\n",
     "from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig\n",
     "from typing import List, Tuple\n",
     "from typing import List, Tuple\n",
     "from enum import Enum\n",
     "from enum import Enum\n",
@@ -463,13 +463,13 @@
     "\n",
     "\n",
     "To add additional datasets\n",
     "To add additional datasets\n",
     "\n",
     "\n",
-    "1. Copy llama-recipes/src/llama_recipes/datasets/toxicchat_dataset.py \n",
+    "1. Copy llama-recipes/src/llama_cookbook/datasets/toxicchat_dataset.py \n",
     "2. Modify the file to change the dataset used\n",
     "2. Modify the file to change the dataset used\n",
     "3. Add references to the new dataset in \n",
     "3. Add references to the new dataset in \n",
-    "    - llama-recipes/src/llama_recipes/configs/datasets.py\n",
-    "    - llama_recipes/datasets/__init__.py\n",
-    "    - llama_recipes/datasets/toxicchat_dataset.py\n",
-    "    - llama_recipes/utils/dataset_utils.py\n",
+    "    - llama-recipes/src/llama_cookbook/configs/datasets.py\n",
+    "    - llama_cookbook/datasets/__init__.py\n",
+    "    - llama_cookbook/datasets/toxicchat_dataset.py\n",
+    "    - llama_cookbook/utils/dataset_utils.py\n",
     "\n",
     "\n",
     "\n",
     "\n",
     "## Evaluation\n",
     "## Evaluation\n",
@@ -484,7 +484,7 @@
    "source": [
    "source": [
     "from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig\n",
     "from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig\n",
     "\n",
     "\n",
-    "from llama_recipes.inference.prompt_format_utils import build_default_prompt, create_conversation, LlamaGuardVersion\n",
+    "from llama_cookbook.inference.prompt_format_utils import build_default_prompt, create_conversation, LlamaGuardVersion\n",
     "from llama.llama.generation import Llama\n",
     "from llama.llama.generation import Llama\n",
     "\n",
     "\n",
     "from typing import List, Optional, Tuple, Dict\n",
     "from typing import List, Optional, Tuple, Dict\n",
@@ -726,7 +726,7 @@
     "#     \"unsafe_content\": [\"O1\"]\n",
     "#     \"unsafe_content\": [\"O1\"]\n",
     "# }\n",
     "# }\n",
     "# ```\n",
     "# ```\n",
-    "from llama_recipes.datasets.toxicchat_dataset import get_llamaguard_toxicchat_dataset\n",
+    "from llama_cookbook.datasets.toxicchat_dataset import get_llamaguard_toxicchat_dataset\n",
     "validation_data = get_llamaguard_toxicchat_dataset(None, None, \"train\", return_jsonl = True)[0:100]\n",
     "validation_data = get_llamaguard_toxicchat_dataset(None, None, \"train\", return_jsonl = True)[0:100]\n",
     "run_validation(validation_data, AgentType.USER, Type.HF, load_in_8bit = False, load_in_4bit = True)"
     "run_validation(validation_data, AgentType.USER, Type.HF, load_in_8bit = False, load_in_4bit = True)"
    ]
    ]
@@ -757,7 +757,7 @@
    "outputs": [],
    "outputs": [],
    "source": [
    "source": [
     "model_id = \"meta-llama/Llama-Guard-3-8B\"\n",
     "model_id = \"meta-llama/Llama-Guard-3-8B\"\n",
-    "from llama_recipes import finetuning\n",
+    "from llama_cookbook import finetuning\n",
     "\n",
     "\n",
     "finetuning.main(\n",
     "finetuning.main(\n",
     "    model_name = model_id,\n",
     "    model_name = model_id,\n",

+ 1 - 1
end-to-end-use-cases/responsible_ai/prompt_guard/README.md

@@ -8,4 +8,4 @@ This is a very small model and inference and fine-tuning are feasible on local C
 
 
 ## Requirements
 ## Requirements
 1. Access to Prompt Guard model weights on Hugging Face. To get access, follow the steps described [here](https://github.com/facebookresearch/PurpleLlama/tree/main/Prompt-Guard#download)
 1. Access to Prompt Guard model weights on Hugging Face. To get access, follow the steps described [here](https://github.com/facebookresearch/PurpleLlama/tree/main/Prompt-Guard#download)
-2. Llama recipes package and it's dependencies [installed](https://github.com/meta-llama/llama-recipes?tab=readme-ov-file#installing)
+2. Llama recipes package and it's dependencies [installed](https://github.com/meta-llama/llama-cookbook?tab=readme-ov-file#installing)

+ 1 - 1
getting-started/README.md

@@ -1,4 +1,4 @@
-## Llama-Recipes Getting Started
+## Llama-cookbook Getting Started
 
 
 If you are new to developing with Meta Llama models, this is where you should start. This folder contains introductory-level notebooks across different techniques relating to Meta Llama.
 If you are new to developing with Meta Llama models, this is where you should start. This folder contains introductory-level notebooks across different techniques relating to Meta Llama.
 
 

+ 1 - 1
getting-started/finetuning/finetune_vision_model.md

@@ -1,7 +1,7 @@
 ## Llama 3.2 Vision Models Fine-Tuning Recipe
 ## Llama 3.2 Vision Models Fine-Tuning Recipe
 This recipe steps you through how to finetune a Llama 3.2 vision model on the OCR VQA task using the [OCRVQA](https://huggingface.co/datasets/HuggingFaceM4/the_cauldron/viewer/ocrvqa?row=0) dataset.
 This recipe steps you through how to finetune a Llama 3.2 vision model on the OCR VQA task using the [OCRVQA](https://huggingface.co/datasets/HuggingFaceM4/the_cauldron/viewer/ocrvqa?row=0) dataset.
 
 
-**Disclaimer**: As our vision models already have a very good OCR ability, here we use the OCRVQA dataset only for demonstration purposes of the required steps for fine-tuning our vision models with llama-recipes.
+**Disclaimer**: As our vision models already have a very good OCR ability, here we use the OCRVQA dataset only for demonstration purposes of the required steps for fine-tuning our vision models with llama-cookbook.
 
 
 ### Fine-tuning steps
 ### Fine-tuning steps
 
 

+ 1 - 1
getting-started/finetuning/finetuning.py

@@ -2,7 +2,7 @@
 # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
 # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
 
 
 import fire
 import fire
-from llama_recipes.finetuning import main
+from llama_cookbook.finetuning import main
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     fire.Fire(main)
     fire.Fire(main)

+ 9 - 9
getting-started/finetuning/quickstart_peft_finetuning.ipynb

@@ -31,17 +31,17 @@
    "source": [
    "source": [
     "### Step 0: Install pre-requirements and convert checkpoint\n",
     "### Step 0: Install pre-requirements and convert checkpoint\n",
     "\n",
     "\n",
-    "We need to have llama-recipes and its dependencies installed for this notebook. Additionally, we need to log in with the huggingface_cli and make sure that the account is able to to access the Meta Llama weights."
+    "We need to have llama-cookbook and its dependencies installed for this notebook. Additionally, we need to log in with the huggingface_cli and make sure that the account is able to to access the Meta Llama weights."
    ]
    ]
   },
   },
   {
   {
    "cell_type": "code",
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": null,
    "metadata": {},
    "metadata": {},
    "outputs": [],
    "outputs": [],
    "source": [
    "source": [
     "# uncomment if running from Colab T4\n",
     "# uncomment if running from Colab T4\n",
-    "# ! pip install llama-recipes ipywidgets\n",
+    "# ! pip install llama-cookbook ipywidgets\n",
     "\n",
     "\n",
     "# import huggingface_hub\n",
     "# import huggingface_hub\n",
     "# huggingface_hub.login()"
     "# huggingface_hub.login()"
@@ -59,7 +59,7 @@
   },
   },
   {
   {
    "cell_type": "code",
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": null,
    "metadata": {},
    "metadata": {},
    "outputs": [
    "outputs": [
     {
     {
@@ -80,7 +80,7 @@
    "source": [
    "source": [
     "import torch\n",
     "import torch\n",
     "from transformers import LlamaForCausalLM, AutoTokenizer\n",
     "from transformers import LlamaForCausalLM, AutoTokenizer\n",
-    "from llama_recipes.configs import train_config as TRAIN_CONFIG\n",
+    "from llama_cookbook.configs import train_config as TRAIN_CONFIG\n",
     "\n",
     "\n",
     "train_config = TRAIN_CONFIG()\n",
     "train_config = TRAIN_CONFIG()\n",
     "train_config.model_name = \"meta-llama/Meta-Llama-3.1-8B\"\n",
     "train_config.model_name = \"meta-llama/Meta-Llama-3.1-8B\"\n",
@@ -221,8 +221,8 @@
    "metadata": {},
    "metadata": {},
    "outputs": [],
    "outputs": [],
    "source": [
    "source": [
-    "from llama_recipes.configs.datasets import samsum_dataset\n",
-    "from llama_recipes.utils.dataset_utils import get_dataloader\n",
+    "from llama_cookbook.configs.datasets import samsum_dataset\n",
+    "from llama_cookbook.utils.dataset_utils import get_dataloader\n",
     "\n",
     "\n",
     "samsum_dataset.trust_remote_code = True\n",
     "samsum_dataset.trust_remote_code = True\n",
     "\n",
     "\n",
@@ -248,7 +248,7 @@
    "source": [
    "source": [
     "from peft import get_peft_model, prepare_model_for_kbit_training, LoraConfig\n",
     "from peft import get_peft_model, prepare_model_for_kbit_training, LoraConfig\n",
     "from dataclasses import asdict\n",
     "from dataclasses import asdict\n",
-    "from llama_recipes.configs import lora_config as LORA_CONFIG\n",
+    "from llama_cookbook.configs import lora_config as LORA_CONFIG\n",
     "\n",
     "\n",
     "lora_config = LORA_CONFIG()\n",
     "lora_config = LORA_CONFIG()\n",
     "lora_config.r = 8\n",
     "lora_config.r = 8\n",
@@ -278,7 +278,7 @@
    "outputs": [],
    "outputs": [],
    "source": [
    "source": [
     "import torch.optim as optim\n",
     "import torch.optim as optim\n",
-    "from llama_recipes.utils.train_utils import train\n",
+    "from llama_cookbook.utils.train_utils import train\n",
     "from torch.optim.lr_scheduler import StepLR\n",
     "from torch.optim.lr_scheduler import StepLR\n",
     "\n",
     "\n",
     "model.train()\n",
     "model.train()\n",

+ 3 - 3
getting-started/inference/local_inference/inference.py

@@ -10,9 +10,9 @@ import fire
 import torch
 import torch
 
 
 from accelerate.utils import is_xpu_available
 from accelerate.utils import is_xpu_available
-from llama_recipes.inference.model_utils import load_model, load_peft_model
+from llama_cookbook.inference.model_utils import load_model, load_peft_model
 
 
-from llama_recipes.inference.safety_utils import AgentType, get_safety_checker
+from llama_cookbook.inference.safety_utils import AgentType, get_safety_checker
 from transformers import AutoTokenizer
 from transformers import AutoTokenizer
 
 
 
 
@@ -176,7 +176,7 @@ def main(
                 )
                 )
             ],
             ],
             title="Meta Llama3 Playground",
             title="Meta Llama3 Playground",
-            description="https://github.com/meta-llama/llama-recipes",
+            description="https://github.com/meta-llama/llama-cookbook",
         ).queue().launch(server_name="0.0.0.0", share=share_gradio)
         ).queue().launch(server_name="0.0.0.0", share=share_gradio)
 
 
 
 

+ 1 - 1
getting-started/inference/mobile_inference/android_inference/README.md

@@ -103,7 +103,7 @@ Connect your phone to your development machine. On OSX, you'll be prompted on th
 
 
 ## Building the Android Package with MLC
 ## Building the Android Package with MLC
 
 
-First edit the file under `android/MLCChat/mlc-package-config.json` and with the [mlc-package-config.json](./mlc-package-config.json) in llama-recipes.
+First edit the file under `android/MLCChat/mlc-package-config.json` and with the [mlc-package-config.json](./mlc-package-config.json) in llama-cookbook.
 
 
 To understand what these JSON fields mean you can refer to this [documentation](https://llm.mlc.ai/docs/deploy/android.html#step-2-build-runtime-and-model-libraries).
 To understand what these JSON fields mean you can refer to this [documentation](https://llm.mlc.ai/docs/deploy/android.html#step-2-build-runtime-and-model-libraries).
 
 

+ 1 - 1
pyproject.toml

@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
 
 
 [project]
 [project]
 name = "llama-cookbook"
 name = "llama-cookbook"
-version = "0.0.5"
+version = "0.0.5.post1"
 authors = [
 authors = [
   { name="Hamid Shojanazeri", email="hamidnazeri@meta.com" },
   { name="Hamid Shojanazeri", email="hamidnazeri@meta.com" },
   { name="Matthias Reso", email="mreso@meta.com" },
   { name="Matthias Reso", email="mreso@meta.com" },

+ 4 - 4
src/llama_cookbook/configs/datasets.py

@@ -14,8 +14,8 @@ class samsum_dataset:
 @dataclass
 @dataclass
 class grammar_dataset:
 class grammar_dataset:
     dataset: str = "grammar_dataset"
     dataset: str = "grammar_dataset"
-    train_split: str = "src/llama_recipes/datasets/grammar_dataset/gtrain_10k.csv"
-    test_split: str = "src/llama_recipes/datasets/grammar_dataset/grammar_validation.csv"
+    train_split: str = "src/llama_cookbook/datasets/grammar_dataset/gtrain_10k.csv"
+    test_split: str = "src/llama_cookbook/datasets/grammar_dataset/grammar_validation.csv"
 
 
 
 
 @dataclass
 @dataclass
@@ -23,7 +23,7 @@ class alpaca_dataset:
     dataset: str = "alpaca_dataset"
     dataset: str = "alpaca_dataset"
     train_split: str = "train"
     train_split: str = "train"
     test_split: str = "val"
     test_split: str = "val"
-    data_path: str = "src/llama_recipes/datasets/alpaca_data.json"
+    data_path: str = "src/llama_cookbook/datasets/alpaca_data.json"
 
 
 @dataclass
 @dataclass
 class custom_dataset:
 class custom_dataset:
@@ -32,7 +32,7 @@ class custom_dataset:
     train_split: str = "train"
     train_split: str = "train"
     test_split: str = "validation"
     test_split: str = "validation"
     data_path: str = ""
     data_path: str = ""
-    
+
 @dataclass
 @dataclass
 class llamaguard_toxicchat_dataset:
 class llamaguard_toxicchat_dataset:
     dataset: str = "llamaguard_toxicchat_dataset"
     dataset: str = "llamaguard_toxicchat_dataset"

+ 2 - 2
src/llama_cookbook/configs/wandb.py

@@ -6,10 +6,10 @@ from dataclasses import dataclass, field
 
 
 @dataclass
 @dataclass
 class wandb_config:
 class wandb_config:
-    project: str = 'llama_recipes' # wandb project name
+    project: str = 'llama_cookbook' # wandb project name
     entity: Optional[str] = None # wandb entity name
     entity: Optional[str] = None # wandb entity name
     job_type: Optional[str] = None
     job_type: Optional[str] = None
     tags: Optional[List[str]] = None
     tags: Optional[List[str]] = None
     group: Optional[str] = None
     group: Optional[str] = None
     notes: Optional[str] = None
     notes: Optional[str] = None
-    mode: Optional[str] = None
+    mode: Optional[str] = None

+ 2 - 2
src/llama_cookbook/data/llama_guard/README.md

@@ -10,9 +10,9 @@ The finetuning_data_formatter script provides classes and methods for formatting
 
 
 ## Running the script
 ## Running the script
 
 
-1. Clone the llama-recipes repo
+1. Clone the llama-cookbook repo
 2. Install the dependencies
 2. Install the dependencies
-3. Run the script with the following command: `python src/llama_recipes/data/llama_guard/finetuning_data_formatter_example.py > sample.json`
+3. Run the script with the following command: `python src/llama_cookbook/data/llama_guard/finetuning_data_formatter_example.py > sample.json`
 
 
 ## Code overview
 ## Code overview
 To use the finetuning_data_formatter, you first need to define your training examples as instances of the TrainingExample class. For example:
 To use the finetuning_data_formatter, you first need to define your training examples as instances of the TrainingExample class. For example:

+ 6 - 6
src/llama_cookbook/finetuning.py

@@ -74,7 +74,7 @@ def setup_wandb(train_config, fsdp_config, **kwargs):
             "You are trying to use wandb which is not currently installed. "
             "You are trying to use wandb which is not currently installed. "
             "Please install it using pip install wandb"
             "Please install it using pip install wandb"
         )
         )
-    from llama_recipes.configs import wandb_config as WANDB_CONFIG
+    from llama_cookbook.configs import wandb_config as WANDB_CONFIG
 
 
     wandb_config = WANDB_CONFIG()
     wandb_config = WANDB_CONFIG()
     update_config(wandb_config, **kwargs)
     update_config(wandb_config, **kwargs)
@@ -196,7 +196,7 @@ def main(**kwargs):
         model.resize_token_embeddings(len(tokenizer))
         model.resize_token_embeddings(len(tokenizer))
 
 
     print_model_size(model, train_config, rank if train_config.enable_fsdp else 0)
     print_model_size(model, train_config, rank if train_config.enable_fsdp else 0)
-    
+
     # Convert the model to bfloat16 if fsdp and pure_bf16 is enabled
     # Convert the model to bfloat16 if fsdp and pure_bf16 is enabled
     if (
     if (
         train_config.enable_fsdp
         train_config.enable_fsdp
@@ -239,12 +239,12 @@ def main(**kwargs):
             freeze_transformer_layers(model, train_config.num_freeze_layers)
             freeze_transformer_layers(model, train_config.num_freeze_layers)
             # print model size and frozen layers after freezing layers
             # print model size and frozen layers after freezing layers
             print_frozen_model_status(model, train_config, rank if train_config.enable_fsdp else 0)
             print_frozen_model_status(model, train_config, rank if train_config.enable_fsdp else 0)
-            
+
         if not train_config.use_peft and train_config.freeze_LLM_only and config.model_type == "mllama":
         if not train_config.use_peft and train_config.freeze_LLM_only and config.model_type == "mllama":
             freeze_LLM_only(model)
             freeze_LLM_only(model)
             # print model size and frozen layers after freezing layers
             # print model size and frozen layers after freezing layers
             print_frozen_model_status(model, train_config, rank if train_config.enable_fsdp else 0)
             print_frozen_model_status(model, train_config, rank if train_config.enable_fsdp else 0)
-        
+
         mixed_precision_policy, wrapping_policy = get_policies(fsdp_config, rank)
         mixed_precision_policy, wrapping_policy = get_policies(fsdp_config, rank)
         # Create the FSDP wrapper for MllamaSelfAttentionDecoderLayer,MllamaCrossAttentionDecoderLayer,MllamaVisionEncoderLayer in vision models
         # Create the FSDP wrapper for MllamaSelfAttentionDecoderLayer,MllamaCrossAttentionDecoderLayer,MllamaVisionEncoderLayer in vision models
         if is_vision:
         if is_vision:
@@ -264,7 +264,7 @@ def main(**kwargs):
             device_id = torch.xpu.current_device()
             device_id = torch.xpu.current_device()
         elif torch.cuda.is_available():
         elif torch.cuda.is_available():
             device_id = torch.cuda.current_device()
             device_id = torch.cuda.current_device()
-        
+
         if train_config.freeze_LLM_only:
         if train_config.freeze_LLM_only:
             use_orig_params = True
             use_orig_params = True
         else:
         else:
@@ -312,7 +312,7 @@ def main(**kwargs):
         dataset_processer = processor
         dataset_processer = processor
     else:
     else:
         dataset_processer = tokenizer
         dataset_processer = tokenizer
-    
+
     # Load and preprocess the dataset for training and validation
     # Load and preprocess the dataset for training and validation
 
 
     dataset_train = get_preprocessed_dataset(
     dataset_train = get_preprocessed_dataset(

+ 16 - 16
src/llama_cookbook/inference/safety_utils.py

@@ -24,7 +24,7 @@ class AuditNLGSensitiveTopics(object):
         except ImportError as e:
         except ImportError as e:
             print("Could not import optional dependency: auditnlg\nPlease install manually with:\n pip install auditnlg\nFollowed by:\npip install -r requirements.txt")
             print("Could not import optional dependency: auditnlg\nPlease install manually with:\n pip install auditnlg\nFollowed by:\npip install -r requirements.txt")
             raise e
             raise e
-            
+
 
 
         data = [{"output": output_text}]
         data = [{"output": output_text}]
 
 
@@ -37,8 +37,8 @@ class AuditNLGSensitiveTopics(object):
             report += "|" + "|".join(f"{n:^10}" for n in [list(k.keys())[0] for k in scores["class_scores"]]) + "|\n"
             report += "|" + "|".join(f"{n:^10}" for n in [list(k.keys())[0] for k in scores["class_scores"]]) + "|\n"
             report += "|" + "|".join(f"{n:^10.5}" for n in [list(k.values())[0] for k in scores["class_scores"]]) + "|\n"
             report += "|" + "|".join(f"{n:^10.5}" for n in [list(k.values())[0] for k in scores["class_scores"]]) + "|\n"
         return "Sensitive Topics", is_safe, report
         return "Sensitive Topics", is_safe, report
-    
-    
+
+
 class SalesforceSafetyChecker(object):
 class SalesforceSafetyChecker(object):
     def __init__(self):
     def __init__(self):
         pass
         pass
@@ -47,13 +47,13 @@ class SalesforceSafetyChecker(object):
         from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, AutoConfig
         from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, AutoConfig
 
 
         config = AutoConfig.from_pretrained("Salesforce/safety-flan-t5-base")
         config = AutoConfig.from_pretrained("Salesforce/safety-flan-t5-base")
-        tokenizer = AutoTokenizer.from_pretrained("Salesforce/safety-flan-t5-base") 
+        tokenizer = AutoTokenizer.from_pretrained("Salesforce/safety-flan-t5-base")
         model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/safety-flan-t5-base", config=config)
         model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/safety-flan-t5-base", config=config)
         model.eval()
         model.eval()
 
 
         prefix = "Is the <Text> field safe or unsafe?"
         prefix = "Is the <Text> field safe or unsafe?"
         input_ids = tokenizer(prefix + " <Text> " + output_text + " <Context> ", return_tensors="pt").input_ids
         input_ids = tokenizer(prefix + " <Text> " + output_text + " <Context> ", return_tensors="pt").input_ids
-        
+
         if len(input_ids[0]) > 512:
         if len(input_ids[0]) > 512:
             warnings.warn(
             warnings.warn(
                 "Input length is > 512 token. Safety check result could be incorrect."
                 "Input length is > 512 token. Safety check result could be incorrect."
@@ -66,9 +66,9 @@ class SalesforceSafetyChecker(object):
                 return_dict_in_generate=True,
                 return_dict_in_generate=True,
                 max_new_tokens=20,
                 max_new_tokens=20,
                 )
                 )
-        
-        is_safe = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True).split(" ")[0] == "safe"    
-            
+
+        is_safe = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True).split(" ")[0] == "safe"
+
         report = ""
         report = ""
         if not is_safe:
         if not is_safe:
             true_false_ids = tokenizer("true false").input_ids[:2]
             true_false_ids = tokenizer("true false").input_ids[:2]
@@ -76,11 +76,11 @@ class SalesforceSafetyChecker(object):
             scores = {}
             scores = {}
             for k, i in zip(keys, range(3,20,2)):
             for k, i in zip(keys, range(3,20,2)):
                 scores[k] = round(outputs.scores[i][0,true_false_ids].softmax(dim=0)[0].item(), 5)
                 scores[k] = round(outputs.scores[i][0,true_false_ids].softmax(dim=0)[0].item(), 5)
-            
+
             report += "|" + "|".join(f"{n:^10}" for n in scores.keys()) + "|\n"
             report += "|" + "|".join(f"{n:^10}" for n in scores.keys()) + "|\n"
             report += "|" + "|".join(f"{n:^10}" for n in scores.values()) + "|\n"
             report += "|" + "|".join(f"{n:^10}" for n in scores.values()) + "|\n"
         return "Salesforce Content Safety Flan T5 Base", is_safe, report
         return "Salesforce Content Safety Flan T5 Base", is_safe, report
-        
+
 
 
     def get_total_length(self, data):
     def get_total_length(self, data):
         prefix = "Is the <Text> field safe or unsafe "
         prefix = "Is the <Text> field safe or unsafe "
@@ -158,7 +158,7 @@ class LlamaGuardSafetyChecker(object):
 
 
     def __init__(self):
     def __init__(self):
         from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
         from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
-        from llama_recipes.inference.prompt_format_utils import build_default_prompt, create_conversation, LlamaGuardVersion
+        from llama_cookbook.inference.prompt_format_utils import build_default_prompt, create_conversation, LlamaGuardVersion
 
 
         model_id = "meta-llama/Llama-Guard-3-8B"
         model_id = "meta-llama/Llama-Guard-3-8B"
 
 
@@ -168,7 +168,7 @@ class LlamaGuardSafetyChecker(object):
         self.model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config, device_map="auto")
         self.model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config, device_map="auto")
 
 
     def __call__(self, output_text, **kwargs):
     def __call__(self, output_text, **kwargs):
-        
+
         agent_type = kwargs.get('agent_type', AgentType.USER)
         agent_type = kwargs.get('agent_type', AgentType.USER)
         user_prompt = kwargs.get('user_prompt', "")
         user_prompt = kwargs.get('user_prompt', "")
 
 
@@ -194,14 +194,14 @@ class LlamaGuardSafetyChecker(object):
         prompt_len = input_ids.shape[-1]
         prompt_len = input_ids.shape[-1]
         output = self.model.generate(input_ids=input_ids, max_new_tokens=100, pad_token_id=0)
         output = self.model.generate(input_ids=input_ids, max_new_tokens=100, pad_token_id=0)
         result = self.tokenizer.decode(output[0][prompt_len:], skip_special_tokens=True)
         result = self.tokenizer.decode(output[0][prompt_len:], skip_special_tokens=True)
-        
+
         splitted_result = result.split("\n")[0];
         splitted_result = result.split("\n")[0];
-        is_safe = splitted_result == "safe"    
+        is_safe = splitted_result == "safe"
 
 
         report = result
         report = result
-        
+
         return "Llama Guard", is_safe, report
         return "Llama Guard", is_safe, report
-        
+
 
 
 # Function to load the PeftModel for performance optimization
 # Function to load the PeftModel for performance optimization
 # Function to determine which safety checker to use based on the options selected
 # Function to determine which safety checker to use based on the options selected

+ 1 - 1
src/llama_cookbook/tools/README.md

@@ -7,7 +7,7 @@ This is the reverse conversion for `convert_llama_weights_to_hf.py` script from
 - Copy file params.json from the official llama download into that directory.
 - Copy file params.json from the official llama download into that directory.
 - Run the conversion script. `model-path` can be a Hugging Face hub model or a local hf model directory.
 - Run the conversion script. `model-path` can be a Hugging Face hub model or a local hf model directory.
 ```
 ```
-python -m llama_recipes.tools.convert_hf_weights_to_llama --model-path meta-llama/Meta-Llama-3.1-70B-Instruct --output-dir test70B --model-size 70B
+python -m llama_cookbook.tools.convert_hf_weights_to_llama --model-path meta-llama/Meta-Llama-3.1-70B-Instruct --output-dir test70B --model-size 70B
 ```
 ```
 
 
 ## Step 1: Run inference
 ## Step 1: Run inference

+ 2 - 2
src/llama_cookbook/utils/config_utils.py

@@ -49,10 +49,10 @@ def generate_peft_config(train_config, kwargs):
         raise RuntimeError(f"Peft config not found: {train_config.peft_method}")
         raise RuntimeError(f"Peft config not found: {train_config.peft_method}")
 
 
     if train_config.peft_method == "prefix":
     if train_config.peft_method == "prefix":
-        raise RuntimeError("PrefixTuning is currently not supported (see https://github.com/meta-llama/llama-recipes/issues/359#issuecomment-2089350811)")
+        raise RuntimeError("PrefixTuning is currently not supported (see https://github.com/meta-llama/llama-cookbook/issues/359#issuecomment-2089350811)")
 
 
     if train_config.enable_fsdp and train_config.peft_method == "llama_adapter":
     if train_config.enable_fsdp and train_config.peft_method == "llama_adapter":
-        raise RuntimeError("Llama_adapter is currently not supported in combination with FSDP (see https://github.com/meta-llama/llama-recipes/issues/359#issuecomment-2089274425)")
+        raise RuntimeError("Llama_adapter is currently not supported in combination with FSDP (see https://github.com/meta-llama/llama-cookbook/issues/359#issuecomment-2089274425)")
 
 
     config = configs[names.index(train_config.peft_method)]()
     config = configs[names.index(train_config.peft_method)]()