什麼是 Llama?

使用 Llama 3

Imtihan Ahmed

Machine Learning Engineer

認識講師

 

  • Imtihan Ahmed
  • 機器學習工程師
  • 6 年經驗
  • 大規模 AI

  講師個人照

使用 Llama 3

什麼是 Llama 3?

 

  • 摘要整理

Screenshot 2025-02-19 at 11.01.25.png

使用 Llama 3

什麼是 Llama 3?

 

  • 摘要整理

 

  • 資料分析

Screenshot 2025-02-19 at 11.01.16.png

使用 Llama 3

什麼是 Llama 3?

 

  • 摘要整理

 

  • 資料分析

 

  • 程式助理

Screenshot 2025-02-19 at 11.01.07.png

使用 Llama 3

什麼是 Llama 3?

Screenshot 2025-02-19 at 11.32.24.png

Llama 3:

  • 由 Meta 開發
使用 Llama 3

什麼是 Llama 3?

Screenshot 2025-02-19 at 11.32.18.png

Llama 3:

  • 由 Meta 開發
  • 文字生成
使用 Llama 3

什麼是 Llama 3?

Screenshot 2025-02-19 at 11.32.12.png

  • 由 Meta 開發
  • 文字生成
  • 以海量資料集訓練
    • 相當於 2000 個 Wikipedia
  • 開源
使用 Llama 3

為何在本機執行 Llama 3

  • 例:工業自動化
    • Llama 預測維修需求

3.jpg

1 https://ai.meta.com/blog/aitomatic-built-with-llama/
使用 Llama 3

為何在本機執行 Llama 3

 

  • 隱私與安全

Screenshot 2025-02-19 at 11.48.10.png

使用 Llama 3

為何在本機執行 Llama 3

 

  • 隱私與安全

 

  • 成本效率

Screenshot 2025-02-19 at 11.48.03.png

使用 Llama 3

為何在本機執行 Llama 3

 

  • 隱私與安全

 

  • 成本效率

 

  • 客製化

Screenshot 2025-02-19 at 11.47.54.png

使用 Llama 3

在本機使用 Llama

  • 安裝 Python 後可在本機使用

Screenshot 2025-02-19 at 11.54.07.png

  • 可透過 llama-cpp-python 函式庫使用
  • 執行 pip install
pip install llama-cpp-python
使用 Llama 3

向 Llama 提問

from llama_cpp import Llama

llm = Llama(model_path = "path/to/model.gguf")
output = llm("What are some ways to improve customer retention?")
  • 匯入 Llama 類別
  • 初始化 LLM
    • 可送出提示並取得回應
    • 模型為 GGUF 格式
  • 傳入問題給 LLM
使用 Llama 3

向 Llama 提問

 

  • 模型接收提示
  • 處理提示
  • 回傳回應

prompting.jpg

使用 Llama 3

解析輸出結果

  • 回應以字典格式呈現
output
{'id': 'cmpl-af88304f-97b0-49f5-ba20-db87f86c4068',
 'object': 'text_completion',
 'created': 1715222298,
 'model': './Llama3-gguf-unsloth.Q4_K_M.gguf',
 'choices': [{'text': 'Improving customer retention is crucial for any business, as 
 it leads to increased revenue, positive word-of-mouth, and cost savings...'},
 ...]
}
使用 Llama 3

解析輸出結果

  • "choices" 的第 0 個元素取出 "text"
output["choices"][0]["text"]
'Improving customer retention is crucial for any business, as 
 it leads to increased revenue, positive word-of-mouth, and cost savings. 
 Here are some effective ways to boost customer retention:
 1. Personalize the Customer Experience
 Tailor your interactions with customers based on their preferences, behaviors, and 
 purchase history. Use data and analytics to create personalized offers, 
 recommendations, and communications.
 2. Foster Strong Relationships
 Build strong, human connections with your customers. Train your...'
使用 Llama 3

一起來練習吧!

使用 Llama 3

Preparing Video For Download...