🚀 Codestral-22B-v0.1-hf-iMat-GGUF-iMat-GGUF
Codestral-22B-v0.1-hf-iMat-GGUF-iMat-GGUFは、多様なプログラミング言語に対応したコード生成モデルです。重要度行列を用いた量子化により、高精度なコード生成が可能です。
🚀 クイックスタート
Codestral-22B-v0.1を使用するには、まずモデルをダウンロードし、必要なライブラリをインストールする必要があります。以下の手順に従って操作してください。
✨ 主な機能
- 80種類以上のプログラミング言語に対応
- 重要度行列を用いた量子化により、高精度なコード生成
- InstructモードとFill in the Middle (FIM)モードのサポート
📦 インストール
mistralai/Codestral-22B-v0.1
を使用するには、mistral-inferenceをインストールすることをおすすめします。
pip install mistral_inference
モデルのダウンロード
from huggingface_hub import snapshot_download
from pathlib import Path
mistral_models_path = Path.home().joinpath('mistral_models', 'Codestral-22B-v0.1')
mistral_models_path.mkdir(parents=True, exist_ok=True)
snapshot_download(repo_id="mistralai/Codestral-22B-v0.1", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
💻 使用例
基本的な使用法
Chatモード
mistral_inference
をインストールした後、mistral-chat
CLIコマンドを使用してモデルを起動できます。
mistral-chat $HOME/mistral_models/Codestral-22B-v0.1 --instruct --max_tokens 256
以下のような質問に対して回答を生成します。
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.
fn fibonacci(n: u32) -> u32 {
match n {
0 => 0,
1 => 1,
_ => fibonacci(n - 1) + fibonacci(n - 2),
}
}
fn main() {
let n = 10;
println!("The {}th Fibonacci number is: {}", n, fibonacci(n));
}
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.
Fill-in-the-middle (FIM)モード
mistral_inference
をインストールし、pip install --upgrade mistral_common
を実行してmistral_common>=1.2
をインストールします。
from mistral_inference.model import Transformer
from mistral_inference.generate import generate
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.tokens.instruct.request import FIMRequest
tokenizer = MistralTokenizer.v3()
model = Transformer.from_folder("~/codestral-22B-240529")
prefix = """def add("""
suffix = """ return sum"""
request = FIMRequest(prompt=prefix, suffix=suffix)
tokens = tokenizer.encode_fim(request).tokens
out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
result = tokenizer.decode(out_tokens[0])
middle = result.split(suffix)[0].strip()
print(middle)
以下のような結果が得られます。
num1, num2):
# Add two numbers
sum = num1 + num2
# return the sum
📚 ドキュメント
量子化情報
元のモデルカード
Codestral-22B-v0.1のモデルカード
Codestrall-22B-v0.1は、Python、Java、C、C++、JavaScript、Bashなどの人気のある80以上のプログラミング言語の多様なデータセットで学習されています (ブログ記事 で詳細を参照)。このモデルは以下のようにクエリを投げることができます。
- インストラクションとして、コードスニペットに関する質問に回答したり (ドキュメントの作成、説明、因数分解など)、特定の指示に従ってコードを生成したりすることができます。
- Fill in the Middle (FIM) として、接頭辞と接尾辞の間の中間トークンを予測することができます (VS Codeなどのソフトウェア開発アドオンに非常に役立ちます)。
制限事項
Codestral-22B-v0.1にはモデレーションメカニズムがありません。モデルがガードレールをきめ細かく尊重し、モデレートされた出力が必要な環境でのデプロイを可能にする方法について、コミュニティと協力したいと考えています。
📄 ライセンス
Codestral-22B-v0.1は MNLP-0.1
ライセンスの下でリリースされています。
ミストラルAIチーム
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