hermes42 commited on
Commit
6b370d8
·
verified ·
1 Parent(s): 90c3356

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +154 -0
README.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: text-generation
4
+ tags:
5
+ - nlp
6
+ - code
7
+ - gguf
8
+ - imatrix
9
+
10
+ ---
11
+ GGUF quants of https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3 with importance matrix calculations run on
12
+ group_10_merged.txt for improved perplexity.
13
+
14
+ Quantified with llama.cpp as of commitid 03d8900ebe062355e26a562379daee5f17ea099f from 2024-05-22
15
+
16
+ Original Model Card below:
17
+
18
+ # Model Card for Mistral-7B-Instruct-v0.3
19
+
20
+ The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.
21
+
22
+ Mistral-7B-v0.3 has the following changes compared to [Mistral-7B-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2/edit/main/README.md)
23
+ - Extended vocabulary to 32768
24
+ - Supports v3 Tokenizer
25
+ - Supports function calling
26
+
27
+ ## Installation
28
+
29
+ It is recommended to use `mistralai/Mistral-7B-Instruct-v0.3` with [mistral-inference](https://github.com/mistralai/mistral-inference). For HF transformers code snippets, please keep scrolling.
30
+
31
+ ```
32
+ pip install mistral_inference
33
+ ```
34
+
35
+ ## Download
36
+
37
+ ```py
38
+ from huggingface_hub import snapshot_download
39
+ from pathlib import Path
40
+
41
+ mistral_models_path = Path.home().joinpath('mistral_models', '7B-Instruct-v0.3')
42
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
43
+
44
+ snapshot_download(repo_id="mistralai/Mistral-7B-Instruct-v0.3", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
45
+ ```
46
+
47
+ ### Chat
48
+
49
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
50
+
51
+ ```
52
+ mistral-chat $HOME/mistral_models/7B-Instruct-v0.3 --instruct --max_tokens 256
53
+ ```
54
+
55
+ ### Instruct following
56
+
57
+ ```py
58
+ from mistral_inference.model import Transformer
59
+ from mistral_inference.generate import generate
60
+
61
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
62
+ from mistral_common.protocol.instruct.messages import UserMessage
63
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
64
+
65
+
66
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
67
+ model = Transformer.from_folder(mistral_models_path)
68
+
69
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="Explain Machine Learning to me in a nutshell.")])
70
+
71
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
72
+
73
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
74
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
75
+
76
+ print(result)
77
+ ```
78
+
79
+ ### Function calling
80
+
81
+ ```py
82
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
83
+ from mistral_inference.model import Transformer
84
+ from mistral_inference.generate import generate
85
+
86
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
87
+ from mistral_common.protocol.instruct.messages import UserMessage
88
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
89
+
90
+
91
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
92
+ model = Transformer.from_folder(mistral_models_path)
93
+
94
+ completion_request = ChatCompletionRequest(
95
+ tools=[
96
+ Tool(
97
+ function=Function(
98
+ name="get_current_weather",
99
+ description="Get the current weather",
100
+ parameters={
101
+ "type": "object",
102
+ "properties": {
103
+ "location": {
104
+ "type": "string",
105
+ "description": "The city and state, e.g. San Francisco, CA",
106
+ },
107
+ "format": {
108
+ "type": "string",
109
+ "enum": ["celsius", "fahrenheit"],
110
+ "description": "The temperature unit to use. Infer this from the users location.",
111
+ },
112
+ },
113
+ "required": ["location", "format"],
114
+ },
115
+ )
116
+ )
117
+ ],
118
+ messages=[
119
+ UserMessage(content="What's the weather like today in Paris?"),
120
+ ],
121
+ )
122
+
123
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
124
+
125
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
126
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
127
+
128
+ print(result)
129
+ ```
130
+
131
+ ## Generate with `transformers`
132
+
133
+ If you want to use Hugging Face `transformers` to generate text, you can do something like this.
134
+
135
+ ```py
136
+ from transformers import pipeline
137
+
138
+ messages = [
139
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
140
+ {"role": "user", "content": "Who are you?"},
141
+ ]
142
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
143
+ chatbot(messages)
144
+ ```
145
+
146
+ ## Limitations
147
+
148
+ The Mistral 7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
149
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
150
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
151
+
152
+ ## The Mistral AI Team
153
+
154
+ Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Bam4d, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Jean-Malo Delignon, Jia Li, Justus Murke, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Nicolas Schuhl, Patrick von Platen, Pierre Stock, Sandeep Subramanian, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibaut Lavril, Timothée Lacroix, Théophile Gervet, Thomas Wang, Valera Nemychnikova, William El Sayed, William Marshall