yabichiu commited on
Commit
47555d1
1 Parent(s): f246b9a

Update README.md

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