qwp4w3hyb commited on
Commit
2227c47
1 Parent(s): 6fe3c12

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +142 -0
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: mnpl
4
+ license_link: https://mistral.ai/licences/MNPL-0.1.md
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ base_model: mistralai/Codestral-22B-v0.1
8
+ tags:
9
+ - code
10
+ - codestral
11
+ - mistralai
12
+ - mistral
13
+ - gguf
14
+ - imatrix
15
+ - importance matrix
16
+ language:
17
+ - code
18
+ model-index:
19
+ - name: Codestral-22B-v0.1-hf-iMat-GGUF-iMat-GGUF
20
+ results: []
21
+ ---
22
+
23
+ # Quant Infos
24
+
25
+ - quants done with an importance matrix for improved quantization loss
26
+ - ggufs & imatrix generated from bf16 for "optimal" accuracy loss
27
+ - Wide coverage of different gguf quant types from Q\_8\_0 down to IQ1\_S
28
+ - Quantized with [llama.cpp](https://github.com/ggerganov/llama.cpp) commit [477973d2e190815d4e13545370504776433789cf](https://github.com/ggerganov/llama.cpp/commit/477973d2e190815d4e13545370504776433789cf) (master as of 2024-05-22)
29
+ - Imatrix generated with [this](https://gist.github.com/bartowski1182/eb213dccb3571f863da82e99418f81e8) multi-purpose dataset by [bartowski](https://huggingface.co/bartowski).
30
+ ```
31
+ ./imatrix -c 512 -m $model_name-bf16.gguf -f calibration_datav3.txt -o $model_name.imatrix
32
+ ```
33
+
34
+ # Original Model Card:
35
+
36
+ ## Model Card for Codestral-22B-v0.1
37
+
38
+ 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:
39
+ - As instruct, for instance to answer any questions about a code snippet (write documentation, explain, factorize) or to generate code following specific indications
40
+ - 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)
41
+
42
+
43
+ ## Installation
44
+
45
+ It is recommended to use `mistralai/Codestral-22B-v0.1` with [mistral-inference](https://github.com/mistralai/mistral-inference).
46
+
47
+ ```
48
+ pip install mistral_inference
49
+ ```
50
+
51
+ ## Download
52
+
53
+ ```py
54
+ from huggingface_hub import snapshot_download
55
+ from pathlib import Path
56
+
57
+ mistral_models_path = Path.home().joinpath('mistral_models', 'Codestral-22B-v0.1')
58
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
59
+
60
+ snapshot_download(repo_id="mistralai/Codestral-22B-v0.1", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
61
+ ```
62
+
63
+ ### Chat
64
+
65
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment.
66
+
67
+ ```
68
+ mistral-chat $HOME/mistral_models/Codestral-22B-v0.1 --instruct --max_tokens 256
69
+ ```
70
+
71
+ Will generate an answer to "Write me a function that computes fibonacci in Rust" and should give something along the following lines:
72
+
73
+ ```
74
+ 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.
75
+
76
+ fn fibonacci(n: u32) -> u32 {
77
+ match n {
78
+ 0 => 0,
79
+ 1 => 1,
80
+ _ => fibonacci(n - 1) + fibonacci(n - 2),
81
+ }
82
+ }
83
+
84
+ fn main() {
85
+ let n = 10;
86
+ println!("The {}th Fibonacci number is: {}", n, fibonacci(n));
87
+ }
88
+
89
+ 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.
90
+ ```
91
+
92
+
93
+ ### Fill-in-the-middle (FIM)
94
+
95
+ After installing `mistral_inference` and running `pip install --upgrade mistral_common` to make sure to have mistral_common>=1.2 installed:
96
+
97
+ ```py
98
+ from mistral_inference.model import Transformer
99
+ from mistral_inference.generate import generate
100
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
101
+ from mistral_common.tokens.instruct.request import FIMRequest
102
+
103
+ tokenizer = MistralTokenizer.v3()
104
+ model = Transformer.from_folder("~/codestral-22B-240529")
105
+
106
+ prefix = """def add("""
107
+ suffix = """ return sum"""
108
+
109
+ request = FIMRequest(prompt=prefix, suffix=suffix)
110
+
111
+ tokens = tokenizer.encode_fim(request).tokens
112
+
113
+ out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
114
+ result = tokenizer.decode(out_tokens[0])
115
+
116
+ middle = result.split(suffix)[0].strip()
117
+ print(middle)
118
+ ```
119
+
120
+ Should give something along the following lines:
121
+
122
+ ```
123
+ num1, num2):
124
+
125
+ # Add two numbers
126
+ sum = num1 + num2
127
+
128
+ # return the sum
129
+ ```
130
+
131
+ ## Limitations
132
+
133
+ The Codestral-22B-v0.1 does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
134
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
135
+
136
+ ## License
137
+
138
+ Codestral-22B-v0.1 is released under the `MNLP-0.1` license.
139
+
140
+ ## The Mistral AI Team
141
+
142
+ 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