国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【AI實(shí)戰(zhàn)】開(kāi)源中文 llama2 來(lái)了,30 分鐘搭建 130 億參數(shù)大模型 Llama2-Chinese-13b-Chat

這篇具有很好參考價(jià)值的文章主要介紹了【AI實(shí)戰(zhàn)】開(kāi)源中文 llama2 來(lái)了,30 分鐘搭建 130 億參數(shù)大模型 Llama2-Chinese-13b-Chat。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

簡(jiǎn)介

  • Llama2
    2023年7月19日:Meta 發(fā)布開(kāi)源可商用模型 Llama2。

    Llama2 是一個(gè)預(yù)訓(xùn)練和微調(diào)的生成文本模型的集合,其規(guī)模從70億到700億個(gè)參數(shù)不等。

    LLaMA2 的詳細(xì)介紹可以參考這篇文章:【大模型】更強(qiáng)的 LLaMA2 來(lái)了,開(kāi)源可商用、與 ChatGPT 齊平

  • Llama2-Chinese

    Llama2中文社區(qū)

    Llama2-Chinese GitHub地址

    Llama2 中文 Hugging Face倉(cāng)庫(kù) FlagAlpha: https://huggingface.co/FlagAlpha

    Llama2在線體驗(yàn)鏈接 llama.family

    模型數(shù)據(jù):
    【AI實(shí)戰(zhàn)】開(kāi)源中文 llama2 來(lái)了,30 分鐘搭建 130 億參數(shù)大模型 Llama2-Chinese-13b-Chat,大語(yǔ)言模型,開(kāi)源中文 llama2,llama2,llama2-chinese

    中文微調(diào)參數(shù):
    【AI實(shí)戰(zhàn)】開(kāi)源中文 llama2 來(lái)了,30 分鐘搭建 130 億參數(shù)大模型 Llama2-Chinese-13b-Chat,大語(yǔ)言模型,開(kāi)源中文 llama2,llama2,llama2-chinese

環(huán)境配置

環(huán)境搭建

  • 系統(tǒng)環(huán)境

    • Ubuntu 20.04LTS
    • CUDA 11.8
    • Docker 18.09.5
  • 創(chuàng)建docker容器

拉取docker鏡像

docker pull nvcr.io/nvidia/pytorch:21.08-py3

創(chuàng)建docker


nvidia-docker run -it -d \
    --name llama2_chinese \
    -p 15550:15550 \
    -p 15551:15551 \
    -v /xx/xx/llm:/notebooks \
    -e TZ='Asia/Shanghai' \
    --shm-size 16G \
    nvcr.io/nvidia/pytorch:21.08-py3
    
# docker exec -it llama2_chinese env LANG=C.UTF-8 /bin/bash

修改 /xx/xx/llm 為自己的路徑

進(jìn)入容器內(nèi):

docker exec -it llama2_chinese env LANG=C.UTF-8 /bin/bash
  • 安裝conda

下載:

cd /notebooks
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

安裝:

bash Miniconda3-latest-Linux-x86_64.sh

安裝提升安裝即可

將miniconda加入PATH路徑:

export PATH="/root/miniconda3/bin:$PATH"

創(chuàng)建 conda 環(huán)境:

conda create -n llama2 python=3.10.9
  • 安裝依賴(lài)庫(kù)
conda activate llama2
conda init

exit退出docker,重新進(jìn)入docker

docker exec -it llama2_chinese  env LANG=C.UTF-8 /bin/bash
cd /notebooks
conda activate llama2

依賴(lài)安裝

安裝依賴(lài)庫(kù):

pip install -r requirements-2.txt  -i https://pypi.tuna.tsinghua.edu.cn/simple

代碼及模型權(quán)重拉取

拉取 Llama2-Chinese

git clone https://github.com/FlagAlpha/Llama2-Chinese.git

github網(wǎng)站偶爾會(huì)抽風(fēng),需要耐心等待,如果失敗了,執(zhí)行 rm -rf Llama2-Chinese,再重新拉取

拉取 Llama2-Chinese-13b-Chat 模型權(quán)重及代碼

cd Llama2-Chinese
git clone git clone https://huggingface.co/FlagAlpha/Llama2-Chinese-13b-Chat

由于權(quán)重文件特別大,如果失敗了,執(zhí)行 rm -rf Llama2-Chinese-13b-Chat,再重新拉取。
建議中午時(shí)間拉取,速度比較快,大概 1 小時(shí)(和你的網(wǎng)絡(luò)帶寬有很大關(guān)系?。?/p>

文件大小查看:

du -sh Llama2-Chinese-13b-Chat

輸出:

25G    Llama2-Chinese-13b-Chat

如果文件大小不一致,或者太小,說(shuō)明權(quán)重文件下載識(shí)別,
請(qǐng)執(zhí)行: rm -rf Llama2-Chinese-13b-Chat, 再重新拉取
或者 按照后面的方法去下載權(quán)重文件

查看文件列表:

ls -l Llama2-Chinese-13b-Chat/

輸出:

# ls -l Llama2-Chinese-13b-Chat/
total 25421840
-rw-r--r-- 1 root root       1514 Jul 27 06:33 README.md
-rw-r--r-- 1 root root        683 Jul 27 06:33 config.json
-rw-r--r-- 1 root root        327 Jul 27 07:12 down.sh
-rw-r--r-- 1 root root        175 Jul 27 06:33 generation_config.json
-rw-r--r-- 1 root root 9948728430 Jul 24 23:12 pytorch_model-00001-of-00003.bin
-rw-r--r-- 1 root root 9904165024 Jul 24 12:44 pytorch_model-00002-of-00003.bin
-rw-r--r-- 1 root root 6178983625 Jul 24 12:14 pytorch_model-00003-of-00003.bin
-rw-r--r-- 1 root root      33444 Jul 27 06:33 pytorch_model.bin.index.json
-rw-r--r-- 1 root root        414 Jul 27 06:33 special_tokens_map.json
-rw-r--r-- 1 root root        131 Jul 27 06:33 tokenizer.model
-rw-r--r-- 1 root root        749 Jul 27 06:33 tokenizer_config.json

【】如果大文件下載識(shí)別,按照下面的方法下載模型文件;

wget https://huggingface.co/FlagAlpha/Llama2-Chinese-13b-Chat/resolve/main/pytorch_model-00001-of-00003.bin
wget https://huggingface.co/FlagAlpha/Llama2-Chinese-13b-Chat/resolve/main/pytorch_model-00002-of-00003.bin
wget https://huggingface.co/FlagAlpha/Llama2-Chinese-13b-Chat/resolve/main/pytorch_model-00003-of-00003.bin

如果還是沒(méi)法下載,參考下面的“國(guó)內(nèi) Llama2 最新下載地址” 進(jìn)行下載

終端測(cè)試

進(jìn)入python環(huán)境:

python3

輸入代碼:

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained('Llama2-Chinese-13b-Chat',device_map='auto',torch_dtype=torch.float16,load_in_8bit=True)
model =model.eval()
tokenizer = AutoTokenizer.from_pretrained('Llama2-Chinese-13b-Chat',use_fast=False)
tokenizer.pad_token = tokenizer.eos_token
input_ids = tokenizer(['<s>Human: 介紹一下深圳\n</s><s>Assistant: '], return_tensors="pt",add_special_tokens=False).input_ids.to('cuda')        
generate_input = {
    "input_ids":input_ids,
    "max_new_tokens":512,
    "do_sample":True,
    "top_k":50,
    "top_p":0.95,
    "temperature":0.3,
    "repetition_penalty":1.3,
    "eos_token_id":tokenizer.eos_token_id,
    "bos_token_id":tokenizer.bos_token_id,
    "pad_token_id":tokenizer.pad_token_id
}
generate_ids  = model.generate(**generate_input)
text = tokenizer.decode(generate_ids[0])
print(text)

頁(yè)面測(cè)試

使用 gradio 搭建頁(yè)面

安裝 gradio

pip install gradio -i https://pypi.tuna.tsinghua.edu.cn/simple

加載模型并啟動(dòng)服務(wù)

修改端口;

vi /notebooks/Llama2-Chinese/examples/chat_gradio.py

到94行:

    demo.queue().launch(share=False, debug=True, server_name="0.0.0.0")

修改為:

    demo.queue().launch(share=False, debug=True, server_name="0.0.0.0", server_port=15550)

啟動(dòng)腳本:

python examples/chat_gradio.py --model_name_or_path Llama2-Chinese-13b-Chat

如果出現(xiàn)下面的錯(cuò)誤:

  File "/notebooks/Llama2-Chinese/examples/chat_gradio.py", line 94
    demo.queue().launch(share=False, debug=True, server_name="0.0.0.0")
                                               ^
SyntaxError: invalid character ',' (U+FF0C)

則按照下面的步驟修改代碼:

vi /notebooks/Llama2-Chinese/examples/chat_gradio.py
:94 
修改中文逗號(hào),為英文逗號(hào),

94    demo.queue().launch(share=False, debug=True, server_name="0.0.0.0")
=>
94    demo.queue().launch(share=False, debug=True, server_name="0.0.0.0")
  • 測(cè)試

    瀏覽器打開(kāi)地址:http://10.192.x.x:15550/

國(guó)內(nèi) Llama2 最新下載地址

Llama2-7B官網(wǎng)版本:https://pan.xunlei.com/s/VN_kR2fwuJdG1F3CoF33rwpIA1?pwd=z9kf

Llama2-7B-Chat官網(wǎng)版本:https://pan.xunlei.com/s/VN_kQa1_HBvV-X9QVI6jV2kOA1?pwd=xmra

Llama2-13B官網(wǎng)版本:https://pan.xunlei.com/s/VN_izibaMDoptluWodzJw4cRA1?pwd=2qqb

Llama2-13B-Chat官網(wǎng)版本:https://pan.xunlei.com/s/VN_iyyponyapjIDLXJCNfqy7A1?pwd=t3xw

Llama2-7B Hugging Face版本:https://pan.xunlei.com/s/VN_t0dUikZqOwt-5DZWHuMvqA1?pwd=66ep

Llama2-7B-Chat Hugging Face版本:https://pan.xunlei.com/s/VN_oaV4BpKFgKLto4KgOhBcaA1?pwd=ufir

Llama2-13B Hugging Face版本:https://pan.xunlei.com/s/VN_yT_9G8xNOz0SDWQ7Mb_GZA1?pwd=yvgf

Llama2-13B-Chat Hugging Face版本:https://pan.xunlei.com/s/VN_yA-9G34NGL9B79b3OQZZGA1?pwd=xqrg

參考

1.https://github.com/FlagAlpha/Llama2-Chinese
2.https://huggingface.co/FlagAlpha/Llama2-Chinese-13b-Chat/tree/main
3.https://github.com/facebookresearch/llama
4.https://huggingface.co/meta-llama文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-650811.html

到了這里,關(guān)于【AI實(shí)戰(zhàn)】開(kāi)源中文 llama2 來(lái)了,30 分鐘搭建 130 億參數(shù)大模型 Llama2-Chinese-13b-Chat的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 在樹(shù)莓派中跑迷你Llama2中文模型

    在樹(shù)莓派中跑迷你Llama2中文模型

    ??OpenAI的Karpathy利用周末搞了一個(gè)迷你Llama2項(xiàng)目llama2.c用500行C語(yǔ)言實(shí)現(xiàn)無(wú)任何依賴(lài)項(xiàng)的推理程序,此項(xiàng)目在github發(fā)布以來(lái)衍生出了基于各種語(yǔ)言的迷你Llama推理實(shí)現(xiàn)llama2.go、llama2.java、llama2.py等等; ??但該項(xiàng)目原本的模型并不支持中文,最近正好看到一個(gè)基于llama2的中文訓(xùn)

    2024年02月12日
    瀏覽(18)
  • 實(shí)戰(zhàn)! 30分鐘教你用SoFlu軟件機(jī)器人搭建完成低代碼平臺(tái)

    最近幾年,“低代碼”儼然成了熱門(mén)話題,各大云廠商都在加碼。作為普通企業(yè)的我們是否有也可以深度定制一套自己的“低代碼”平臺(tái)呢? 答案是肯定的,目前主流的就是自建和外購(gòu)兩種方式,隨著低代碼的發(fā)展和廣泛應(yīng)用,這兩種方式的不足之處也日益凸顯。 外購(gòu):貴

    2024年02月14日
    瀏覽(23)
  • 基于Llama2模型的開(kāi)源模型

    基于Llama2模型的開(kāi)源模型

    ??2023年7月18日Meta開(kāi)源了Llama2,在2萬(wàn)億個(gè)Token上訓(xùn)練,可用于商業(yè)和研究,包括從7B到70B模型權(quán)重、預(yù)訓(xùn)練和微調(diào)的代碼。相比Llama1,Llama2有較多提升,評(píng)估結(jié)果如下所示: 基于Llama2模型的開(kāi)源模型如下所示: 1.WizardCoder Python V1.0 2.Phind Code Llama v1 3.WizardLM 70B V1.0 4.Dophin Llam

    2024年02月10日
    瀏覽(24)
  • 大模型部署手記(11)LLaMa2+Chinese-LLaMA-Plus-2-7B+Windows+llama.cpp+中文對(duì)話

    大模型部署手記(11)LLaMa2+Chinese-LLaMA-Plus-2-7B+Windows+llama.cpp+中文對(duì)話

    組織機(jī)構(gòu):Meta(Facebook) 代碼倉(cāng):GitHub - facebookresearch/llama: Inference code for LLaMA models 模型:LIama-2-7b-hf、Chinese-LLaMA-Plus-2-7B ? 下載:使用huggingface.co和百度網(wǎng)盤(pán)下載 硬件環(huán)境:暗影精靈7Plus Windows版本:Windows 11家庭中文版 Insider Preview 22H2 內(nèi)存 32G GPU顯卡:Nvidia GTX 3080 Laptop (1

    2024年02月03日
    瀏覽(26)
  • Sealos 國(guó)內(nèi)集群正式上線,可一鍵運(yùn)行 LLama2 中文版大模型!

    Sealos 國(guó)內(nèi)集群正式上線,可一鍵運(yùn)行 LLama2 中文版大模型!

    2023 年 7 月 19 日,MetaAI 宣布開(kāi)源旗下的 LLama2 大模型,Meta 首席科學(xué)家、圖靈獎(jiǎng)得主 Yann LeCun 在推特上表示 Meta 此舉可能將改變大模型行業(yè)的競(jìng)爭(zhēng)格局。一夜之間,大模型格局再次發(fā)生巨變。 不同于 LLama,LLama2 免費(fèi)可商用 ! LLama2 的能力在 GPT-3 ~ GPT-3.5 之間,對(duì)于關(guān)注數(shù)據(jù)隱

    2024年02月12日
    瀏覽(24)
  • 大模型部署手記(9)LLaMa2+Chinese-LLaMA-Plus-7B+Windows+llama.cpp+中文文本補(bǔ)齊

    大模型部署手記(9)LLaMa2+Chinese-LLaMA-Plus-7B+Windows+llama.cpp+中文文本補(bǔ)齊

    組織機(jī)構(gòu):Meta(Facebook) 代碼倉(cāng):GitHub - facebookresearch/llama: Inference code for LLaMA models 模型:llama-2-7b、Chinese-LLaMA-Plus-7B(chinese_llama_plus_lora_7b) ? 下載:使用download.sh下載 硬件環(huán)境:暗影精靈7Plus Windows版本:Windows 11家庭中文版 Insider Preview 22H2 內(nèi)存 32G GPU顯卡:Nvidia GTX 3080 La

    2024年02月03日
    瀏覽(24)
  • IDPChat:探索基于LLaMA和Stable Diffusion的「開(kāi)源」中文多模態(tài)AI大模型

    IDPChat:探索基于LLaMA和Stable Diffusion的「開(kāi)源」中文多模態(tài)AI大模型

    中文多模態(tài)模型 IDPChat 和大家見(jiàn)面了。 隨著GPT4、文心一言等的發(fā)布,預(yù)訓(xùn)練大模型正式開(kāi)啟由單模態(tài)向多模態(tài)模型演進(jìn)。多模態(tài)的特性為語(yǔ)言模型帶來(lái)更加豐富的應(yīng)用場(chǎng)景。 我們認(rèn)為,未來(lái)的AI應(yīng)用將主要以大模型為核心基石。 而在大模型的領(lǐng)域,基于基礎(chǔ)模型(Foundatio

    2024年02月09日
    瀏覽(24)
  • LLMs之LLaMA2:LLaMA2的簡(jiǎn)介(技術(shù)細(xì)節(jié))、安裝、使用方法(開(kāi)源-免費(fèi)用于研究和商業(yè)用途)之詳細(xì)攻略

    LLMs之LLaMA2:LLaMA2的簡(jiǎn)介(技術(shù)細(xì)節(jié))、安裝、使用方法(開(kāi)源-免費(fèi)用于研究和商業(yè)用途)之詳細(xì)攻略

    LLMs之LLaMA-2:LLaMA-2的簡(jiǎn)介(技術(shù)細(xì)節(jié))、安裝、使用方法(開(kāi)源-免費(fèi)用于研究和商業(yè)用途)之詳細(xì)攻略 導(dǎo)讀 :2023年7月18日,Meta重磅發(fā)布Llama 2!這是一組預(yù)訓(xùn)練和微調(diào)的大型語(yǔ)言模型(LLM),規(guī)模從70億到700億個(gè)參數(shù)不等。Meta微調(diào)的LLM稱(chēng)為L(zhǎng)lama 2-Chat,專(zhuān)為對(duì)話使用場(chǎng)景進(jìn)行了優(yōu)化

    2024年02月16日
    瀏覽(23)
  • 使用 Docker 快速上手官方版 LLaMA2 開(kāi)源大模型

    使用 Docker 快速上手官方版 LLaMA2 開(kāi)源大模型

    本篇文章,我們聊聊如何使用 Docker 容器快速上手 Meta AI 出品的 LLaMA2 開(kāi)源大模型。 昨天特別忙,早晨申請(qǐng)完 LLaMA2 模型下載權(quán)限后,直到晚上才顧上折騰了一個(gè) Docker 容器運(yùn)行方案,都沒(méi)來(lái)得及寫(xiě)文章來(lái)聊聊這個(gè)容器怎么回事,以及怎么使用。 所以,現(xiàn)在就來(lái)聊聊如何快速上

    2024年02月16日
    瀏覽(19)
  • [玩轉(zhuǎn)AIGC]LLaMA2訓(xùn)練中文文章撰寫(xiě)神器(數(shù)據(jù)準(zhǔn)備,數(shù)據(jù)處理,模型訓(xùn)練,模型推理)

    [玩轉(zhuǎn)AIGC]LLaMA2訓(xùn)練中文文章撰寫(xiě)神器(數(shù)據(jù)準(zhǔn)備,數(shù)據(jù)處理,模型訓(xùn)練,模型推理)

    好久沒(méi)更新這個(gè)專(zhuān)欄的文章了,今天抽空寫(xiě)了一篇?!?023.12.28 摘要:文體包括新聞,法律文書(shū),公告,廣告等,每種文體的書(shū)寫(xiě)風(fēng)格不一樣,如果擁有自己的數(shù)據(jù)集,想針對(duì)特定文體來(lái)訓(xùn)練一個(gè)內(nèi)容生成的工具,來(lái)幫助自己寫(xiě)點(diǎn)文章,如果沒(méi)接觸過(guò)AIGC,可能一開(kāi)始會(huì)

    2024年01月17日
    瀏覽(25)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包