• Stars
    star
    450
  • Rank 96,482 (Top 2 %)
  • Language
    Jupyter Notebook
  • License
    Apache License 2.0
  • Created 9 months ago
  • Updated 25 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quick Start for Large Language Models (Theoretical Learning and Practical Fine-tuning) 大语言模型快速入门(理论学习与微调实战)

大模型微调训练 快速入门


中文 | English

大语言模型快速入门(理论学习与微调实战)

搭建开发环境

详细安装说明请参考文档

安装 Python 依赖包

请使用 requirements.txt 文件进行 Python 依赖包安装:

pip install -r requirements.txt

目前支持项目运行的软件版本列表如下所示,详见版本对照文档

torch>=2.1.2==2.3.0.dev20240116+cu121
transformers==4.37.2
ffmpeg==1.4
ffmpeg-python==0.2.0
timm==0.9.12
datasets==2.16.1
evaluate==0.4.1
scikit-learn==1.3.2
pandas==2.1.1
peft==0.7.2.dev0
accelerate==0.26.1
autoawq==0.2.2
optimum==1.17.0.dev0
auto-gptq==0.6.0
bitsandbytes>0.39.0==0.41.3.post2
jiwer==3.0.3
soundfile>=0.12.1==0.12.1
librosa==0.10.1
langchain==0.1.0
gradio==4.13.0

为了检查你的运行环境中软件版本是否匹配,项目提供了自动化版本检查脚本,请注意修改输出文件名。

关于 GPU 驱动和 CUDA 版本

通常,GPU 驱动和 CUDA 版本都是需要满足安装的 PyTorch 和 TensorFlow 版本。

大多数新发布的大语言模型使用了较新的 PyTorch v2.0+ 版本,Pytorch 官方认为 CUDA 最低版本是 11.8 以及匹配的 GPU 驱动版本。详情见Pytorch官方提供的 CUDA 最低版本要求回复

简而言之,建议直接安装当前最新的 CUDA 12.3 版本,详情见 Nvidia 官方安装包

安装完成后,使用 nvidia-smi 指令查看版本:

nvidia-smi          
Mon Dec 18 12:10:47 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.129.03             Driver Version: 535.129.03   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  Tesla T4                       Off | 00000000:00:0D.0 Off |                    0 |
| N/A   44C    P0              26W /  70W |      2MiB / 15360MiB |      6%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

Jupyter Lab 后台启动配置

上述开发环境安装完成后,建议使用后台常驻的方式来启动 Jupyter Lab。下面是相关配置(以 root 用户为例):

# 生成 Jupyter Lab 配置文件,
$ jupyter lab --generate-config
Writing default config to: /root/.jupyter/jupyter_lab_config.py

打开配置文件后,修改以下配置项:

# 非 root 用户启动,无需修改
c.ServerApp.allow_root = True
c.ServerApp.ip = '*'

使用 nohup 后台启动 Jupyter Lab

$ nohup jupyter lab --port=8000 --NotebookApp.token='替换为你的密码' --notebook-dir=./ &

Jupyter Lab 输出的日志将会保存在 nohup.out 文件(已在 .gitignore中过滤)。

关于 LangChain 调用 OpenAI GPT API 的配置

为了使用OpenAI API,你需要从OpenAI控制台获取一个API密钥。一旦你有了密钥,你可以将其设置为环境变量:

对于基于Unix的系统(如Ubuntu或MacOS),你可以在终端中运行以下命令:

export OPENAI_API_KEY='你的-api-key'

对于Windows,你可以在命令提示符中使用以下命令:

set OPENAI_API_KEY=你的-api-key

请确保将'你的-api-key'替换为你的实际OpenAI API密钥。

More Repositories

1

openai-quickstart

A comprehensive guide to understanding and implementing large language models with hands-on examples using LangChain for GenAI applications.
Jupyter Notebook
1,094
star
2

tensorflow-101

《TensorFlow 快速入门与实战》和《TensorFlow 2 项目进阶实战》课程代码与课件
Jupyter Notebook
453
star
3

tensorflow-in-depth

《深入理解TensorFlow》项目代码与样章
Python
304
star
4

agent-hub

This repository is a hub for AI Agent projects, including GitHub Sentinel, LanguageMentor, and ChatPPT, designed to enhance enterprise workflows, language learning, and multimodal interaction. Explore a growing family of agents geared towards revolutionizing various industries with cutting-edge AI solutions.
Shell
75
star
5

openai-translator

A versatile AI translation tool powered by LLMs.
Python
72
star
6

GitHubSentinel

GitHub Sentinel 是专为大模型(LLMs)时代打造的智能信息检索和高价值内容挖掘 AI Agent。它面向那些需要高频次、大量信息获取的用户,特别是开源爱好者、个人开发者和投资人等。GitHub Sentinel 不仅能帮助用户自动跟踪和分析 GitHub 开源项目 的最新动态,还能快速扩展到其他信息渠道,如 Hacker News 的热门话题,提供更全面的信息挖掘与分析能力。
Jupyter Notebook
66
star
7

keras-101

Keras 快速入门与实战
Jupyter Notebook
60
star
8

start-ai

从零开始学习人工智能(Start-AI)
39
star
9

aml-101

微软机器学习(Azure Machine Learning)快速入门与实战
Jupyter Notebook
25
star
10

tensorflow2-tutorials

Tutorials of TensorFlow 2.0(Keras, Eager, TFX, etc)
Jupyter Notebook
18
star
11

leetcode-solutions

The Python solutions of leetcode
Jupyter Notebook
12
star
12

DjangoPeng.github.io

Personal Blog
HTML
9
star
13

CRF

Build the crf++ project with Visual Studio in MS-Windows
C++
7
star
14

PredictionModel

Python
6
star
15

word2vec

Build word2vec with Visual Studio in MS-Windows
C
2
star