AlejandraGG commited on
Commit
b3003b1
·
verified ·
1 Parent(s): 35f8a7c

Create app-py

Browse files
Files changed (1) hide show
  1. app-py +20 -0
app-py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import pipeline
3
+
4
+ model_id = "meta-llama/Llama-3.2-1B-Instruct"
5
+ pipe = pipeline(
6
+ "text-generation",
7
+ model=model_id,
8
+ torch_dtype=torch.bfloat16,
9
+ device_map="auto",
10
+ token = os.getenv("HF_TOKEN2")
11
+ )
12
+ messages = [
13
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
14
+ {"role": "user", "content": "Who are you?"},
15
+ ]
16
+ outputs = pipe(
17
+ messages,
18
+ max_new_tokens=256,
19
+ )
20
+ print(outputs[0]["generated_text"][-1])