TroyDoesAI commited on
Commit
09f3fbd
1 Parent(s): 063798e

Update README.md

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