TechxGenus commited on
Commit
b0f6921
·
verified ·
1 Parent(s): 6ef39c0

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ license: other
4
+ license_name: mnpl
5
+ license_link: https://mistral.ai/licences/MNPL-0.1.md
6
+ tags:
7
+ - code
8
+ language:
9
+ - code
10
+ ---
11
+
12
+ FP8 version of Codestral-22B-v0.1 model.
13
+ Made using [AutoFP8](https://github.com/neuralmagic/AutoFP8).
14
+
15
+ ---
16
+
17
+ # Model Card for Codestral-22B-v0.1
18
+
19
+ 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:
20
+ - As instruct, for instance to answer any questions about a code snippet (write documentation, explain, factorize) or to generate code following specific indications
21
+ - 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)
22
+
23
+
24
+ ## Installation
25
+
26
+ It is recommended to use `mistralai/Codestral-22B-v0.1` with [mistral-inference](https://github.com/mistralai/mistral-inference).
27
+
28
+ ```
29
+ pip install mistral_inference
30
+ ```
31
+
32
+ ## Download
33
+
34
+ ```py
35
+ from huggingface_hub import snapshot_download
36
+ from pathlib import Path
37
+
38
+ mistral_models_path = Path.home().joinpath('mistral_models', 'Codestral-22B-v0.1')
39
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
40
+
41
+ snapshot_download(repo_id="mistralai/Codestral-22B-v0.1", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
42
+ ```
43
+
44
+ ### Chat
45
+
46
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment.
47
+
48
+ ```
49
+ mistral-chat $HOME/mistral_models/Codestral-22B-v0.1 --instruct --max_tokens 256
50
+ ```
51
+
52
+ Will generate an answer to "Write me a function that computes fibonacci in Rust" and should give something along the following lines:
53
+
54
+ ```
55
+ 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.
56
+
57
+ fn fibonacci(n: u32) -> u32 {
58
+ match n {
59
+ 0 => 0,
60
+ 1 => 1,
61
+ _ => fibonacci(n - 1) + fibonacci(n - 2),
62
+ }
63
+ }
64
+
65
+ fn main() {
66
+ let n = 10;
67
+ println!("The {}th Fibonacci number is: {}", n, fibonacci(n));
68
+ }
69
+
70
+ 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.
71
+ ```
72
+
73
+
74
+ ### Fill-in-the-middle (FIM)
75
+
76
+ After installing `mistral_inference` and running `pip install --upgrade mistral_common` to make sure to have mistral_common>=1.2 installed:
77
+
78
+ ```py
79
+ from mistral_inference.model import Transformer
80
+ from mistral_inference.generate import generate
81
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
82
+ from mistral_common.tokens.instruct.request import FIMRequest
83
+
84
+ tokenizer = MistralTokenizer.v3()
85
+ model = Transformer.from_folder("~/codestral-22B-240529")
86
+
87
+ prefix = """def add("""
88
+ suffix = """ return sum"""
89
+
90
+ request = FIMRequest(prompt=prefix, suffix=suffix)
91
+
92
+ tokens = tokenizer.encode_fim(request).tokens
93
+
94
+ out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
95
+ result = tokenizer.decode(out_tokens[0])
96
+
97
+ middle = result.split(suffix)[0].strip()
98
+ print(middle)
99
+ ```
100
+
101
+ Should give something along the following lines:
102
+
103
+ ```
104
+ num1, num2):
105
+
106
+ # Add two numbers
107
+ sum = num1 + num2
108
+
109
+ # return the sum
110
+ ```
111
+
112
+ ## Limitations
113
+
114
+ The Codestral-22B-v0.1 does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
115
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
116
+
117
+ ## License
118
+
119
+ Codestral-22B-v0.1 is released under the `MNLP-0.1` license.
120
+
121
+ ## The Mistral AI Team
122
+
123
+ 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,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "mistralai/Codestral-22B-v0.1",
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
+ "activation_scheme": "static",
20
+ "ignored_layers": [
21
+ "lm_head"
22
+ ],
23
+ "quant_method": "fp8"
24
+ },
25
+ "rms_norm_eps": 1e-05,
26
+ "rope_theta": 1000000.0,
27
+ "sliding_window": null,
28
+ "tie_word_embeddings": false,
29
+ "torch_dtype": "bfloat16",
30
+ "transformers_version": "4.41.2",
31
+ "use_cache": true,
32
+ "vocab_size": 32768
33
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.41.2"
6
+ }
model-00001-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ec506eda26315726d366c19744f063f2fe2c03db1345b084f19fe443fe5195e
3
+ size 4983132720
model-00002-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:faafc36b9845595a94527491f28ad363394019773c758b6d3332e2191e8e8ae1
3
+ size 4970601624
model-00003-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9c352fa3b6aed40d5eef8ed4bc8149d845a10b159ae92ec7765c94ecdd65086
3
+ size 4970601624
model-00004-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57e231ba6ecb0dfc903aa34a2d024fa5df771edeaa5659d471bf063825cb7b4b
3
+ size 4983183544
model-00005-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a86fe4a093675c274fc1045c0a83100ef8100a8f5682a143e3f516cf14e31eb0
3
+ size 2743249672
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
+ }