大型语言模型(LLM)简介

Python 中的 LLM 入门

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

预备知识

  • 浏览 Hugging Face Hub
  • 深度学习模型

卡通大脑读书图标

Python 中的 LLM 入门

LLM 简介

 

代表理解的灯泡与大脑图标

Python 中的 LLM 入门

LLM 简介

 

代表使用的笔记本插图

Python 中的 LLM 入门

大型语言模型抽象图

Python 中的 LLM 入门

带有"总结"气泡的大型语言模型抽象图

Python 中的 LLM 入门

带有"总结"和"生成"气泡的大型语言模型抽象图

Python 中的 LLM 入门

带有"总结""生成""翻译"气泡的大型语言模型抽象图

Python 中的 LLM 入门

带有"总结、生成、翻译、问答"气泡的大型语言模型抽象图

LLM 标志

Python 中的 LLM 入门

LLM

 

  • 基于深度学习架构

 

  • 最常见为Transformer

 

  • 海量参数与文本数据的神经网络

Hugging Face 标志

Python 中的 LLM 入门

使用 Hugging Face 模型

from transformers import pipeline


summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn")
text = "Walking amid Gion's Machiya wooden houses is a mesmerizing experience. The beautifully preserved structures exuded an old-world charm that transports visitors back in time, making them feel like they had stepped into a living museum. The glow of lanterns lining the narrow streets add to the enchanting ambiance, making each stroll a memorable journey through Japan's rich cultural history." summary = summarizer(text, max_length=50)
  • clean_up_tokenization_spaces=True:移除多余空格
Python 中的 LLM 入门

模型输出

print(summary)
[{'summary_text': "Gion's Machiya
  wooden houses exuded an old-world 
  charm that transports visitors back 
  in time. The glow of lanterns lining 
  the narrow streets add to the 
  enchanting ambiance, making each 
  stroll a memorable journey through 
  Japan's"}]
print(summary[0]["summary_text"])
Gion's Machiya wooden houses exuded an 
old-world charm that transports 
visitors back in time. The glow of 
lanterns lining the narrow streets add 
to the enchanting ambiance, making each 
stroll a memorable journey through 
Japan's
Python 中的 LLM 入门

接下来

 

  • 巩固现有 LLM 知识
  • 完成新任务
  • 了解 LLM 构建方式
  • 微调 LLM
  • 评估 LLM 表现

学习路径

Python 中的 LLM 入门

让我们练习!

Python 中的 LLM 入门

Preparing Video For Download...