From 56defb99b239b377e2d24fe22d8c102d1d18d311 Mon Sep 17 00:00:00 2001 From: Aman Karmani Date: Thu, 29 Aug 2024 21:14:31 +0000 Subject: [PATCH] README: ensure modeling code is patched before model instantiation --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 58419f1bd..0cf4af3d8 100644 --- a/README.md +++ b/README.md @@ -120,12 +120,10 @@ Using the [patching APIs](#patching), you can swap Hugging Face models with opti import transformers from liger_kernel.transformers import apply_liger_kernel_to_llama -model = transformers.AutoModelForCausalLM("path/to/llama/model") - -# Adding this line automatically monkey-patches the model with the optimized Liger kernels +# 1a. Adding this line automatically monkey-patches the model with the optimized Liger kernels apply_liger_kernel_to_llama() -# You could alternatively specify exactly which kernels are applied +# 1b. You could alternatively specify exactly which kernels are applied apply_liger_kernel_to_llama( rope=True, swiglu=True, @@ -133,6 +131,9 @@ apply_liger_kernel_to_llama( fused_linear_cross_entropy=False, rms_norm=False ) + +# 2. Instantiate patched model +model = transformers.AutoModelForCausalLM("path/to/llama/model") ``` ### 3. Compose Your Own Model