patrickvonplaten commited on
Commit
abbb488
·
verified ·
1 Parent(s): fe4eac9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +116 -3
README.md CHANGED
@@ -1,3 +1,116 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ # Model Card for Mistral-7B-Instruct-v0.3
6
+
7
+ The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.
8
+
9
+ 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)
10
+ - Extended vocabulary to 32768
11
+ - Supports v3 Tokenizer
12
+ - Supports function calling
13
+
14
+ ## Installation
15
+
16
+ It is recommended to use `mistralai/Mistral-7B-Instruct-v0.3` with [mistral-inference](https://github.com/mistralai/mistral-inference)
17
+
18
+ ```
19
+ pip install mistral_inference
20
+ ```
21
+
22
+ ## Download
23
+
24
+ ```py
25
+ from huggingface_hub import snapshot_download
26
+ from pathlib import Path
27
+
28
+ mistral_models_path = Path.home().joinpath('mistral_models', '7B-Instruct-v0.3')
29
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
30
+
31
+ snapshot_download(repo_id="mistralai/Mistral-7B-Instruct-v0.3", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], cache_dir=mistral_models_path)
32
+ ```
33
+
34
+ ### Instruct following
35
+
36
+ ```py
37
+ from mistral_inference.model import Transformer
38
+ from mistral_inference.generate import generate
39
+
40
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
41
+ from mistral_common.protocol.instruct.messages import UserMessage
42
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
43
+
44
+
45
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
46
+ model = Transformer.from_folder(mistral_models_path)
47
+
48
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="Explain Machine Learning to me in a nutshell.")])
49
+
50
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
51
+
52
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
53
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
54
+
55
+ print(result)
56
+ ```
57
+
58
+ ### Function calling
59
+
60
+ ```py
61
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
62
+ from mistral_inference.model import Transformer
63
+ from mistral_inference.generate import generate
64
+
65
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
66
+ from mistral_common.protocol.instruct.messages import UserMessage
67
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
68
+
69
+
70
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
71
+ model = Transformer.from_folder(mistral_models_path)
72
+
73
+ completion_request = ChatCompletionRequest(
74
+ tools=[
75
+ Tool(
76
+ function=Function(
77
+ name="get_current_weather",
78
+ description="Get the current weather",
79
+ parameters={
80
+ "type": "object",
81
+ "properties": {
82
+ "location": {
83
+ "type": "string",
84
+ "description": "The city and state, e.g. San Francisco, CA",
85
+ },
86
+ "format": {
87
+ "type": "string",
88
+ "enum": ["celsius", "fahrenheit"],
89
+ "description": "The temperature unit to use. Infer this from the users location.",
90
+ },
91
+ },
92
+ "required": ["location", "format"],
93
+ },
94
+ )
95
+ )
96
+ ],
97
+ messages=[
98
+ UserMessage(content="What's the weather like today in Paris?"),
99
+ ],
100
+ )
101
+
102
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
103
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
104
+
105
+ print(result)
106
+ ```
107
+
108
+ ## Limitations
109
+
110
+ The Mistral 7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
111
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
112
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
113
+
114
+ ## The Mistral AI Team
115
+
116
+ 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