root commited on
Commit
f572b18
·
1 Parent(s): 0a19e86

Initial version

Browse files
README.md CHANGED
@@ -2,4 +2,120 @@
2
  license: other
3
  license_name: mnpl
4
  license_link: https://mistral.ai/licences/MNPL-0.1.md
 
 
 
 
5
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: other
3
  license_name: mnpl
4
  license_link: https://mistral.ai/licences/MNPL-0.1.md
5
+ tags:
6
+ - code
7
+ language:
8
+ - code
9
  ---
10
+
11
+ **This is a quantized version of HF's [StarChat2 15B v0.1](imistral-community/Codestral-22B-v0.1) (see below).**
12
+
13
+ **Quantization done with [AutoAWQ](https://github.com/casper-hansen/AutoAWQ/).**
14
+
15
+ # Model Card for Codestral-22B-v0.1
16
+
17
+ Codestrall-22B-v0.1 is trained on a diverse dataset of 80+ programming languages, including the most popular ones, such as Python, Java, C, C++, JavaScript, and Bash (more details in the [Blogpost](https://mistral.ai/news/codestral/)). The model can be queried:
18
+ - As instruct, for instance to answer any questions about a code snippet (write documentation, explain, factorize) or to generate code following specific indications
19
+ - As Fill in the Middle (FIM), to predict the middle tokens between a prefix and a suffix (very useful for software development add-ons like in VS Code)
20
+
21
+
22
+ ## Installation
23
+
24
+ It is recommended to use `mistralai/Codestral-22B-v0.1` with [mistral-inference](https://github.com/mistralai/mistral-inference).
25
+
26
+ ```
27
+ pip install mistral_inference
28
+ ```
29
+
30
+ ## Download
31
+
32
+ ```py
33
+ from huggingface_hub import snapshot_download
34
+ from pathlib import Path
35
+
36
+ mistral_models_path = Path.home().joinpath('mistral_models', 'Codestral-22B-v0.1')
37
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
38
+
39
+ snapshot_download(repo_id="mistralai/Codestral-22B-v0.1", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
40
+ ```
41
+
42
+ ### Chat
43
+
44
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment.
45
+
46
+ ```
47
+ mistral-chat $HOME/mistral_models/Codestral-22B-v0.1 --instruct --max_tokens 256
48
+ ```
49
+
50
+ Will generate an answer to "Write me a function that computes fibonacci in Rust" and should give something along the following lines:
51
+
52
+ ```
53
+ Sure, here's a simple implementation of a function that computes the Fibonacci sequence in Rust. This function takes an integer `n` as an argument and returns the `n`th Fibonacci number.
54
+
55
+ fn fibonacci(n: u32) -> u32 {
56
+ match n {
57
+ 0 => 0,
58
+ 1 => 1,
59
+ _ => fibonacci(n - 1) + fibonacci(n - 2),
60
+ }
61
+ }
62
+
63
+ fn main() {
64
+ let n = 10;
65
+ println!("The {}th Fibonacci number is: {}", n, fibonacci(n));
66
+ }
67
+
68
+ This function uses recursion to calculate the Fibonacci number. However, it's not the most efficient solution because it performs a lot of redundant calculations. A more efficient solution would use a loop to iteratively calculate the Fibonacci numbers.
69
+ ```
70
+
71
+
72
+ ### Fill-in-the-middle (FIM)
73
+
74
+ After installing `mistral_inference` and running `pip install --upgrade mistral_common` to make sure to have mistral_common>=1.2 installed:
75
+
76
+ ```py
77
+ from mistral_inference.model import Transformer
78
+ from mistral_inference.generate import generate
79
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
80
+ from mistral_common.tokens.instruct.request import FIMRequest
81
+
82
+ tokenizer = MistralTokenizer.v3()
83
+ model = Transformer.from_folder("~/codestral-22B-240529")
84
+
85
+ prefix = """def add("""
86
+ suffix = """ return sum"""
87
+
88
+ request = FIMRequest(prompt=prefix, suffix=suffix)
89
+
90
+ tokens = tokenizer.encode_fim(request).tokens
91
+
92
+ out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
93
+ result = tokenizer.decode(out_tokens[0])
94
+
95
+ middle = result.split(suffix)[0].strip()
96
+ print(middle)
97
+ ```
98
+
99
+ Should give something along the following lines:
100
+
101
+ ```
102
+ num1, num2):
103
+
104
+ # Add two numbers
105
+ sum = num1 + num2
106
+
107
+ # return the sum
108
+ ```
109
+
110
+ ## Limitations
111
+
112
+ The Codestral-22B-v0.1 does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
113
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
114
+
115
+ ## License
116
+
117
+ Codestral-22B-v0.1 is released under the `MNLP-0.1` license.
118
+
119
+ ## The Mistral AI Team
120
+
121
+ 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, Henri Roussez, Jean-Malo Delignon, Jia Li, Justus Murke, Kartik Khandelwal, Lawrence Stewart, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Marjorie Janiewicz, Mickael Seznec, Nicolas Schuhl, Patrick von Platen, Romain Sauvestre, Pierre Stock, Sandeep Subramanian, Saurabh Garg, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibaut Lavril, Thibault Schueller, Timothée Lacroix, Théophile Gervet, Thomas Wang, Valera Nemychnikova, Wendy Shang, William El Sayed, William Marshall
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/data/hf/models/models--mistral-community--Codestral-22B-v0.1/snapshots/09385cada1173191992e11130e5d959d7498328e",
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": 6144,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 16384,
13
+ "max_position_embeddings": 32768,
14
+ "model_type": "mistral",
15
+ "num_attention_heads": 48,
16
+ "num_hidden_layers": 56,
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.41.1",
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.41.1"
7
+ }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4eb6fa33e64787ac5620f627f205df9ed5b881dc11a71bd8bc4d17ca56822127
3
+ size 9974417192
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba26de19f62bc41619db11397d79ca89ce03bbca97745d2b6db986ad37422c87
3
+ size 2181031768
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
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
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": true,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "bos_token": "<s>",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": true,
35
+ "model_max_length": 1000000000000000019884624838656,
36
+ "pad_token": null,
37
+ "sp_model_kwargs": {},
38
+ "spaces_between_special_tokens": false,
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false
42
+ }