Skip to content

Commit 6a7e83f

Browse files
authored
Update code snippet README (#25)
* update README * remove comment doc
1 parent 51c9b49 commit 6a7e83f

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ from optimum.executorch import ExecuTorchModelForCausalLM
5252
from transformers import AutoTokenizer
5353

5454
# Load the exported model
55-
model = ExecuTorchModelForCausalLM.from_pretrained(
56-
"./meta_llama3_2_1b",
57-
export=False
58-
)
55+
model = ExecuTorchModelForCausalLM.from_pretrained("./meta_llama3_2_1b")
5956

6057
# Initialize tokenizer and generate text
6158
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
@@ -71,15 +68,12 @@ generated_text = model.text_generation(
7168
from optimum.executorch import ExecuTorchModelForCausalLM
7269
from transformers import AutoTokenizer
7370

74-
# Load and export model in one step
75-
model = ExecuTorchModelForCausalLM.from_pretrained(
76-
"meta-llama/Llama-3.2-1B",
77-
export=True,
78-
recipe="xnnpack"
79-
)
71+
# Load and export the model on-the-fly
72+
model_id = "meta-llama/Llama-3.2-1B"
73+
model = ExecuTorchModelForCausalLM.from_pretrained(model_id, recipe="xnnpack")
8074

8175
# Generate text right away
82-
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
76+
tokenizer = AutoTokenizer.from_pretrained(model_id)
8377
generated_text = model.text_generation(
8478
tokenizer=tokenizer,
8579
prompt="Simply put, the theory of relativity states that",

docs/source/quickstart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To load a model and run inference, you can just replace your `AutoModelForCausal
3434
+ from optimum.executorch import ExecuTorchModelForCausalLM
3535
from transformers import AutoTokenizer
3636

37-
model_id = "meta-llama/Llama-3.2-1B" # you can also load the model that was exported with the CLI
37+
model_id = "meta-llama/Llama-3.2-1B"
3838
tokenizer = AutoTokenizer.from_pretrained(model_id)
3939
- model = AutoModelForCausalLM.from_pretrained(model_id)
4040
+ model = ExecuTorchModelForCausalLM.from_pretrained(model_id)

0 commit comments

Comments
 (0)