吴恩达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) 

测试通过!

相关推荐
凤年徐几秒前
保姆级教程:从零搭建你的第一个AI Agent
人工智能
披着羊皮不是狼3 分钟前
基于CNN的图像检测算法
人工智能·算法·cnn
禾高网络6 分钟前
长护险智慧服务平台:科技赋能长期照护保障体系
大数据·人工智能·科技·小程序
永霖光电_UVLED7 分钟前
奇瑞加速欧洲布局,扩产计划开启新征程
人工智能·生成对抗网络·汽车·制造·激光
CoderJia程序员甲11 分钟前
GitHub 热榜项目 - 日榜(2026-04-14)
人工智能·ai·大模型·github·ai教程
威联通安全存储11 分钟前
视频监控底座重构:海量流摄取与边缘 AI 视觉架构
人工智能·重构·音视频
披着羊皮不是狼12 分钟前
深度学习核心架构全解析
人工智能·深度学习
Agent产品评测局12 分钟前
企业邮件处理自动化落地,分类回复全流程实现方法 —— 2026企业级智能体选型与落地全景指南丨Agent产品测评局
运维·人工智能·ai·chatgpt·自动化
张二娃同学14 分钟前
深度学习入门:YOLOv5 与 Fast R-CNN的认识
人工智能·python·深度学习·神经网络·yolo
财经资讯数据_灵砚智能15 分钟前
基于全球经济类多源新闻的NLP情感分析与数据可视化(日间)2026年4月13日
大数据·人工智能·信息可视化·自然语言处理·ai编程