AI行業在兩個強大的哲學之間進行了分配 - 開源民主化和專有創新。由Allenai開發的Olmo 2(開放語言模型2)代表了透明AI開發的巔峰之作,可以完全訪問其體系結構和培訓數據。相比之下,Anthropic的旗艦模型Claude 3.5十四行詩優先考慮商業級編碼功能和閉門造車的多模式推理。
本文介入其技術體系結構,用例和實際工作流程中,並附有代碼示例和數據集參考。無論您是構建啟動聊天機器人還是擴展企業解決方案,本指南都將幫助您做出明智的選擇。
學習目標
>了解設計選擇(例如RMSNORM,旋轉嵌入)如何影響Olmo 2和Claude 3.5十四行詩中的訓練穩定性和性能。
> > data Science Blogathon的一部分。 目錄的> olmo 2:一個完全開放的自動回歸模型
>
> Olmo 2是一種完全開源的自回歸語言模型,在包含5萬億代幣的巨大數據集中訓練。它的重量,培訓數據和源代碼賦予了研究人員和開發人員的能力,以重現結果,嘗試培訓過程並建立其創新架構。
ofolmo 2的關鍵建築創新是什麼?
兩階段的課程培訓:
該模型最初是在Dolmino Mix-1124數據集中訓練的,這是一種旨在涵蓋各種語言模式和下游任務的大型且多樣的語料庫。接下來是第二階段,培訓側重於特定於任務的微調。這些建築和培訓策略結合在一起,創建了一個模型,不僅表現出色,而且適應性和適應性,這是學術研究和實際應用的真正資產。
標準 Olmo 2 OLMO2對於重量的任務來說,成本效益大約是4倍,使其非常適合注重預算意識的項目。請注意,由於Olmo2是一種開放式源模型,因此沒有固定的人口許可費,因此其成本取決於您的自我安置計算資源。相比之下,擬人的API速率設定了Claude 3.5十四行詩的價格。 有Ollama後,安裝必要的Python軟件包
如何訪問Claude 3.5 SONNET API? >單擊創建鍵並命名您的密鑰。單擊添加。
使用olmo2和Claude 3.5 SonnetModels用於以下任務。 提示:“給我代碼來計算nth fibonacci編號。
b)claudesonnet3.5響應
“提示:生成一個使用matplotlib和seaborn的Python腳本來產生充滿活力的散點圖,顯示了兩個變量之間的關係。該圖應包括清晰的軸標籤,描述性標題和不同的顏色,以區分數據點。
a)olmo 2響應:
您可以找到代碼響應。
b)claudesonnet3.5響應: a)olmo 2響應: 戰略決策框架:Olmo 2 vs. Claude 3.5十四行詩 > Q1。 Olmo 2可以通過足夠的微調來匹配Claude 3.5十四行詩的準確性?在狹窄的域(例如,法律文件)中,是的。對於通用任務,Claude的140B參數保留了邊緣。模型如何處理非英語語言? Claude 3.5十四行詩本地支持50種語言。 Olmo 2主要集中在英語上,但可以對多語言任務進行微調。 >克勞德3.5十四行詩:以道德和以編碼為中心的應用程序的封閉資源
與Olmo2的開放哲學相反,Claude3.5 SONNet是針對專業任務進行了優化的封閉源模型,尤其是在編碼和確保道德上合理的輸出方面。它的設計反映了績效和負責任的部署之間的仔細平衡。
> claude 3.5sonnet
模型訪問
擁抱面上可用的全重量
僅api formy訪問
微調
可通過pytorch 自定義
限製到及時工程
推理速度
12令牌/秒(A100 GPU)
30令牌/秒(API)
Olmo 2 vs. Claude 3.5十四行詩的定價比較成本
免費(自主)
$ 15/百萬令牌
>訪問Olmo 2型號和Claude 3.5十四行詩API
如何在本地運行Ollama(Olmo 2)模型?
>訪問官方的Ollama存儲庫或網站,以下載安裝程序 - Here。
pip install ollama
ollama run olmo2:7b
import ollama
def generate_with_olmo(prompt, n_predict=1000):
"""
Generate text using Ollama's Olmo 2 model (streaming version),
controlling the number of tokens with n_predict.
"""
full_text = []
try:
for chunk in ollama.generate(
model='olmo2:7b',
prompt=prompt,
options={"n_predict": n_predict},
stream=True
):
full_text.append(chunk["response"])
return "".join(full_text)
except Exception as e:
return f"Error with Ollama API: {str(e)}"
if __name__ == "__main__":
output = generate_with_olmo("Explain the concept of quantum computing in simple terms.")
print("Olmo 2 Response:", output)
pip install anthropic
import anthropic
from anthropic import Anthropic
# Create an instance of the Anthropic API client
client = Anthropic(api_key='your-api-key')
def generate_with_claude(prompt, max_tokens=1000):
"""
Generate text using Claude 3.5 API
"""
try:
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=max_tokens,
messages=[
{
"role": "user",
"content": prompt
}
]
)
return message.content
except Exception as e:
return f"Error with Claude API: {str(e)}"
if __name__ == "__main__":
output = generate_with_claude("Explain the concept of quantum computing in simple terms.")
print("Claude 3.5 Sonnet Response:", output)
>
:
def fibonacci_optimized(n):
if n <= 0:
return "Input must be a positive integer."
fib_0, fib_1 = 0, 1
for i in range(2, n+1):
fib_i = fib_0 + fib_1
fib_0, fib_1 = fib_1, fib_i
return fib_i
# Example usage:
print(fibonacci_optimized(10)) # Output: 55
Olmo 2提供了一種有效但缺乏靈活性的迭代方法,僅提供一種方法。另一方面,Claude Sonnet 3.5提出了三種不同的實現:遞歸(效率低下但具有教育意義),迭代性(最佳使用)和矩陣指數(最適合大型輸入)。克勞德(Claude)的反應更加全面,涵蓋了多種用例,並包括測試套件以驗證正確性。 >
>任務2:繪製散點圖
>
b)claudesonnet3.5響應:
Insights
>任務3:代碼翻譯
>
提示:“將此Java方法轉換為python代碼,同時保持等效功能:>
a)olmo 2響應:pip install ollama
Insights :
ollama run olmo2:7b
Olmo 2和Claude Sonnet 3.5都提供相同的解決方案,將Java方法準確地轉換為Python。由於該功能很簡單,因此沒有分化的空間,這兩個響應同樣有效。
任務4:優化效率低下的代碼
import ollama
def generate_with_olmo(prompt, n_predict=1000):
"""
Generate text using Ollama's Olmo 2 model (streaming version),
controlling the number of tokens with n_predict.
"""
full_text = []
try:
for chunk in ollama.generate(
model='olmo2:7b',
prompt=prompt,
options={"n_predict": n_predict},
stream=True
):
full_text.append(chunk["response"])
return "".join(full_text)
except Exception as e:
return f"Error with Ollama API: {str(e)}"
if __name__ == "__main__":
output = generate_with_olmo("Explain the concept of quantum computing in simple terms.")
print("Olmo 2 Response:", output)
提示:“優化以下python函數以降低時間複雜性。>
b)claudesonnet3.5響應:pip install anthropic
通過使用集合跟踪可見元素,但保留了存儲重複項的列表,從而提高了 Olmo 2的
> olmo 2,從而導致潛在的冗餘。 Claude Sonnet 3.5通過將重複項存儲在集合中,並將其轉換回列表,從而提高效率並避免不必要的操作,從而進一步優化。克勞德(Claude)的方法更加干淨,可確保時間更複雜,同時保持正確性。 import anthropic
from anthropic import Anthropic
# Create an instance of the Anthropic API client
client = Anthropic(api_key='your-api-key')
def generate_with_claude(prompt, max_tokens=1000):
"""
Generate text using Claude 3.5 API
"""
try:
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=max_tokens,
messages=[
{
"role": "user",
"content": prompt
}
]
)
return message.content
except Exception as e:
return f"Error with Claude API: {str(e)}"
if __name__ == "__main__":
output = generate_with_claude("Explain the concept of quantum computing in simple terms.")
print("Claude 3.5 Sonnet Response:", output)
>
任務5:代碼調試
def fibonacci_optimized(n):
if n <= 0:
return "Input must be a positive integer."
fib_0, fib_1 = 0, 1
for i in range(2, n+1):
fib_i = fib_0 + fib_1
fib_0, fib_1 = fib_1, fib_i
return fib_i
# Example usage:
print(fibonacci_optimized(10)) # Output: 55
>提示:“以下是一個python腳本,可以計算一個數字的階乘,但其中包含錯誤。識別並糾正錯誤,以確保其返回任何正整數的正確階乘:
pip install ollama
a)olmo 2響應:
ollama run olmo2:7b
b)claudesonnet3.5響應:
import ollama
def generate_with_olmo(prompt, n_predict=1000):
"""
Generate text using Ollama's Olmo 2 model (streaming version),
controlling the number of tokens with n_predict.
"""
full_text = []
try:
for chunk in ollama.generate(
model='olmo2:7b',
prompt=prompt,
options={"n_predict": n_predict},
stream=True
):
full_text.append(chunk["response"])
return "".join(full_text)
except Exception as e:
return f"Error with Ollama API: {str(e)}"
if __name__ == "__main__":
output = generate_with_olmo("Explain the concept of quantum computing in simple terms.")
print("Olmo 2 Response:", output)
洞察力:
> olmo 2正確修復了階乘函數的遞歸步驟,但缺乏輸入驗證。 Claude Sonnet 3.5不僅糾正了遞歸,還包括輸入驗證以處理負數和非授權輸入,使其更強大。 Claude的解決方案更徹底,適合現實世界應用。
何時選擇Olmo 2?
>預算約束的項目:免費自我託管與API費
>企業級編碼:複雜的代碼生成/重構
>多模式要求:現場服務器上的圖像和文本處理需求。
鑰匙要點
以上是Olmo 2對Claude 3.5十四行詩:哪個更好?的詳細內容。更多資訊請關注PHP中文網其他相關文章!