


LIBLLMへようこそ、通常のパーソナルコンピューターやモバイルデバイスでの大規模な言語モデル(LLM)の効率的な推論用に設計されたオープンソースプロジェクトです。コアは、C ++ 14に実装されており、サードパーティの依存関係(BlasやDentePieceなど)があり、さまざまなデバイスでシームレスな操作を可能にします。
平均的なパーソナルコンピューターとモバイルデバイスで大規模な言語モデル(LLM)の効率的な推論用に設計されたオープンソースプロジェクトであるLibllmへようこそ。コアはC ++ 14で記述されており、サードパーティの依存関係がなく(BLA、Oentsepieceなど)、さまざまなデバイスでシームレスに実行できます。
| モデル | ダウンロード | LLMコマンド |
|---|---|---|
| index-1.9b-character(ロールプレイング) | [?hf] [MS] | LLMチャット-Mインデックス:文字 |
| インデックス1.9B-chat | [?hf] [MS] | LLMチャット-Mインデックス |
| QWEN2-1.5B-Instruct | [?hf] [MS] | LLMチャット-M Qwen:1.5b |
| QWEN2-7B-Instruct | [?hf] [MS] | LLMチャット-M Qwen:7b |
| llama3.2-1b-instruct | [?hf] [MS] | LLMチャット-M llama3.2:1b |
| llama3.2-3b-instruct | [?hf] [MS] | LLMチャット-M llama3.2 |
| ささやき声-V3 | [?hf] [MS] | LLM転写-mささやき |
HF = huggingface、 MS = modelscope
| OS | プラットフォーム | cuda | AVX2 | AVX512 | asimdhp |
|---|---|---|---|---|---|
| Linux | x64 | ✅ | ✅ | ✅ | |
| Windows | x64 | ✅ | ✅ | ✅ | |
| macos | ARM64 | ✅ |
llm chat -model index-character Huggingfaceからindex-characterモデルを自動的にダウンロードします。 Bilibili-Index-1.9B-Characterとチャットするには:
$ llm chat -m index-character HuggingfaceまたはModelScope(中国)からBilibili-Index-1.9B-Characterを自動的にダウンロードし、LLMでChat CLIを起動します。
Bilibili-Index-1.9B-Characterモデルとチャット:
$ llm chat -m index-character llm 、HuggingfaceまたはModelScope(中国のIPの場合)からモデルBilibili-Index-1.9B-Character自動的にダウンロードし、話し始めます。
$ src/libllm/llm chat -m index-character
INFO 2024-07-30T12:02:28Z interface.cc:67] ISA support: AVX2=1 F16C=1 AVX512F=1
INFO 2024-07-30T12:02:28Z interface.cc:71] Use Avx512 backend.
INFO 2024-07-30T12:02:30Z matmul.cc:43] Use GEMM from cuBLAS.
INFO 2024-07-30T12:02:30Z cuda_operators.cc:51] cuda numDevices = 2
INFO 2024-07-30T12:02:30Z cuda_operators.cc:52] cuda:0 maxThreadsPerMultiProcessor = 2048
INFO 2024-07-30T12:02:30Z cuda_operators.cc:54] cuda:0 multiProcessorCount = 20
INFO 2024-07-30T12:02:30Z thread_pool.cc:73] ThreadPool started. numThreads=20
INFO 2024-07-30T12:02:30Z llm.cc:204] read model package: /home/xiaoych/.libllm/models/bilibili-index-1.9b-character-q4.llmpkg
INFO 2024-07-30T12:02:30Z model_for_generation.cc:43] model_type = index
INFO 2024-07-30T12:02:30Z model_for_generation.cc:44] device = cuda
INFO 2024-07-30T12:02:31Z state_map.cc:66] 220 tensors read.
Please input your question.
Type ' :new ' to start a new session (clean history).
Type ' :sys <system_prompt> ' to set the system prompt and start a new session .
> hi
您好!我是Index,请问有什么我可以帮助您的吗?
(12 tokens, time=0.76s, 63.47ms per token)
> $ mkdir build && cd build
$ cmake ..
$ make -jcmakeの前にopenmpをインストールしてください。注:現在、libllm macosは、aarch64カーネルがないため、非常に遅くなると予想されています。
% brew install libomp
% export OpenMP_ROOT= $( brew --prefix ) /opt/libomp
% mkdir build && cd build
% cmake ..
% make -j注:OSに複数のCUDAバージョンがある場合は、 -DCUDAToolkit_ROOT=<CUDA-DIR>を指定します。
推奨バージョンは次のとおりです。
$ mkdir build && cd build
$ cmake -DWITH_CUDA=ON [-DCUDAToolkit_ROOT =< CUDA-DIR > ] ..
$ make -j from libllm import Model , ControlToken
model = Model ( "tools/bilibili_index.llmpkg" )
prompt = [ ControlToken ( "<|reserved_0|>" ), "hi" , ControlToken ( "<|reserved_1|>" )]
for chunk in model . complete ( prompt ):
print ( chunk . text , end = "" , flush = True )
print ( " n Done!" ) package main
import (
"fmt"
"log"
"github.com/ling0322/libllm/go/llm"
)
func main () {
model , err := llm . NewModel ( "../../tools/bilibili_index.llmpkg" , llm . Auto )
if err != nil {
log . Fatal ( err )
}
prompt := llm . NewPrompt ()
prompt . AppendControlToken ( "<|reserved_0|>" )
prompt . AppendText ( "hi" )
prompt . AppendControlToken ( "<|reserved_1|>" )
comp , err := model . Complete ( llm . NewCompletionConfig (), prompt )
if err != nil {
log . Fatal ( err )
}
for comp . IsActive () {
chunk , err := comp . GenerateNextChunk ()
if err != nil {
log . Fatal ( err )
}
fmt . Print ( chunk . Text )
}
fmt . Println ()
}Huggingfaceからのインデックス1.9Bモデルのエクスポートの例を次に示します。
$ cd tools
$ python bilibili_index_exporter.py
-huggingface_name IndexTeam/Index-1.9B-Character
-quant q4
-output index.llmpkg
次に、モデル、トークン剤、および構成を含むIndexTeam/Index-1.9B-Characterにリアルされたすべての必要なモジュールがindex.llmpkgに書き込まれます。