安裝介面
這裡使用llama-cpp-python
pip3 install llama-cpp-python
下載Llama-2
到 https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/tree/main 下載,或是用以下指令:
git lfs install
git clone https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML
程式碼與輸出結果
from llama_cpp import Llama
llm = Llama(model_path="/media/whuang022/Acer/llma2/llama.cpp/llama-2-13b-chat.ggmlv3.q4_0.bin")
output = llm("Q:台北在哪裡阿? A: ", max_tokens=32, stop=["Q:", "\n"], echo=True)
print(output)
輸出結果如下:

本文允許重製、散布、傳輸以及修改,但不得為商業目的之使用
使用時必須註明出處自:楊明翰 , 台灣人工智慧與資料科學研究室 https://aistudio.tw