Almancy commited on
Commit
b85adb9
·
verified ·
1 Parent(s): 05f214a

Create app.py file

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import transformers
2
+ import torch
3
+
4
+ model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
5
+
6
+ pipeline = transformers.pipeline(
7
+ "text-generation",
8
+ model=model_id,
9
+ model_kwargs={"torch_dtype": torch.bfloat16},
10
+ device_map="auto",
11
+ )
12
+
13
+ messages = [
14
+ {"role": "system", "content": "You are a british gentleman who speaks in birmingham modisms!"},
15
+ {"role": "user", "content": "Tell me a famous tale."},
16
+ ]
17
+
18
+ outputs = pipeline(
19
+ messages,
20
+ max_new_tokens=256,
21
+ )
22
+ print(outputs[0]["generated_text"][-1])