yunmorning commited on
Commit
dc1a22b
1 Parent(s): 348eb52

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +175 -0
README.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: mistralai/Mistral-7B-Instruct-v0.2
4
+ inference: false
5
+ model_link: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2
6
+ model_name: Mistral-7B-Instruct-v0.2
7
+ pipeline_tag: text-generation
8
+ quantized_by: FriendliAI
9
+ tags:
10
+ - pretrained
11
+ ---
12
+
13
+ <!-- header start -->
14
+ <p align="center">
15
+ <img src="https://i.imgur.com/mNM6Cai.png" width="100%" alt="Friendli Logo">
16
+ </p>
17
+ <!-- header end -->
18
+
19
+ # Mistral-7B-Instruct-v0.2 - FP8
20
+
21
+ - Model creator: [Mistral AI](https://huggingface.co/mistralai)
22
+ - Original model: [Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2)
23
+
24
+ ## Description
25
+
26
+ This repo contains the Mistral-7B-Instruct-v0.2 model quantized to FP8 by FriendliAI, significantly enhancing its inference efficiency while maintaining high accuracy.
27
+ Note that FP8 is only supported by NVIDIA Ada, Hopper, and Blackwell GPU architectures.
28
+ Check out [FriendliAI documentation](https://docs.friendli.ai/) for more details.
29
+
30
+ ## License
31
+
32
+ Refer to the license of the original model card.
33
+
34
+ ## Compatibility
35
+
36
+ This model is compatible with **[Friendli Container](https://friendli.ai/products/container/)**.
37
+
38
+ ## Prerequisites
39
+
40
+ - Before you begin, make sure you have signed up for [Friendli Suite](https://suite.friendli.ai/). **You can use Friendli Containers free of charge for four weeks.**
41
+ - Prepare a Personal Access Token following [this guide](#preparing-personal-access-token).
42
+ - Prepare a Friendli Container Secret following [this guide](#preparing-container-secret).
43
+ - Install Hugging Face CLI with `pip install -U "huggingface_hub[cli]"`
44
+
45
+ ### Preparing Personal Access Token
46
+
47
+ PAT (Personal Access Token) is the user credential for for logging into our container registry.
48
+
49
+ 1. Sign in [Friendli Suite](https://suite.friendli.ai/).
50
+ 2. Go to **[User Settings > Tokens](https://suite.friendli.ai/user-settings/tokens)** and click **'Create new token'**.
51
+ 3. Save your created token value.
52
+
53
+ ### Preparing Container Secret
54
+
55
+ Container secret is a credential to launch our Friendli Container images.
56
+ You should pass the container secret as an environment variable to run the container image.
57
+
58
+ 1. Sign in [Friendli Suite](https://suite.friendli.ai/).
59
+ 2. Go to **Container > Container Secrets** and click **'Create secret'**.
60
+ 3. Save your created secret value.
61
+
62
+ ### Pulling Friendli Container Image
63
+
64
+ 1. Log in to the Docker client using the personal access token created as outlined in [this guide](#preparing-personal-access-token).
65
+
66
+ ```sh
67
+ export FRIENDLI_PAT="YOUR PAT"
68
+ docker login registry.friendli.ai -u $YOUR_EMAIL -p $FRIENDLI_PAT
69
+ ```
70
+
71
+ 2. Pull image
72
+
73
+ ```sh
74
+ docker pull registry.friendli.ai/trial
75
+ ```
76
+
77
+ ## Running Friendli Container
78
+
79
+ Once you've prepared the image of Friendli Container, you can launch it to create a serving endpoint.
80
+
81
+ ```sh
82
+ export MODEL_DIR=$PWD/FriendliAI--Mistral-7B-Instruct-v0.2-fp8
83
+ export FRIENDLI_CONTAINER_SECRET="YOUR CONTAINER SECRET"
84
+ export FRIENDLI_CONTAINER_IMAGE="registry.friendli.ai/trial"
85
+ export GPU_ENUMERATION='"device=0"'
86
+
87
+ huggingface-cli download FriendliAI/Mistral-7B-Instruct-v0.2-fp8 \
88
+ --local-dir $MODEL_DIR \
89
+ --local-dir-use-symlinks False
90
+
91
+ docker run \
92
+ --gpus $GPU_ENUMERATION --network=host --ipc=host \
93
+ -v $MODEL_DIR:/model \
94
+ -e FRIENDLI_CONTAINER_SECRET=$FRIENDLI_CONTAINER_SECRET \
95
+ $FRIENDLI_CONTAINER_IMAGE /bin/bash -c \
96
+ "/root/launcher \
97
+ --web-server-port 6000 \
98
+ --ckpt-path /model \
99
+ --ckpt-type hf_safetensors"
100
+ ```
101
+
102
+ ---
103
+
104
+ # Original model card: Mistral AI's Mistral-7B-Instruct-v0.2
105
+
106
+ # Model Card for Mistral-7B-Instruct-v0.2
107
+
108
+ The Mistral-7B-Instruct-v0.2 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.2.
109
+
110
+ Mistral-7B-v0.2 has the following changes compared to Mistral-7B-v0.1
111
+ - 32k context window (vs 8k context in v0.1)
112
+ - Rope-theta = 1e6
113
+ - No Sliding-Window Attention
114
+
115
+ For full details of this model please read our [paper](https://arxiv.org/abs/2310.06825) and [release blog post](https://mistral.ai/news/la-plateforme/).
116
+
117
+ ## Instruction format
118
+
119
+ In order to leverage instruction fine-tuning, your prompt should be surrounded by `[INST]` and `[/INST]` tokens. The very first instruction should begin with a begin of sentence id. The next instructions should not. The assistant generation will be ended by the end-of-sentence token id.
120
+
121
+ E.g.
122
+ ```
123
+ text = "<s>[INST] What is your favourite condiment? [/INST]"
124
+ "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
125
+ "[INST] Do you have mayonnaise recipes? [/INST]"
126
+ ```
127
+
128
+ This format is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating) via the `apply_chat_template()` method:
129
+
130
+ ```python
131
+ from transformers import AutoModelForCausalLM, AutoTokenizer
132
+ device = "cuda" # the device to load the model onto
133
+ model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
134
+ tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
135
+ messages = [
136
+ {"role": "user", "content": "What is your favourite condiment?"},
137
+ {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
138
+ {"role": "user", "content": "Do you have mayonnaise recipes?"}
139
+ ]
140
+ encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
141
+ model_inputs = encodeds.to(device)
142
+ model.to(device)
143
+ generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
144
+ decoded = tokenizer.batch_decode(generated_ids)
145
+ print(decoded[0])
146
+ ```
147
+
148
+ ## Troubleshooting
149
+ - If you see the following error:
150
+ ```
151
+ Traceback (most recent call last):
152
+ File "", line 1, in
153
+ File "/transformers/models/auto/auto_factory.py", line 482, in from_pretrained
154
+ config, kwargs = AutoConfig.from_pretrained(
155
+ File "/transformers/models/auto/configuration_auto.py", line 1022, in from_pretrained
156
+ config_class = CONFIG_MAPPING[config_dict["model_type"]]
157
+ File "/transformers/models/auto/configuration_auto.py", line 723, in getitem
158
+ raise KeyError(key)
159
+ KeyError: 'mistral'
160
+ ```
161
+
162
+ Installing transformers from source should solve the issue
163
+ pip install git+https://github.com/huggingface/transformers
164
+
165
+ This should not be required after transformers-v4.33.4.
166
+
167
+ ## Limitations
168
+
169
+ The Mistral 7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
170
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
171
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
172
+
173
+ ## The Mistral AI Team
174
+
175
+ Albert Jiang, Alexandre Sablayrolles, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Lélio Renard Lavaud, Louis Ternon, Lucile Saulnier, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Théophile Gervet, Thibaut Lavril, Thomas Wang, Timothée Lacroix, William El Sayed.