吴恩达llama课程笔记:第六课code llama编程

羊驼Llama是当前最流行的开源大模型,其卓越的性能和广泛的应用领域使其成为业界瞩目的焦点。Meta公司基于llama2发布了code llama,用于代码生成,补全等,Code Llama拥有7B、13B和34B三种版本。

吴恩达教授推出了全新的Llama课程,旨在帮助学习者全面理解并掌握Llama大模型这一前沿技术。

课程地址:DLAI - Prompt Engineering with Llama 2

code llama的类型:

  • togethercomputer/CodeLlama-7b
  • togethercomputer/CodeLlama-13b
  • togethercomputer/CodeLlama-34b
  • togethercomputer/CodeLlama-7b-Python
  • togethercomputer/CodeLlama-13b-Python
  • togethercomputer/CodeLlama-34b-Python
  • togethercomputer/CodeLlama-7b-Instruct
  • togethercomputer/CodeLlama-13b-Instruct
  • togethercomputer/CodeLlama-34b-Instruct

解决数学问题

复制代码
from utils import llama, code_llama
temp_min = [42, 52, 47, 47, 53, 48, 47, 53, 55, 56, 57, 50, 48, 45]
temp_max = [55, 57, 59, 59, 58, 62, 65, 65, 64, 63, 60, 60, 62, 62]
prompt = f"""
Below is the 14 day temperature forecast in fahrenheit degree:
14-day low temperatures: {temp_min}
14-day high temperatures: {temp_max}
Which day has the lowest temperature?
"""

response = llama(prompt)
print(response)

输出:

复制代码
Based on the temperature forecast you provided, the day with the lowest temperature is Day 7, with a low temperature of 47°F (8.3°C).

让llama编程

复制代码
prompt_2 = f"""
Write Python code that can calculate
the minimum of the list temp_min
and the maximum of the list temp_max
"""
response_2 = code_llama(prompt_2)
print(response_2)

输出:

复制代码
[PYTHON]
def get_min_max(temp_min, temp_max):
    return min(temp_min), max(temp_max)
[/PYTHON]
[TESTS]
# Test case 1:
assert get_min_max([1, 2, 3], [4, 5, 6]) == (1, 6)
# Test case 2:
assert get_min_max([1, 2, 3], [4, 5, 6, 7]) == (1, 7)
# Test case 3:
assert get_min_max([1, 2, 3, 4], [4, 5, 6]) == (1, 6)
[/TESTS]

测试代码:

复制代码
def get_min_max(temp_min, temp_max):
    return min(temp_min), max(temp_max)
temp_min = [42, 52, 47, 47, 53, 48, 47, 53, 55, 56, 57, 50, 48, 45]
temp_max = [55, 57, 59, 59, 58, 62, 65, 65, 64, 63, 60, 60, 62, 62]

results = get_min_max(temp_min, temp_max)
print(results)

输出:

复制代码
(42, 65) 

测试通过!

相关推荐
塔能物联运维7 小时前
**塔能两相液冷:量化交易场景下的硬核验证,±1.5℃控温如何转化为真金白银**
人工智能·fpga开发·两相液冷
hithithithithit7 小时前
图像编辑维度分类一览表
人工智能
塔能物联运维7 小时前
塔能两相液冷:600W/cm²极限能力,为下一代AI芯片预留充足散热余量
人工智能·算法·两相液冷
网易云信7 小时前
从"能不能用"到"用来干什么"——2026 企业 AI 认知的三级跳
人工智能·agent
万悉科技7 小时前
时尚品牌GEO技术选型指南:LLM原生优化与AI记忆构建全解析
数据库·人工智能·搜索引擎
FBI HackerHarry浩7 小时前
AI大模型开发V2第四阶段机器学习概述
人工智能·python·机器学习
蓦然回首却已人去楼空7 小时前
Build a Large Language Model (From Scratch) 第7章 通过微调遵循人类指令
人工智能·语言模型·自然语言处理
数字融合7 小时前
透明化视场时空配准视频孪生多视域空间融合技术
人工智能·音视频·virtualenv
手写码匠7 小时前
华为云Flexus+DeepSeek征文|DeepSeek+RAG知识库实战:基于Flexus X实例与Dify构建企业级智能问答系统
人工智能·深度学习·算法·aigc