dnhkng commited on
Commit
02dd8cb
1 Parent(s): d37eaf9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -3
README.md CHANGED
@@ -1,3 +1,48 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ This is a new kind of model optimization.
6
+
7
+ A paper is currently being written on the technique.
8
+
9
+ ## Quickstart
10
+
11
+ This code snippets show how to get quickly started with running the model on a GPU:
12
+
13
+ ```python
14
+ import torch
15
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
16
+
17
+ torch.random.manual_seed(0)
18
+ model_id = "microsoft/Phi-3-medium-4k-instruct"
19
+ model = AutoModelForCausalLM.from_pretrained(
20
+ model_id,
21
+ device_map="cuda",
22
+ torch_dtype="auto",
23
+ trust_remote_code=True,
24
+ )
25
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
26
+
27
+ messages = [
28
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
29
+ {"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
30
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
31
+ ]
32
+
33
+ pipe = pipeline(
34
+ "text-generation",
35
+ model=model,
36
+ tokenizer=tokenizer,
37
+ )
38
+
39
+ generation_args = {
40
+ "max_new_tokens": 500,
41
+ "return_full_text": False,
42
+ "temperature": 0.0,
43
+ "do_sample": False,
44
+ }
45
+
46
+ output = pipe(messages, **generation_args)
47
+ print(output[0]['generated_text'])
48
+ ```