LoginSignup
0
0

llama3の量子化モデルをGoogle Colaboratoryで動かす

Last updated at Posted at 2024-04-20

背景・目的

  • llama3を15GBのVRAMで動かしたい

colabの内容

  • ランタイム -> ランタイムのタイプを変更 -> ハードウェアアクセラレータ -> T4 GPUを選択

  • 下記の内容をセルに書いて実行する

    !git clone https://github.com/ggerganov/llama.cpp
    %cd llama.cpp
    !mkdir build
    %cd build
    !cmake .. -DLLAMA_CUBLAS=ON
    !cmake --build . --config Release
    !cp bin/main ..
    %cd ..
    !wget https://huggingface.co/QuantFactory/Meta-Llama-3-8B-Instruct-GGUF/resolve/main/Meta-Llama-3-8B-Instruct.Q4_K_M.gguf?download=true
    !mv 'Meta-Llama-3-8B-Instruct.Q4_K_M.gguf?download=true' llama3.gguf
    text = "太郎くんは10円のお菓子を三つ買うために100円を支払いました。お釣りはいくら?"
    !./main -m ./llama3.gguf --temp 0.1 -p "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are a helpful assistant. Please answer in Japanese<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n$text<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" -ngl 32 -b 512
    

output

system\n\nYou are a helpful assistant. Please answer in Japaneseuser\n\n太郎くんは10円のお菓子を三つ買うために100円を支払いました。お釣りはいくら?assistant\n\n太郎くんは10円のお菓子を三つ買うために100円を支払いました。10円のお菓子を三つ買うためには、3 x 10 = 30円が必要です。太郎くんは100円を支払ったため、100 - 30 = 70円のお釣りが残ります。 [end of text]

賢い・・!

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0