近日,幻方量化旗下AI公司深度求索(DeepSeek)正式發(fā)布DeepSeek-R1模型。在數(shù)學(xué)、代碼、自然語言推理等任務(wù)上,該模型性能比肩OpenAI o1正式版。DeepSeek稱,R1在后訓(xùn)練階段大規(guī)模使用了強化學(xué)習(xí)技術(shù),在僅有極少標(biāo)注數(shù)據(jù)的情況下,極大提升了模型推理能力。
DeepSeek不僅將R1訓(xùn)練技術(shù)全部公開,還蒸餾了6個小模型開源給社區(qū),允許用戶借此訓(xùn)練其他模型。
API價格方面,每百萬輸入tokens 1 元(緩存命中)/4元(緩存未命中),每百萬輸出tokens 16元,較o1正式版低27-55倍。
DeepSeek-R1可以說是一個選能型選手,在各項任務(wù)上展現(xiàn)了超乎想象的能力,特別是在AIME和MATH-500這些高難度挑戰(zhàn)上,DeepSeek-R1的成績簡直讓人目瞪口呆,跟OpenAI o1比起來,毫不遜色,甚至還有點小超越。
你想沒想過,自己也能在本地實現(xiàn)這樣一個功能強大的DeepSeek呢?
今天我來手把手教大家,使用一款 AI 搜索開發(fā)框架--LeetTools 輕松在本地實現(xiàn)DeepSeek。
演示
?? 安裝與配置LeetTools
1. 創(chuàng)建虛擬環(huán)境并安裝LeetTools
1)從anaconda.com下載并安裝naconda
2)從code.visualstudio.com下載并安裝Visual Studio
3)打開anaconda,從左側(cè)菜單選擇Environment,再點擊下方的Creat,為LeetTools創(chuàng)建一個虛擬環(huán)境
4)在彈出的對話框中,給虛擬環(huán)境起一個名字,比如LeetTools,接著勾選Python,選擇版本3.11.11,然后選擇Create,這樣就創(chuàng)建了LeetTools的虛擬環(huán)境。
5)打開Visual Studio
6)選擇最左側(cè)菜單欄的Extension按鈕,安裝Python,Python Debugger,Pylance,Git Extension Pack,Git History,Github Repository,gitignore,Gitlens擴展插件
7)點擊最左側(cè)菜單欄的Source Control,然后點擊Clone Repository按鈕
8)在彈出的地址框中輸入LeetTools的Github地址:??https://github.com/leettools-dev/leettools
9)在彈出的對話框中,選擇下方的新建文件夾,建一個LeetTools的存儲數(shù)據(jù)的文件夾,然后選擇該文件夾,點擊右下方的Select as Repository Destination,完成前期的配置工作,接下來就是LeetTools安裝的過程了
10)然后在桌面上端的菜單欄里選擇,Terminal,New Terminal,就在Visual Studio里打開了一個終端窗口然后就可以開始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. 運行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
?? 示例代碼
以下是一個使用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
定制化場景應(yīng)用
通過LeetTools ,開發(fā)者可以輕松實現(xiàn)DeepSeek的強大功能。當(dāng)然,LeetTools 的能力遠不止于此。在它的開發(fā)框架上,開發(fā)者們可以大展身手,根據(jù)自身需求,開發(fā)出各種定制化的場景應(yīng)用,讓智能搜索真正融入到生活的方方面面。
-----------------------------------
?著作權(quán)歸作者所有:來自51CTO博客作者智領(lǐng)云科技的原創(chuàng)作品,請聯(lián)系作者獲取轉(zhuǎn)載授權(quán),否則將追究法律責(zé)任
碾壓 OpenAI,DeepSeek-R1 發(fā)布!如何在本地實現(xiàn) DeepSeek?
https://blog.51cto.com/u_15471165/13175539