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

研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘

這篇具有很好參考價(jià)值的文章主要介紹了研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

前言


本文的原文連接是:
https://blog.csdn.net/freewebsys/article/details/108971807

未經(jīng)博主允許不得轉(zhuǎn)載。
博主CSDN地址是:https://blog.csdn.net/freewebsys
博主掘金地址是:https://juejin.cn/user/585379920479288
博主知乎地址是:https://www.zhihu.com/people/freewebsystem

1,關(guān)于gpt2的幾個(gè)例子學(xué)習(xí)


快速使用docker 鏡像進(jìn)行環(huán)境搭建。
相關(guān)的chatGpt項(xiàng)目有:
gpt2官方模型:
https://github.com/openai/gpt-2
6.1K 星星:
https://github.com/Morizeyao/GPT2-Chinese
2.4K 星星:
https://github.com/yangjianxin1/GPT2-chitchat
1.6K 星星:
https://github.com/imcaspar/gpt2-ml

先找個(gè)簡單的進(jìn)行研究:
3.2K 星星:
https://github.com/minimaxir/gpt-2-simple

2,使用docker配置環(huán)境


先弄官方的例子,使用tensorflow的2.12 的鏡像,因顯卡驅(qū)動的問題,只能用cpu進(jìn)行運(yùn)算:

git clone https://github.com/minimaxir/gpt-2-simple
cd gpt-2-simple
docker run --name gpt2simple -itd -v `pwd`:/data -p 8888:8888 tensorflow/tensorflow:latest

版本說明,這邊用的就是最小的版本:能跑就行。

latest: minimal image with TensorFlow Serving binary installed and ready to serve!
:latest-gpu: minimal image with TensorFlow Serving binary installed and ready to serve on GPUs!
:latest-devel - include all source/dependencies/toolchain to develop, along with a compiled binary that works on CPUs
:latest-devel-gpu - include all source dependencies/toolchain (cuda9/cudnn7) to develop, along with a compiled binary that works on NVIDIA GPUs.

然后進(jìn)入docker 鏡像中執(zhí)行命令:
當(dāng)然也可以使用Dockerfile 但是網(wǎng)速慢,且容易出錯:

docker exec -it gpt2simple bash  

############### 以下是登陸后執(zhí)行:

sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

mkdir /root/.pip/

# 增加 pip 的源
echo "[global]" > ~/.pip/pip.conf
echo "index-url = https://mirrors.aliyun.com/pypi/simple/" >> ~/.pip/pip.conf
echo "[install]" >> ~/.pip/pip.conf
echo "trusted-host=mirrors.aliyun.com" >> ~/.pip/pip.conf

cd /data
#注釋掉 tensorflow 依賴
sed -i 's/tensorflow/#tensorflow/g' requirements.txt

pip3 install -r requirements.txt

3,使用uget工具下載模型,文件大容易卡死


sudo apt install uget

然后就是網(wǎng)絡(luò)特別的慢了。根本下載不了,就卡在進(jìn)度中。幾個(gè)特別大的模型,最大的6G。

一個(gè)比一個(gè)大,不知道壓縮沒有:
498M:
https://openaipublic.blob.core.windows.net/gpt-2/models/124M/model.ckpt.data-00000-of-00001
1.42G
https://openaipublic.blob.core.windows.net/gpt-2/models/355M/model.ckpt.data-00000-of-00001
3.10G
https://openaipublic.blob.core.windows.net/gpt-2/models/774M/model.ckpt.data-00000-of-00001
6.23G
https://openaipublic.blob.core.windows.net/gpt-2/models/1558M/model.ckpt.data-00000-of-00001

使用工具下載模型,命令行執(zhí)行的時(shí)候容易卡死:

研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘

這個(gè)云地址不支持多線程下載,就下載了一個(gè)最小的124M的模型。
先嘗個(gè)新鮮就行。

剩下的文件可以單獨(dú)下載:

gpt2 里面的代碼,去掉模型文件其他用腳本下載,哎網(wǎng)絡(luò)是個(gè)大問題。
也沒有國內(nèi)的鏡像。

download_model.py 124M
修改了代碼,去掉了最大的model.ckpt.data 這個(gè)單獨(dú)下載,下載了拷貝進(jìn)去。

import os
import sys
import requests
from tqdm import tqdm

if len(sys.argv) != 2:
    print('You must enter the model name as a parameter, e.g.: download_model.py 124M')
    sys.exit(1)

model = sys.argv[1]

subdir = os.path.join('models', model)
if not os.path.exists(subdir):
    os.makedirs(subdir)
subdir = subdir.replace('\\','/') # needed for Windows

for filename in ['checkpoint','encoder.json','hparams.json', 'model.ckpt.index', 'model.ckpt.meta', 'vocab.bpe']:

    r = requests.get("https://openaipublic.blob.core.windows.net/gpt-2/" + subdir + "/" + filename, stream=True)

    with open(os.path.join(subdir, filename), 'wb') as f:
        file_size = int(r.headers["content-length"])
        chunk_size = 1000
        with tqdm(ncols=100, desc="Fetching " + filename, total=file_size, unit_scale=True) as pbar:
            # 1k for chunk_size, since Ethernet packet size is around 1500 bytes
            for chunk in r.iter_content(chunk_size=chunk_size):
                f.write(chunk)
                pbar.update(chunk_size)

4,研究使用gpt2-simple執(zhí)行demo,訓(xùn)練200次


然后運(yùn)行demo.py 代碼
項(xiàng)目代碼:

提前把模型和文件準(zhǔn)備好:

https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt

另存為,在工程目錄
shakespeare.txt

gpt-2-simple/models$ tree 
.
└── 124M
    ├── checkpoint
    ├── encoder.json
    ├── hparams.json
    ├── model.ckpt.data-00000-of-00001
    ├── model.ckpt.index
    ├── model.ckpt.meta
    └── vocab.bpe

1 directory, 7 files

https://github.com/minimaxir/gpt-2-simple

import gpt_2_simple as gpt2
import os
import requests

model_name = "124M"
file_name = "shakespeare.txt"

sess = gpt2.start_tf_sess()

print("########### init start ###########")

gpt2.finetune(sess,
              file_name,
              model_name=model_name,
              steps=200)   # steps is max number of training steps
gpt2.generate(sess)

print("########### finish ###########")

執(zhí)行:

time python demo.py

real 80m14.186s
user 513m37.158s
sys 37m45.501s

開始訓(xùn)練,做測試,模型訓(xùn)練200次。耗時(shí)是 1小時(shí) 20分鐘。
用的是 Intel? Core? i7-9700 CPU @ 3.00GHz,8核8線程的。
使用CPU訓(xùn)練,沒有顯卡。

研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘
cpu都是80%,load 是 7 ,風(fēng)扇已經(jīng)呼呼轉(zhuǎn)了。
研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘

然后生成對話:
demo-run.py

import gpt_2_simple as gpt2

sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess)
gpt2.generate(sess)

執(zhí)行結(jié)果,沒有cpu/gpu 優(yōu)化:

python demo_generate.py 
2023-03-03 13:11:53.801232: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-03-03 13:11:55.191519: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-03-03 13:11:57.054783: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:357] MLIR V1 optimization pass is not enabled
Loading checkpoint checkpoint/run1/model-200
Ministers' policy: policy
I am the king, and
I shall have none of you;
But, in the desire of your majesty,
I shall take your honour's honour,
And give you no better honour than
To be a king and a king's son,
And my honour shall have no more than that
Which you have given to me.

GLOUCESTER:

MONTAGUE:

Mistress:
Go, go, go, go, go, go, go, go, go!

GLOUCESTER:
You have done well, my lord;
I was but a piece of a body;
And, if thou meet me, I'll take thy pleasure;
And, if thou be not satisfied
I'll give thee another way, or let
My tongue hope that thou wilt find a friend:
I'll be your business, my lord.

MONTAGUE:
Go, go, go, go!

GLOUCESTER:
Go, go, go!

MONTAGUE:
Go, go, go!

GLOUCESTER:
You have been so well met, my lord,
I'll look you to the point:
If thou wilt find a friend, I'll be satisfied;
Thou hast no other choice but to be a king.

MONTAGUE:
Go, go, go!

GLOUCESTER:
Go, go, go!

MONTAGUE:
Go, go, go!

GLOUCESTER:
Go, go, go!

MONTAGUE:
Go, go, go!

GLOUCESTER:
Go, go, go!

KING RICHARD II:
A villain, if you have any, is a villain without a villain.

WARWICK:
I have seen the villain, not a villain,
But--

KING RICHARD II:
Here is the villain.

WARWICK:
A villain.

KING RICHARD II:
But a villain, let him not speak with you.

WARWICK:
Why, then, is there in this house no man of valour?

KING RICHARD II:
The Lord Northumberland, the Earl of Wiltshire,
The noble Earl of Wiltshire, and the Duke of Norfolk
All villainous.

WARWICK:
And here comes the villain?

KING RICHARD II:
He is a villain, if you be a villain.

每次生成的對話都不一樣呢??梢远噙\(yùn)行幾次,生成的內(nèi)容都是不一樣的。

5,總結(jié)


ai果然是高技術(shù)含量的東西,代碼啥的不多,就是沒有太看懂。
然后消耗CPU和GPU資源,也是非常消耗硬件的。
這個(gè)很小的模型訓(xùn)練200次,都這么費(fèi)時(shí)間,更何況是大數(shù)據(jù)量多參數(shù)的模型呢??!

同時(shí)這個(gè)基礎(chǔ)設(shè)施也要搭建起來呢,有個(gè)項(xiàng)目要研究下了,就是
https://www.kubeflow.org/

得去研究服務(wù)器集群了,因?yàn)镹vidia的限制,服務(wù)器上跑的都是又貴又性能低的顯卡。
但是可以本地跑集群做訓(xùn)練呢?。?!

本文的原文連接是:
https://blog.csdn.net/freewebsys/article/details/108971807

研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘文章來源地址http://www.zghlxwxcb.cn/news/detail-484193.html

到了這里,關(guān)于研究開源gpt-2-simple項(xiàng)目,跑一個(gè)簡單的模型,然后生成一段對話。用的是 Intel(R) Core(TM) i7-9700,8核8線程,訓(xùn)練最小的模型200次跑1個(gè)小時(shí)20分鐘的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • 本地構(gòu)建自己的chatgpt已成為可能,國外團(tuán)隊(duì)從GPT3.5提取大規(guī)模數(shù)據(jù)完成本地機(jī)器人訓(xùn)練,并開源項(xiàng)目源碼和模型支持普通在筆記上運(yùn)行chatgpt

    本地構(gòu)建自己的chatgpt已成為可能,國外團(tuán)隊(duì)從GPT3.5提取大規(guī)模數(shù)據(jù)完成本地機(jī)器人訓(xùn)練,并開源項(xiàng)目源碼和模型支持普通在筆記上運(yùn)行chatgpt

    國外團(tuán)隊(duì)從GPT3.5提取大規(guī)模數(shù)據(jù)完成本地機(jī)器人訓(xùn)練,并開源項(xiàng)目源碼和模型支持,普通在筆記上運(yùn)行chatgpt。下面是他們分享的:收集到的數(shù)據(jù)、數(shù)據(jù)管理程序、訓(xùn)練代碼和最終模型,以促進(jìn)開放研究和可重復(fù)性。 在 2023 年 3 月 20 日至 2023 年 3 月 26 日期間,該團(tuán)隊(duì)使用 GPT

    2023年04月21日
    瀏覽(100)
  • GPT-2 開源模型本地搭建(一)

    GPT-2 開源模型本地搭建(一)

    ChatGPT (gpt-35-turbo) 和 GPT-4 模型是針對對話接口進(jìn)行了優(yōu)化的語言模型,都是輸入對話和輸出消息模式。 以上模型的行為與舊的 GPT-3、GPT-2 模型不同,舊的模型是文本輸入和文本輸出,這意味著它們接受了提示字符串并返回了一個(gè)會追加到提示的補(bǔ)全,舊的模型屬于文本補(bǔ)全類

    2023年04月26日
    瀏覽(39)
  • 微軟最新研究成果:使用GPT-4合成數(shù)據(jù)來訓(xùn)練AI模型,實(shí)現(xiàn)SOTA!

    微軟最新研究成果:使用GPT-4合成數(shù)據(jù)來訓(xùn)練AI模型,實(shí)現(xiàn)SOTA!

    文本嵌入是各項(xiàng)NLP任務(wù)的基礎(chǔ),用于將自然語言轉(zhuǎn)換為向量表示。現(xiàn)有的大部分方法通常采用 復(fù)雜的多階段訓(xùn)練流程 ,先在大規(guī)模數(shù)據(jù)上訓(xùn)練,再在小規(guī)模標(biāo)注數(shù)據(jù)上微調(diào)。此過程依賴于手動收集數(shù)據(jù)制作正負(fù)樣本對,缺乏任務(wù)的多樣性和語言多樣性。 此外,大部分方法采

    2024年02月02日
    瀏覽(25)
  • GPT4All 一個(gè)開源 ChatGPT

    GPT4All 一個(gè)開源 ChatGPT

    ChatGPT 正在迅速發(fā)展與傳播,新的大型語言模型 (LLM) 正在以越來越快的速度開發(fā)。就在過去幾個(gè)月,有了顛覆性的 ChatGPT 和現(xiàn)在的 GPT-4。明確定義,GPT 代表(Generative Pre-trained Transformer),是底層語言模型,而 ChatGPT是為會話設(shè)計(jì)的具體實(shí)現(xiàn)。比爾·蓋茨 (Bill Gates) 回顧 OpenAI

    2023年04月17日
    瀏覽(27)
  • 開源了,我做了一個(gè)基于GPT的桌寵聊天系統(tǒng):Pet-GPT!

    開源了,我做了一個(gè)基于GPT的桌寵聊天系統(tǒng):Pet-GPT!

    最近c(diǎn)hatgpt的熱度高居不下。作為一個(gè)深度成謎者,發(fā)現(xiàn)大部分開發(fā)者在調(diào)用GPT的時(shí)候要不就是基于Tauri做本地窗口外接網(wǎng)頁,要不就是web直接展示。在沉思苦想一段時(shí)間后,才發(fā)現(xiàn)好像沒啥什么人用pyqt做???特別是沒人用桌面寵物(想起了當(dāng)初QQ寵物,懷念?。﹣碓L問。 既然

    2023年04月17日
    瀏覽(25)
  • 文本生成高精準(zhǔn)3D模型,北京智源AI研究院等出品—3D-GPT

    文本生成高精準(zhǔn)3D模型,北京智源AI研究院等出品—3D-GPT

    北京智源AI研究院、牛津大學(xué)、澳大利亞國立大學(xué)聯(lián)合發(fā)布了一項(xiàng)研究—3D-GPT,通過文本問答方式就能創(chuàng)建高精準(zhǔn)3D模型。 據(jù)悉,3D-GPT使用了大語言模型的多任務(wù)推理能力,通過任務(wù)調(diào)度代理、概念化代理和建模代理三大模塊,簡化了3D建模的開發(fā)流程實(shí)現(xiàn)技術(shù)民主化。 但3D-

    2024年02月03日
    瀏覽(29)
  • 本地運(yùn)行 LLAMA & GPT-3.5-TURBO開源項(xiàng)目

    本地運(yùn)行 LLAMA & GPT-3.5-TURBO開源項(xiàng)目

    git: nomic-ai/gpt4all: gpt4all: an ecosystem of open-source chatbots trained on a massive collections of clean assistant data including code, stories and dialogue (github.com) 下載好源碼后,的目錄結(jié)構(gòu): ?視頻中說的 chat 目錄在:?gpt4all-training/chat? 下載 gpt4all 使用的模型地址:https://the-eye.eu/public/AI/models/nomic-

    2024年02月11日
    瀏覽(23)
  • 我的創(chuàng)作紀(jì)念日兼GPT模型簡單介紹

    我的創(chuàng)作紀(jì)念日兼GPT模型簡單介紹

    目錄 一、引言 二、收獲與開端 2.1 問題:在創(chuàng)作的過程中都有哪些收獲? 2.2?模型開端 三、日常與深入 3.1 問題:當(dāng)前創(chuàng)作和你的學(xué)習(xí)是什么樣的關(guān)系? 3.2?模型深入介紹 3.2.1 無監(jiān)督預(yù)訓(xùn)練 3.2.2?有監(jiān)督下游任務(wù)精調(diào) 四、憧憬與應(yīng)用 4.1?問題:你的創(chuàng)作規(guī)劃和終極目標(biāo)是什

    2024年02月13日
    瀏覽(17)
  • 用 GPT-4 給開源項(xiàng)目 GoPool 重構(gòu)測試代碼 - 每天5分鐘玩轉(zhuǎn) GPT 編程系列(8)

    用 GPT-4 給開源項(xiàng)目 GoPool 重構(gòu)測試代碼 - 每天5分鐘玩轉(zhuǎn) GPT 編程系列(8)

    目錄 1. 好險(xiǎn),差點(diǎn)被噴 2. 重構(gòu)測試代碼 2.1 引入 Ginkgo 測試框架 2.2 嘗試改造舊的測試用例 2.3 重構(gòu)功能測試代碼 3. 總結(jié) 早幾天發(fā)了一篇文章:《僅三天,我用 GPT-4 生成了性能全網(wǎng)第一的 Golang Worker Pool,輕松打敗 GitHub 萬星項(xiàng)目》,這標(biāo)題是挺容易被懟,哇咔咔;不過最終“

    2024年02月12日
    瀏覽(32)
  • Meta Llama 3強(qiáng)勢來襲:迄今最強(qiáng)開源大模型,性能媲美GPT-4

    Meta Llama 3強(qiáng)勢來襲:迄今最強(qiáng)開源大模型,性能媲美GPT-4

    前言 Meta的最新語言模型Llama 3已經(jīng)發(fā)布,標(biāo)志著在大型語言模型(LLM)領(lǐng)域的一次重大突破,其性能在行業(yè)內(nèi)與GPT-4相媲美。此次更新不僅提升了模型的處理能力和精確性,還將開源模型的性能推向了一個(gè)新的高度。 Huggingface模型下載: https://huggingface.co/meta-llama AI 快站模型免

    2024年04月26日
    瀏覽(19)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包