timpal0l commited on
Commit
0872539
1 Parent(s): 0c25445

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -3
README.md CHANGED
@@ -1,3 +1,39 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ #### Transformers pipeline
6
+
7
+ ```python
8
+ import transformers
9
+ import torch
10
+
11
+ model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
12
+
13
+ pipeline = transformers.pipeline(
14
+ "text-generation",
15
+ model=model_id,
16
+ model_kwargs={"torch_dtype": torch.bfloat16},
17
+ device_map="auto",
18
+ )
19
+
20
+ messages = [
21
+ {"role": "system", "content": "Du är en snäll maskin."},
22
+ {"role": "user", "content": "Vem är du?"},
23
+ ]
24
+
25
+ terminators = [
26
+ pipeline.tokenizer.eos_token_id,
27
+ pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
28
+ ]
29
+
30
+ outputs = pipeline(
31
+ messages,
32
+ max_new_tokens=256,
33
+ eos_token_id=terminators,
34
+ do_sample=True,
35
+ temperature=0.6,
36
+ top_p=0.9,
37
+ )
38
+ print(outputs[0]["generated_text"][-1])
39
+ ```