Flouneumを使用すると、ローカルの事前に訓練されたAIモデルを使用するアプリケーションを簡単に開発できます。このモノレポには2つの主要なプロジェクトがあります。
Kalosmは、Flouneumを裏付ける錆の事前に訓練されたモデルのシンプルなインターフェイスです。事前に訓練された、言語、オーディオ、および画像モデルと簡単に対話できます。
Kalosmはさまざまなモデルをサポートしています。現在サポートされているモデルのリストは次のとおりです。
| モデル | モダリティ | サイズ | 説明 | 量子化 | CUDA +金属加速 | 例 |
|---|---|---|---|---|---|---|
| ラマ | 文章 | 1B-70B | 汎用言語モデル | ✅ | ✅ | llama 3チャット |
| ミストラル | 文章 | 7-13b | 汎用言語モデル | ✅ | ✅ | ミストラルチャット |
| ファイ | 文章 | 2B-4B | 小さな推論に焦点を合わせた言語モデル | ✅ | ✅ | Phi 3チャット |
| ささやきます | オーディオ | 20MB-1GB | オーディオ転写モデル | ✅ | ✅ | ライブウィスパー転写 |
| rwuerstchen | 画像 | 5GB | 画像生成モデル | ✅ | rwuerstchenイメージ生成 | |
| TROCR | 画像 | 3GB | 光学文字認識モデル | ✅ | テキスト認識 | |
| 何でもセグメント | 画像 | 50MB-400MB | 画像セグメンテーションモデル | 画像セグメンテーション | ||
| バート | 文章 | 100MB-1GB | テキスト埋め込みモデル | ✅ | セマンティック検索 |
Kalosmは、事前に訓練されたモデルを中心にさまざまなユーティリティもサポートしています。これらには以下が含まれます:
Kalosmは、Candle Machine Learning Libraryを使用して、純粋な錆でモデルを実行しています。 llama.cppと同等のパフォーマンスを備えた量子化および加速モデルをサポートします。
ミストラル7b
| アクセル | カロスム | llama.cpp |
|---|---|---|
| 金属(M2) | 39 t/s | 27 t/s |
Kalosmは、任意のパーサーで構造化された生成をサポートしています。カスタムパーサーエンジンとサンプラーと構造認識の加速度を使用して、制御されていないテキスト生成よりも構造生成をさらに速くします。任意の錆の種類を撮影し、 #[derive(Parse, Schema)]を追加して、構造化された生成で使用できるようにすることができます。
use kalosm :: language :: * ;
/// A fictional character
# [ derive ( Parse , Schema , Clone , Debug ) ]
struct Character {
/// The name of the character
# [ parse ( pattern = "[A-Z][a-z]{2,10} [A-Z][a-z]{2,10}" ) ]
name : String ,
/// The age of the character
# [ parse ( range = 1 ..= 100 ) ]
age : u8 ,
/// A description of the character
# [ parse ( pattern = "[A-Za-z ]{40,200}" ) ]
description : String ,
}
# [ tokio :: main ]
async fn main ( ) {
// First create a model. Chat models tend to work best with structured generation
let model = Llama :: phi_3 ( ) . await . unwrap ( ) ;
// Then create a task with the parser as constraints
let task = Task :: builder_for :: < [ Character ; 10 ] > ( "You generate realistic JSON placeholders for characters" )
. build ( ) ;
// Finally, run the task
let mut stream = task . run ( "Create a list of random characters" , & model ) ;
stream . to_std_out ( ) . await . unwrap ( ) ;
let character = stream . await . unwrap ( ) ;
println ! ( "{character:?}" ) ;
}正規表現に加えて、構造化されたデータを生成するための独自の文法を提供できます。これにより、JSON、HTML、XMLなどの複雑なデータ構造を含む、必要な構造に対する応答を制約できます。
このQuickStartは、シンプルなチャットボットであなたを立ち上げて実行します。始めましょう!
Kalosmのより完全なガイドはKalosm Webサイトで入手できます。例は、Examplesフォルダーで入手できます。
cargo new kalosm-hello-world
cd ./kalosm-hello-world # You can use `--features language,metal`, `--features language,cuda`, or `--features language,mkl` if your machine supports an accelerator
cargo add kalosm --features language
cargo add tokio --features fullmain.rsファイルに追加します use kalosm :: language :: * ;
# [ tokio :: main ]
async fn main ( ) -> Result < ( ) , Box < dyn std :: error :: Error > > {
let model = Llama :: phi_3 ( ) . await ? ;
let mut chat = Chat :: builder ( model )
. with_system_prompt ( "You are a pirate called Blackbeard" )
. build ( ) ;
loop {
chat . add_message ( prompt_input ( " n > " ) ? )
. to_std_out ( )
. await ? ;
}
}cargo run --releaseどちらのプロジェクトにも興味がある場合は、不一致に参加してプロジェクトについて話し合い、ヘルプを得ることができます。