rhysjones commited on
Commit
2666847
1 Parent(s): 6b2ff82

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md CHANGED
@@ -27,5 +27,77 @@ pip install -U transformers
27
 
28
  This version has the support for the new Phi-3 model type.
29
 
 
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
 
27
 
28
  This version has the support for the new Phi-3 model type.
29
 
30
+ ### Chat Format
31
 
32
+ Phi-3-mini-mango uses the same chat format as the original Phi-3 Mini-4K-Instruct model. Note that it does not use a system prompt,
33
+ instead place any specific instructions as part of the first <|user|> prompt.
34
+
35
+ You can provide the prompt as a question with a generic template as follow:
36
+ ```markdown
37
+ <|user|>\nQuestion <|end|>\n<|assistant|>
38
+ ```
39
+ For example:
40
+ ```markdown
41
+ <|user|>
42
+ How to explain Internet for a medieval knight?<|end|>
43
+ <|assistant|>
44
+ ```
45
+
46
+ where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
47
+
48
+ ```markdown
49
+ <|user|>
50
+ I am going to Paris, what should I see?<|end|>
51
+ <|assistant|>
52
+ Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n\n1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n\nThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."<|end|>
53
+ <|user|>
54
+ What is so great about #1?<|end|>
55
+ <|assistant|>
56
+ ```
57
+
58
+ ### Sample inference code
59
+
60
+ This code snippets show how to get quickly started with running the model on a GPU:
61
+
62
+ ```python
63
+ import torch
64
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
65
+
66
+ torch.random.manual_seed(0)
67
+
68
+ model = AutoModelForCausalLM.from_pretrained(
69
+ "microsoft/Phi-3-mini-4k-instruct",
70
+ device_map="cuda",
71
+ torch_dtype="auto",
72
+ trust_remote_code=True,
73
+ )
74
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
75
+
76
+ messages = [
77
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
78
+ {"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."},
79
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
80
+ ]
81
+
82
+ pipe = pipeline(
83
+ "text-generation",
84
+ model=model,
85
+ tokenizer=tokenizer,
86
+ )
87
+
88
+ generation_args = {
89
+ "max_new_tokens": 500,
90
+ "return_full_text": False,
91
+ "temperature": 0.0,
92
+ "do_sample": False,
93
+ }
94
+
95
+ output = pipe(messages, **generation_args)
96
+ print(output[0]['generated_text'])
97
+ ```
98
+
99
+ *Some applications/frameworks might not include a BOS token (`<s>`) at the start of the conversation. Please ensure that it is included since it provides more reliable results.*
100
+
101
+
102
+ The model shares the same limtations as the [https://huggingface.co/microsoft/Phi-3-mini-4k-instruct#responsible-ai-considerations](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct#responsible-ai-considerations)
103