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

测试通过!

相关推荐
lrh1228008 小时前
详解逻辑回归算法:分类任务核心原理、损失函数与评估方法
人工智能·分类·数据挖掘
StarRocks_labs8 小时前
不止于极速查询!StarRocks 2025 年度回顾:深耕 Lakehouse,加速 AI 融合
starrocks·人工智能·物化视图·lakehouse·湖仓架构
智驱力人工智能8 小时前
景区节假日车流实时预警平台 从拥堵治理到体验升级的工程实践 车流量检测 城市路口车流量信号优化方案 学校周边车流量安全分析方案
人工智能·opencv·算法·安全·yolo·边缘计算
Sherlock Ma8 小时前
强化学习入门(2):DQN、Reinforce、AC、PPO
人工智能·深度学习·机器学习·自然语言处理·transformer·dnn·强化学习
冰西瓜6008 小时前
从项目入手机器学习(六)—— 深度学习尝试
人工智能·深度学习·机器学习
一起养小猫8 小时前
Flutter for OpenHarmony 进阶:Timer组件与倒计时系统深度解析
android·网络·笔记·flutter·json·harmonyos
水境传感 张园园8 小时前
负氧离子监测站:守护清新空气,畅享健康生活
人工智能·负氧离子监测站
咩咩不吃草8 小时前
机器学习不平衡数据处理三招:k折交叉验证、下采样与过采样实战
人工智能·算法·机器学习·下采样·过采样·k折交叉验证
TSINGSEE8 小时前
国标GB28181视频质量诊断:EasyGBS服务插件EasyVQD快速识别花屏、蓝屏、画面冻结抖动
人工智能·音视频·实时音视频·视频编解码·视频质量诊断·花屏检测·画面抖动
多恩Stone8 小时前
【3DV 进阶-11】Trellis.2 数据处理与训练流程图
人工智能·pytorch·python·算法·3d·aigc·流程图