duyntnet commited on
Commit
8de040c
1 Parent(s): d13e8e5

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +102 -0
README.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ inference: false
7
+ tags:
8
+ - transformers
9
+ - gguf
10
+ - imatrix
11
+ - Phi-3-medium-4k-instruct
12
+ ---
13
+ Quantizations of https://huggingface.co/microsoft/Phi-3-medium-4k-instruct
14
+
15
+ **Note**: All quants are created after this [commit](https://github.com/ggerganov/llama.cpp/commit/201cc11afa0a1950e1f632390b2ac6c937a0d8f0) so they should work correctly.
16
+
17
+
18
+ # From original readme
19
+
20
+ ## How to Use
21
+
22
+ Phi-3-Medium-4K-Instruct has been integrated in the development version (4.40.2) of `transformers`. Until the official version is released through `pip`, ensure that you are doing one of the following:
23
+ * When loading the model, ensure that `trust_remote_code=True` is passed as an argument of the `from_pretrained()` function.
24
+
25
+ * Update your local `transformers` to the development version: `pip uninstall -y transformers && pip install git+https://github.com/huggingface/transformers`. The previous command is an alternative to cloning and installing from the source.
26
+
27
+ The current `transformers` version can be verified with: `pip list | grep transformers`.
28
+
29
+ Phi-3-Medium-4K-Instruct is also available in [Azure AI Studio](https://aka.ms/phi3-azure-ai).
30
+
31
+ ### Tokenizer
32
+
33
+ Phi-3-Medium-4K-Instruct supports a vocabulary size of up to `32064` tokens. The [tokenizer files](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct/blob/main/added_tokens.json) already provide placeholder tokens that can be used for downstream fine-tuning, but they can also be extended up to the model's vocabulary size.
34
+
35
+ ### Chat Format
36
+
37
+ Given the nature of the training data, the Phi-3-Medium-4K-Instruct model is best suited for prompts using the chat format as follows.
38
+ You can provide the prompt as a question with a generic template as follow:
39
+ ```markdown
40
+ <|user|>\nQuestion <|end|>\n<|assistant|>
41
+ ```
42
+ For example:
43
+ ```markdown
44
+ <|user|>
45
+ How to explain Internet for a medieval knight?<|end|>
46
+ <|assistant|>
47
+ ```
48
+
49
+ where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
50
+
51
+ ```markdown
52
+ <|user|>
53
+ I am going to Paris, what should I see?<|end|>
54
+ <|assistant|>
55
+ 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|>
56
+ <|user|>
57
+ What is so great about #1?<|end|>
58
+ <|assistant|>
59
+ ```
60
+
61
+ ### Sample inference code
62
+
63
+ This code snippets show how to get quickly started with running the model on a GPU:
64
+
65
+ ```python
66
+ import torch
67
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
68
+
69
+ torch.random.manual_seed(0)
70
+ model_id = "microsoft/Phi-3-medium-4k-instruct"
71
+ model = AutoModelForCausalLM.from_pretrained(
72
+ model_id,
73
+ device_map="cuda",
74
+ torch_dtype="auto",
75
+ trust_remote_code=True,
76
+ )
77
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
78
+
79
+ messages = [
80
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
81
+ {"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."},
82
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
83
+ ]
84
+
85
+ pipe = pipeline(
86
+ "text-generation",
87
+ model=model,
88
+ tokenizer=tokenizer,
89
+ )
90
+
91
+ generation_args = {
92
+ "max_new_tokens": 500,
93
+ "return_full_text": False,
94
+ "temperature": 0.0,
95
+ "do_sample": False,
96
+ }
97
+
98
+ output = pipe(messages, **generation_args)
99
+ print(output[0]['generated_text'])
100
+ ```
101
+
102
+ *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.*