bullerwins commited on
Commit
d465599
1 Parent(s): 5834d5c

Update README.md

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