碾壓 OpenAI,DeepSeek-R1 發(fā)布!如何在本地實(shí)現(xiàn) DeepSeek?

近日,幻方量化旗下AI公司深度求索(DeepSeek)正式發(fā)布DeepSeek-R1模型。在數(shù)學(xué)、代碼、自然語(yǔ)言推理等任務(wù)上,該模型性能比肩OpenAI o1正式版。DeepSeek稱(chēng),R1在后訓(xùn)練階段大規(guī)模使用了強(qiáng)化學(xué)習(xí)技術(shù),在僅有極少標(biāo)注數(shù)據(jù)的情況下,極大提升了模型推理能力。


DeepSeek不僅將R1訓(xùn)練技術(shù)全部公開(kāi),還蒸餾了6個(gè)小模型開(kāi)源給社區(qū),允許用戶借此訓(xùn)練其他模型。


API價(jià)格方面,每百萬(wàn)輸入tokens 1 元(緩存命中)/4元(緩存未命中),每百萬(wàn)輸出tokens 16元,較o1正式版低27-55倍。

DeepSeek-R1可以說(shuō)是一個(gè)選能型選手,在各項(xiàng)任務(wù)上展現(xiàn)了超乎想象的能力,特別是在AIME和MATH-500這些高難度挑戰(zhàn)上,DeepSeek-R1的成績(jī)簡(jiǎn)直讓人目瞪口呆,跟OpenAI o1比起來(lái),毫不遜色,甚至還有點(diǎn)小超越。

你想沒(méi)想過(guò),自己也能在本地實(shí)現(xiàn)這樣一個(gè)功能強(qiáng)大的DeepSeek呢?


今天我來(lái)手把手教大家,使用一款 AI 搜索開(kāi)發(fā)框架--LeetTools 輕松在本地實(shí)現(xiàn)DeepSeek。

演示

?? 安裝與配置LeetTools

1. 創(chuàng)建虛擬環(huán)境并安裝LeetTools

1)從anaconda.com下載并安裝naconda

2)從code.visualstudio.com下載并安裝Visual Studio

3)打開(kāi)anaconda,從左側(cè)菜單選擇Environment,再點(diǎn)擊下方的Creat,為L(zhǎng)eetTools創(chuàng)建一個(gè)虛擬環(huán)境

4)在彈出的對(duì)話框中,給虛擬環(huán)境起一個(gè)名字,比如LeetTools,接著勾選Python,選擇版本3.11.11,然后選擇Create,這樣就創(chuàng)建了LeetTools的虛擬環(huán)境。

5)打開(kāi)Visual Studio

6)選擇最左側(cè)菜單欄的Extension按鈕,安裝Python,Python Debugger,Pylance,Git Extension Pack,Git History,Github Repository,gitignore,Gitlens擴(kuò)展插件


7)點(diǎn)擊最左側(cè)菜單欄的Source Control,然后點(diǎn)擊Clone Repository按鈕

8)在彈出的地址框中輸入LeetTools的Github地址:??https://github.com/leettools-dev/leettools

9)在彈出的對(duì)話框中,選擇下方的新建文件夾,建一個(gè)LeetTools的存儲(chǔ)數(shù)據(jù)的文件夾,然后選擇該文件夾,點(diǎn)擊右下方的Select as Repository Destination,完成前期的配置工作,接下來(lái)就是LeetTools安裝的過(guò)程了

10)然后在桌面上端的菜單欄里選擇,Terminal,New Terminal,就在Visual Studio里打開(kāi)了一個(gè)終端窗口然后就可以開(kāi)始LeetTools的安裝了。

% conda create -y -n leettools pythnotallow=3.11

% conda activate leettools

% pip install leettools

# where we store all the data and logs

% export LEET_HOME=${HOME}/leettools

% mkdir -p ${LEET_HOME}

2. 設(shè)置環(huán)境變量

# set the endpoint and api key

% export EDS_DEFAULT_LLM_BASE_URL=https://api.openai.com/v1

% export EDS_LLM_API_KEY=<your_openai_api_key>

3. 運(yùn)行LeetTools 命令

# now you can run the command line commands

# flow: the subcommand to run different flows, use --list to see all the available flows

# -t run this 'answer' flow, use --info option to see the function description

# -q the query

# -k save the scraped web page to the knowledge base

# -l log level, info shows the essential log messages

% leet flow -t answer -q "How does GraphRAG work?" -k graphrag -l info

?? 示例代碼

以下是一個(gè)使用LeetTools 調(diào)用 DeepSeek 的示例代碼:

### to use other API providers such as DeepSeek, you can

% export EDS_DEFAULT_LLM_BASE_URL=https://api.deepseek.com/v1

% export EDS_LLM_API_KEY=<your deepseek api key>

% export EDS_DEFAULT_LLM_MODEL=deepseek-chat

# use a local embedder since DeepSeek does not provide an embedding endpoint yet

# if the API supports OpenAI-compatible embedding endpoint, no extra settings needed

# this dense_embedder_local_mem uses all-MiniLM-L6-v2 model as a singleton embedder

% export EDS_DEFAULT_DENSE_EMBEDDER=dense_embedder_local_mem

# Or you can put the above settings in the .env.deepseek file

% cat > .env.deepseek

LEET_HOME=/Users/myhome/leettools

EDS_DEFAULT_LLM_BASE_URL=https://api.deepseek.com/v1

EDS_LLM_API_KEY=sk-0d8-mykey

EDS_DEFAULT_LLM_MODEL=deepseek-chat

EDS_DEFAULT_DENSE_EMBEDDER=dense_embedder_local_mem

# Then run the command with the -e option to specify the .env file to use

% leet flow -e .env.deepseek -t answer -q "How does GraphRAG work?" -k graphrag -l info

定制化場(chǎng)景應(yīng)用

通過(guò)LeetTools ,開(kāi)發(fā)者可以輕松實(shí)現(xiàn)DeepSeek的強(qiáng)大功能。當(dāng)然,LeetTools 的能力遠(yuǎn)不止于此。在它的開(kāi)發(fā)框架上,開(kāi)發(fā)者們可以大展身手,根據(jù)自身需求,開(kāi)發(fā)出各種定制化的場(chǎng)景應(yīng)用,讓智能搜索真正融入到生活的方方面面。

-----------------------------------

?著作權(quán)歸作者所有:來(lái)自51CTO博客作者智領(lǐng)云科技的原創(chuàng)作品,請(qǐng)聯(lián)系作者獲取轉(zhuǎn)載授權(quán),否則將追究法律責(zé)任

碾壓 OpenAI,DeepSeek-R1 發(fā)布!如何在本地實(shí)現(xiàn) DeepSeek?

https://blog.51cto.com/u_15471165/13175539

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容