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

测试通过!

相关推荐
Funny_AI_LAB12 分钟前
MetaAI最新开源Llama3.2亮点及使用指南
算法·计算机视觉·语言模型·llama·facebook
NuyoahC19 分钟前
算法笔记(十一)——优先级队列(堆)
c++·笔记·算法·优先级队列
Langchain22 分钟前
不可错过!CMU最新《生成式人工智能大模型》课程:从文本、图像到多模态大模型
人工智能·自然语言处理·langchain·大模型·llm·大语言模型·多模态大模型
龙的爹233333 分钟前
论文翻译 | Generated Knowledge Prompting for Commonsense Reasoning
人工智能·gpt·机器学习·语言模型·自然语言处理·nlp·prompt
龙的爹233334 分钟前
论文翻译 | Model-tuning Via Prompts Makes NLP Models Adversarially Robust
人工智能·gpt·语言模型·自然语言处理·nlp·prompt
方世恩1 小时前
【进阶OpenCV】 (5)--指纹验证
人工智能·opencv·目标检测·计算机视觉
这可就有点麻烦了1 小时前
强化学习笔记之【TD3算法】
linux·笔记·算法·机器学习
A_lvvx1 小时前
OpenCV透视变换
人工智能·opencv·计算机视觉
百锦再1 小时前
自动驾驶的技术实现及原理
人工智能·机器学习·自动驾驶
AcademicIdeas学境思源2 小时前
避免学术欺诈!在ChatGPT帮助下实现严格引用并避免抄袭
人工智能