TechxGenus commited on
Commit
98bcbff
1 Parent(s): 9257070

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ AWQ quantized version of Mistral-7B-Instruct-v0.3 model.
6
+
7
+ ---
8
+
9
+ # Model Card for Mistral-7B-Instruct-v0.3
10
+
11
+ The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.
12
+
13
+ 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)
14
+ - Extended vocabulary to 32768
15
+ - Supports v3 Tokenizer
16
+ - Supports function calling
17
+
18
+ ## Installation
19
+
20
+ 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.
21
+
22
+ ```
23
+ pip install mistral_inference
24
+ ```
25
+
26
+ ## Download
27
+
28
+ ```py
29
+ from huggingface_hub import snapshot_download
30
+ from pathlib import Path
31
+
32
+ mistral_models_path = Path.home().joinpath('mistral_models', '7B-Instruct-v0.3')
33
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
34
+
35
+ snapshot_download(repo_id="mistralai/Mistral-7B-Instruct-v0.3", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
36
+ ```
37
+
38
+ ### Chat
39
+
40
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
41
+
42
+ ```
43
+ mistral-chat $HOME/mistral_models/7B-Instruct-v0.3 --instruct --max_tokens 256
44
+ ```
45
+
46
+ ### Instruct following
47
+
48
+ ```py
49
+ from mistral_inference.model import Transformer
50
+ from mistral_inference.generate import generate
51
+
52
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
53
+ from mistral_common.protocol.instruct.messages import UserMessage
54
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
55
+
56
+
57
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
58
+ model = Transformer.from_folder(mistral_models_path)
59
+
60
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="Explain Machine Learning to me in a nutshell.")])
61
+
62
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
63
+
64
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
65
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
66
+
67
+ print(result)
68
+ ```
69
+
70
+ ### Function calling
71
+
72
+ ```py
73
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
74
+ from mistral_inference.model import Transformer
75
+ from mistral_inference.generate import generate
76
+
77
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
78
+ from mistral_common.protocol.instruct.messages import UserMessage
79
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
80
+
81
+
82
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
83
+ model = Transformer.from_folder(mistral_models_path)
84
+
85
+ completion_request = ChatCompletionRequest(
86
+ tools=[
87
+ Tool(
88
+ function=Function(
89
+ name="get_current_weather",
90
+ description="Get the current weather",
91
+ parameters={
92
+ "type": "object",
93
+ "properties": {
94
+ "location": {
95
+ "type": "string",
96
+ "description": "The city and state, e.g. San Francisco, CA",
97
+ },
98
+ "format": {
99
+ "type": "string",
100
+ "enum": ["celsius", "fahrenheit"],
101
+ "description": "The temperature unit to use. Infer this from the users location.",
102
+ },
103
+ },
104
+ "required": ["location", "format"],
105
+ },
106
+ )
107
+ )
108
+ ],
109
+ messages=[
110
+ UserMessage(content="What's the weather like today in Paris?"),
111
+ ],
112
+ )
113
+
114
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
115
+
116
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
117
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
118
+
119
+ print(result)
120
+ ```
121
+
122
+ ## Generate with `transformers`
123
+
124
+ If you want to use Hugging Face `transformers` to generate text, you can do something like this.
125
+
126
+ ```py
127
+ from transformers import pipeline
128
+
129
+ messages = [
130
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
131
+ {"role": "user", "content": "Who are you?"},
132
+ ]
133
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
134
+ chatbot(messages)
135
+ ```
136
+
137
+ ## Limitations
138
+
139
+ The Mistral 7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
140
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
141
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
142
+
143
+ ## The Mistral AI Team
144
+
145
+ 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
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "mistralai/Mistral-7B-Instruct-v0.3",
3
+ "architectures": [
4
+ "MistralForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 4096,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 14336,
13
+ "max_position_embeddings": 32768,
14
+ "model_type": "mistral",
15
+ "num_attention_heads": 32,
16
+ "num_hidden_layers": 32,
17
+ "num_key_value_heads": 8,
18
+ "quantization_config": {
19
+ "bits": 4,
20
+ "group_size": 128,
21
+ "modules_to_not_convert": null,
22
+ "quant_method": "awq",
23
+ "version": "gemm",
24
+ "zero_point": true
25
+ },
26
+ "rms_norm_eps": 1e-05,
27
+ "rope_theta": 1000000.0,
28
+ "sliding_window": null,
29
+ "tie_word_embeddings": false,
30
+ "torch_dtype": "float16",
31
+ "transformers_version": "4.40.0",
32
+ "use_cache": true,
33
+ "vocab_size": 32768
34
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "do_sample": true,
5
+ "eos_token_id": 2,
6
+ "transformers_version": "4.40.0"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9f0acaca9f5f26e779b8db72754b97be963851c94946d4c1d5d145df7033ddd
3
+ size 4163463144
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37f00374dea48658ee8f5d0f21895b9bc55cb0103939607c8185bfd1c6ca1f89
3
+ size 587404
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff