跳到主要內容

Llama2 建構部署的相關過程


macOS 作業系統

#meta llama2模型下載

#先用git clone整個repository
!git clone https://github.com/facebookresearch/llama.git


#下載權重跟模型

#方法一:
# https://llama-2.ai/download/

#方法二:
# https://ai.meta.com/resources/models-and-libraries/llama-downloads/

# 填寫資料後會發信提供下載時需填的資訊(這個資訊只能使用24hours,之後要下載必須再申請)

# cd ./llama/;./download.sh

# 執行後會需要輸入信裡的資訊/選擇模型,開始下載,大約需要80分鐘
# 結束後會產生
 ./llama/llama-2-7b-chat 目錄,其下是一些檔案
# 以及 ./tokenizer_checklist.chk  ./tokenizer.model
# 需要把上面那兩個檔案複製進  ./llama/llama-2-7b-chat 目錄內

# 將 meta 提供的 .pth(pytorch 轉換為 hugging face 規格)
# 可以先上 https://huggingface.co/ 註冊,以及提供公鑰,稍晚下載時會需要

# 要這樣轉換是因為 huggingface發展了共用規格,多數應用使用這種格式


!pip install torch fairscale fire sentencepiece
!pip install llama-recipes transformers datasets accelerate protobuf==3.20 py7zr scipy peft bitsandbytes

!TRANSFORM=`python -c "import transformers;print('/'.join(transformers.__file__.split('/')[:-1])+'/models/llama/convert_llama_weights_to_hf.py')"`

!python ${TRANSFORM} --input_dir /Users/luke/workspace/AI_Correlation/llama/llama-2-7b --model_size 7B --output_dir ../models_hf/llama-2-7b

#下載中研院 CKIP-Llama 模型 (因 LLM 在地化爭議目前已關閉)

#https://huggingface.co/ckiplab/CKIP-Llama-2-7b-chat/

!cd ./models_hf
!brew install git-lfs

!git lfs install
!git clone https://huggingface.co/ckiplab/CKIP-Llama-2-7b-chat

# if you want to clone without large files – just their pointers
# prepend your git clone with the following env var:

!GIT_LFS_SKIP_SMUDGE=1

其他可參考: 
https://github.com/ckiplab/CKIP-Llama-2-7b (因 LLM 在地化爭議目前已關閉)
或是加入



留言

這個網誌中的熱門文章

3分鐘學會使用程式發送msn訊息,php篇(一)

---電子發票整合方案 http:// rd-program.blogspot.com/ 2012/03/blog-post.html --- < imoo msn機器人測試平台,將於下週三(2009.6.24)取消所有未經申請試用的認證資訊 , 詳見相關資訊 > msnSDK訊息控制開發套件 同時支援MSN/Yahoo即時通 訊息雙向傳遞 ps.也請參考 msnSDK的使用流程 ================================ 步驟一:取得api 使用的權限(GETSPID) $file="http://59.120.234.84:8082/msnSDK/msn_cgi-win32?FUNC=GETSPID&USERID=apiblogt1&PASSWD=msnsdkt" ; $myArray=''; $mySession=''; $myResult=''; $getline=''; if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } while ($getline = fgets($fp, 4096)) { $myArray=explode("\t",$getline); $myResult=$myArray[0]; $mySession= $myArray[1]; } fclose($fp); if ($myResult=="0") { echo "get session fail... "; exit(); } else { //$_SESSION["mySession"]= $mySession; echo "get session=".$mySession." "; } echo "<a href='REGISTER.php?uids=".$_GET["uids...

3分鐘學會使用程式發送msn訊息, Java篇(三)

< imoo msn機器人測試平台,將於下週三(2009.6.24)取消所有未經申請試用的認證資訊 , 詳見相關資訊 > msnSDK訊息控制開發套件 同時支援MSN/Yahoo即時通 訊息雙向傳遞 ps.也請參考 msnSDK的使用流程 ================================ public class clsMsnSDK { public static void main(String[] args) throws Exception { String UserName = "apiblogt3"; String Password = "msnsdkt"; //取得SPID String strRet = GETSPID(UserName,Password); String[]tmp = strRet.split("1\t"); String strValue = tmp[1].replace('\n',' ').trim(); String SPID = strValue; System.out.println(SPID); //註冊聯絡人 String Email = "xxxxx@hotmail.com"; //填入msn/yahoo聯絡人,勿使用這個預設值 String ret = Register(Email,SPID); System.out.println(ret); //發訊息 String strMsg = "Hello_World!"; //輸入訊息 (未做 Url EnCoded) String MsgRet = SendMsg(Email,strMsg,SPID); System.out.println(MsgRet); } //取得SPID public static String GETSPID(String UserName,String Password) throws Exception { String strUrl = "http://59.120.2...