paulwong

2024年7月8日 #

debian安装python+替换为清华源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo vi /etc/apt/sources.list.d/debian.sources

添加如下内容:
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian/
Suites: bookworm bookworm-updates bookworm-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security/
Suites: bookworm-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

更新所有包
sudo apt update

安装python
sudo apt-get install python3

sudo apt-get install python3-pip

命令支持短写
sudo apt install python-is-python3

安装miniconda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_25.3.1-1-Linux-x86_64.sh

bash Miniconda3-py310_25.3.1-1-Linux-x86_64.sh
conda config --set show_channel_urls yes

cat > ~/.condarc <<EOF
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
EOF

清除缓存
conda clean -i

conda --version
conda info # 查看渠道是否显示为清华源




posted @ 2025-06-23 11:32 paulwong 阅读(33) | 评论 (0)编辑 收藏

最全 Docker 神器集结,让你的服务器瞬间起飞!

https://mp.weixin.qq.com/s/gtyMdmCqBY7LfdBGUBldSA

posted @ 2025-06-21 23:01 paulwong 阅读(18) | 评论 (0)编辑 收藏

百炼大模型支持深度思考


https://help.aliyun.com/zh/model-studio/deep-thinking#1f5ad51894bvi

posted @ 2025-06-18 23:56 paulwong 阅读(11) | 评论 (0)编辑 收藏

以非root用户运行docker

sudo useradd -m paul # 创建用户并自动建立家目录
sudo passwd paul # 设置用户密码(需输入两次确认)
sudo usermod -aG wheel paul # CentOS/RHEL
[root@dev69 ~]$ groupadd docker
[root@dev69 ~]$ usermod -aG docker $USER
[root@dev69 ~]$ reboot
[paul@dev69 ~]$ docker run hello-world

posted @ 2025-06-13 16:47 paulwong 阅读(12) | 评论 (0)编辑 收藏

创建数据集的资源


AI 数据集生成和模型微调框架 Distilabel 入门指南:基本概念、安装与快速开始
https://zhuanlan.zhihu.com/p/25766406373

使用Llama3和distilabel构建微调数据
https://huggingface.co/blog/dvilasuero/synthetic-data-with-llama3-distilabel

posted @ 2025-05-18 08:01 paulwong 阅读(23) | 评论 (0)编辑 收藏

强化学习资源

蘑菇书EasyRL
李宏毅老师的《深度强化学习》是强化学习领域经典的中文视频之一。李老师幽默风趣的上课风格让晦涩难懂的强化学习理论变得轻松易懂,他会通过很多有趣的例子来讲解强化学习理论。比如老师经常会用玩 Atari 游戏的例子来讲解强化学习算法。此外,为了教程的完整性,我们整理了周博磊老师的《强化学习纲要》、李科浇老师的《世界冠军带你从零实践强化学习》以及多个强化学习的经典资料作为补充。对于想入门强化学习又想看中文讲解的人来说绝对是非常推荐的。

本教程也称为“蘑菇书”,寓意是希望此书能够为读者注入活力,让读者“吃”下这本蘑菇之后,能够饶有兴致地探索强化学习,像马里奥那样愈加强大,继而在人工智能领域觅得意外的收获。
https://github.com/datawhalechina/easy-rl?tab=readme-ov-file


posted @ 2025-04-30 14:15 paulwong 阅读(32) | 评论 (0)编辑 收藏

足球数据资源

足球基础数据
https://www.nami.com/details/4nw10i0tela68lq#interface

足球统计数据
https://www.nami.com/details/7xwk3iqtv3s9rk6#interface

足球统计数据
https://www.nami.com/details/7xwk3iqtv3s9rk6#interface

足球高阶数据
https://www.nami.com/details/g5wvvikteeixwzd#interface

指数数据
https://www.nami.com/details/o6w9kipt4yi78k3#interface

足球资料库数据
https://www.nami.com/details/7j8gxi0to7inrql#interface

Marz火星数据(体育)
https://www.kancloud.cn/marz/marz-sport/3098904



posted @ 2025-04-24 14:56 paulwong 阅读(69) | 评论 (0)编辑 收藏

ai预测足球资源

基于机器学习的2022世界杯预测实战
https://www.showmeai.tech/article-detail/400

AI 竞彩赛事 预测工具
https://www.mysports.ai/cn

posted @ 2025-04-19 01:07 paulwong 阅读(37) | 评论 (0)编辑 收藏

微调训练的数据集

使用trl库做微调时, 对数据集的要求是:

如果是多轮对话场景:
jsonl 文件,且需符合以下要求:
1.每行是一个独立的 JSON 对象;
2 每个对象须包含一个键名为 messages 的数组,数组不能为空;
3.messages 中每个元素必须包含 role 和 content 两个字段:
4.role 只能是 system,user 或 assisiant;
5.如果有 system 角色消息, 需在数组首位;
6.第一条非 system 消息必须是 user 角色;
7.user 和 assisiant 角色的消息应当交替、成对出现,不少于1对;

如果是指令微调场景:
jsonl 文件,且需符合以下要求:
1.每行是一个独立的 JSON 对象;
2 每个对象须包含且只能包含一个键名为 text 的键值对,值不能为空;

posted @ 2025-03-21 21:52 paulwong 阅读(75) | 评论 (0)编辑 收藏

大模型训练的几个阶段

大模型开发出来后, 一般要经过以下几个阶段的训练:

预训练(Pre-Trained)

单纯提供文本: {"text":"..."}
训练模型由第一个文字开始, 预测后面的文字, 直到结束.
这种模型只会做完成文本的任务

监督微调(Supervised Fine Turning)

为了使模型能完成根据指令完成回答, 而不是随机生成回答
提供的文本: {"instruction":"...", "output":"..."}

高效参数微调(Parameter Efficient Fine Turning)

只调整部分参数, 具体实现方法有LoRA

参考:
https://github.com/huggingface/smol-course/blob/main/1_instruction_tuning/notebooks/sft_finetuning_example.ipynb



posted @ 2025-03-18 13:14 paulwong 阅读(76) | 评论 (0)编辑 收藏

python资源

python
https://www.w3schools.com/python/

https://www.runoob.com/python/python-basic-syntax.html


posted @ 2025-03-16 20:54 paulwong 阅读(47) | 评论 (0)编辑 收藏

大模型微调后的评估指标

大模型微调后的评估指标是衡量模型性能的关键,通常根据任务类型和具体需求选择不同的评估指标。以下是一些常见的评估指标及其适用场景:


1. 分类任务

  • 准确率(Accuracy):预测正确的样本占总样本的比例。
    • 适用场景:类别分布均衡的任务。
  • 精确率(Precision):预测为正类的样本中,实际为正类的比例。
    • 适用场景:关注减少假阳性(False Positive)的任务。
  • 召回率(Recall):实际为正类的样本中,预测为正类的比例。
    • 适用场景:关注减少假阴性(False Negative)的任务。
  • F1分数(F1 Score):精确率和召回率的调和平均值。
    • 适用场景:类别不平衡或需要平衡精确率和召回率的任务。
  • ROC-AUC:ROC曲线下的面积,衡量模型区分正负类的能力。
    • 适用场景:二分类任务,尤其是类别不平衡的情况。

2. 回归任务

  • 均方误差(MSE, Mean Squared Error):预测值与真实值之差的平方的平均值。
    • 适用场景:对误差较大的样本惩罚更重的任务。
  • 均方根误差(RMSE, Root Mean Squared Error):MSE的平方根。
    • 适用场景:与MSE类似,但更接近原始数据尺度。
  • 平均绝对误差(MAE, Mean Absolute Error):预测值与真实值之差的绝对值的平均值。
    • 适用场景:对异常值不敏感的任务。
  • R²(决定系数):模型解释目标变量方差的比例。
    • 适用场景:评估模型拟合优度。

3. 生成任务

  • BLEU(Bilingual Evaluation Understudy):衡量生成文本与参考文本的n-gram重叠程度。
    • 适用场景:机器翻译、文本生成任务。
  • ROUGE(Recall-Oriented Understudy for Gisting Evaluation):衡量生成文本与参考文本的重叠程度,侧重于召回率。
    • 适用场景:文本摘要、生成任务。
  • METEOR:综合考虑精确率、召回率和词序的评估指标。
    • 适用场景:机器翻译、文本生成任务。
  • Perplexity(困惑度):衡量模型预测概率分布的不确定性。
    • 适用场景:语言模型评估。

4. 多标签任务

  • Hamming Loss:预测错误的标签比例。
    • 适用场景:多标签分类任务。
  • Jaccard Similarity:预测标签与真实标签的交集与并集之比。
    • 适用场景:多标签分类任务。

5. 排序任务

  • NDCG(Normalized Discounted Cumulative Gain):衡量排序结果的相关性。
    • 适用场景:推荐系统、信息检索。
  • MAP(Mean Average Precision):平均精确率的均值。
    • 适用场景:信息检索、推荐系统。

6. 其他指标

  • 训练时间:模型微调所需的时间。
  • 推理速度:模型生成结果的速度。
  • 资源消耗:模型运行所需的计算资源(如GPU内存、CPU使用率)。
  • 鲁棒性:模型对噪声、异常值或对抗样本的抵抗能力。

7. 领域特定指标

  • 医学领域:敏感性(Sensitivity)、特异性(Specificity)、AUC-ROC。
  • 金融领域:收益曲线、夏普比率(Sharpe Ratio)。
  • 计算机视觉:mAP(mean Average Precision)、IoU(Intersection over Union)。

8. 人类评估

  • 人工评分:通过人工评估生成结果的质量(如流畅性、相关性、准确性)。
  • 用户满意度:通过用户反馈评估模型的实际效果。

9. 模型对比

  • 基线对比:与未微调的模型或基线模型进行性能对比。
  • 消融实验:评估微调过程中不同组件(如数据、超参数)对性能的影响。

10. 综合评估

  • 多指标综合:根据任务需求,结合多个指标进行综合评估。
  • 任务特定指标:针对特定任务设计自定义指标。

在实际应用中,选择合适的评估指标需要结合任务目标、数据特点和业务需求,同时注意避免单一指标的局限性。

posted @ 2025-03-12 10:08 paulwong 阅读(302) | 评论 (0)编辑 收藏

LLM全栈框架完整分类清单(预训练+微调+工具链)

https://blog.csdn.net/ViniJack/article/details/145789900



posted @ 2025-03-10 11:29 paulwong 阅读(64) | 评论 (0)编辑 收藏

医疗问诊系统资源

计算机毕业设计Python+Neo4j知识图谱医疗问答系统 大模型
https://baijiahao.baidu.com/s?id=1815574648931972744&wfr=spider&for=pc

QABasedOnMedicaKnowledgeGraph
https://github.com/liuhuanyong/QASystemOnMedicalKG/blob/master/README.md

非结构文字抽取实体与关系的大模型
底座, 百川 https://huggingface.co/baichuan-inc/Baichuan2-13B-Chat/tree/main
底座, llama2 https://huggingface.co/unsloth/llama-2-13b
微调->百川 https://huggingface.co/zjunlp/baichuan2-13b-iepile-lora
微调->llama2 https://huggingface.co/zjunlp/llama2-13b-iepile-lora

SiameseUniNLU通用自然语言理解模型
https://www.modelscope.cn/models/iic/nlp_structbert_siamese-uninlu_chinese-base/summary

数据集
https://huggingface.co/datasets/zjunlp/iepile

各种已经训练好的模型
https://www.modelscope.cn/models?name=zpeng1989&page=1











posted @ 2025-03-08 20:52 paulwong 阅读(56) | 评论 (0)编辑 收藏

使用nlp提取非结构化数据中的信息

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); @import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); 如果要从结构化的数据中提取信息,用sql即可, 即要提取的信息在select 的字段中.

如果要从非结构化的数据中, 如纯文本, 则要靠nlp, 要对文本理解后, 才能提取相应的信息.

https://www.w3cschool.cn/article/99991254.html

文本结构化 with SpaCy 攻略
https://zhuanlan.zhihu.com/p/556163162
https://zhuanlan.zhihu.com/p/557953165
https://zhuanlan.zhihu.com/p/563334531
https://zhuanlan.zhihu.com/p/573743734

使用openspg自动构建医疗知识图谱
https://blog.csdn.net/myboyliu2007/article/details/139654943

posted @ 2025-03-08 11:45 paulwong 阅读(32) | 评论 (0)编辑 收藏

AI案例资源

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
从实践案例介绍大模型应用经验和思考
https://mp.weixin.qq.com/s/hcD0-z9Y4PsrILUgHdqGcQ

LLaMA Factory:微调DeepSeek-R1-Distill-Qwen-7B模型实现新闻标题分类器
https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b

deepseek r1微调模型应用落地案例(医疗法律,PatientSeek)
https://www.bilibili.com/video/BV17zAVevEtw/?spm_id_from=333.788.recommend_more_video.0&vd_source=35b81999db00535703a287d5c98652b1

文本转语音的模型ChatTTS体验极佳,真人般丝滑和流畅,自定义也比较灵活
https://www.bilibili.com/video/BV1oJ4m1u7B8/?spm_id_from=333.1387.upload.video_card.click&vd_source=35b81999db00535703a287d5c98652b1

医疗NLP领域 评测/比赛,数据集,论文和预训练模型资源汇总。
https://github.com/FreedomIntelligence/Medical_NLP

posted @ 2025-02-26 16:01 paulwong 阅读(39) | 评论 (0)编辑 收藏

满血版Deepseek R1全网资源

官网
https://chat.deepseek.com

腾讯, 需下载客户端
https://ima.qq.com

阿里, 需自建对话应用, 有网页版
https://tbox.alipay.com/

askmanyai
https://askmanyai.cn

360纳米搜索, 无网页版, 需自行下载app


posted @ 2025-02-15 23:10 paulwong 阅读(92) | 评论 (0)编辑 收藏

量化资源

GPTQ、GGUF、AWQ 大语言模型量化方法对比(转载) 
https://caovan.com/gptqggufawq-dayuyanmoxinglianghuafangfaduibizhuanzai/.html

posted @ 2025-02-08 23:31 paulwong 阅读(78) | 评论 (0)编辑 收藏

DeepSeek背后的数学:深入研究群体相对策略优化(GRPO)

     摘要: 本博客深入探讨了群体相对策略优化(GRPO)背后的数学,GRPO是推动DeepSeek卓越推理能力的核心强化学习算法。我们将分解GRPO的工作原理、其关键组件,以及为什么它是训练高级大型语言模型(LLM)的改变者。 GRPO的基础 GRPO是什么? 群相对策略优化(GRPO)是一种强化学习(RL)算法,专门用于增强大型语言模型(LLM)的推理能力。与传统的RL方法不同,RL方法严重依赖外部评...  阅读全文

posted @ 2025-02-08 00:13 paulwong 阅读(295) | 评论 (0)编辑 收藏

DeepSeek资源

DeepSeek大模型由于采用了GRPO算法, 大幅降低了显存的需求.

【DeepSeek】复现DeepSeek R1?快来看这个Open R1项目实践指南~
https://blog.csdn.net/qq_38961840/article/details/145388142

!!!实战LLM强化学习——使用GRPO(DeepSeek R1出圈算法)
https://blog.csdn.net/qq_38961840/article/details/145390704

【DeepSeek】一文详解GRPO算法——为什么能减少大模型训练资源?
https://blog.csdn.net/qq_38961840/article/details/145384852

DeepSeek R1系列
https://blog.csdn.net/qq_38961840/category_12885087.html


posted @ 2025-02-02 19:22 paulwong 阅读(100) | 评论 (0)编辑 收藏

不用再找了,这是大模型最全的面试题库

https://blog.csdn.net/m0_59596990/article/details/135200833

posted @ 2025-01-22 07:42 paulwong 阅读(39) | 评论 (0)编辑 收藏

数据集资源

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
https://hyper.ai/cn/datasets


posted @ 2025-01-17 15:52 paulwong 阅读(30) | 评论 (0)编辑 收藏

vllm资源

vllm是一个可以加载大模型, 推理, 量化模型, 以http api的方式暴露服务的框架.

https://docs.vllm.ai/en/latest/getting_started/examples/basic_with_model_default_sampling.html


posted @ 2025-01-17 13:01 paulwong 阅读(73) | 评论 (0)编辑 收藏

AI应用场景

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); @import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
到底AI是虚的还是假的, 在企业中有没实际落地场景, 以下取实际应用场景:

生物公司
使用qwen2:7b训练细胞制备领域的数据集,目标是
1.预测细胞收获量  
2.算细胞存活状态(存活/死亡)
3.预测工艺是否成功
4.可以提前预测细胞的质量是否达标,以便及时采取措施进行调整
5.细胞培养过程中出现大量细胞死亡的情况,模型可以根据实时数据和历史经验,分析可能是培养箱温度失控、培养基成分错误或受到污染等原因导致的,并提供相应的排查建议」

文体旅游
智能旅游系统:
提供目的地介绍、
旅行路线规划、
酒店预订和景
点推荐等服务。

考试改卷
基于大模型,做一个判试卷的应用,能够判断主观题,比如阅读理解,比如历史,地理,政治问答题。
判卷准确率不能低于人工判卷准确率。
即一次考试,一个班50份试卷,判断结果错误不超过5道题。判断效率高于或等于人工。

取过往同学试卷题目, 作答内容, 得分 作一波ocr出数据, 一个科目, 提取所有试卷内容, 最后就是一个科目一个模型, 提取的内容放在文本, csv, json,
基于“bert-base-chinese”这个模型, 进行微调出专用模型即可,  
让大模型成为专业的判卷老师

考试
用扣子打一个智能体,实现不同学员对掌握的知识进行测试,根据测试结果进行打分和二次出题测试



posted @ 2025-01-17 11:23 paulwong 阅读(145) | 评论 (0)编辑 收藏

搭建llamafactory微调、评估、测试和量化环境

0. 配置环境变量
HF_ENDPOINT=https://hf-mirror.com
HF_HOME=/root/autodl-tmp/paul/tools/huggingface

1. 本机安装python 3.10, 并设置软件源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.index-url https://mirrors.huaweicloud.com/repository/pypi/simple

2. 安装miniconda

3. 新建一个环境, 并激活
conda create -n quantization python=3.12

2. 本机安装pytorch2.5.1+cuda12.4
pip3 install torch torchvision torchaudio
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

3. clone llamafactory源码
git clone https://github.com/hiyouga/LLaMA-Factory

4. llamafactory本地安装依赖
pip install -e .
pip install -e .["vllm","gptq"]

5. 启动webui
llamafactory-cli webui

6. 在页面中填入相关参数进行操作

posted @ 2025-01-16 16:54 paulwong 阅读(142) | 评论 (0)编辑 收藏

量化大模型工具

VLLM量化推理
https://llmc-zhcn.readthedocs.io/en/latest/backend/vllm.html#id1

安装此工具前需安装两个包:
sudo apt-get install cmake
sudo apt-get install pkgconfig

配置huggingface镜像地址:
export HF_ENDPOINT=https://hf-mirror.com

下载代码库, 并安装python依赖
git clone https://github.com/ModelTC/llmc.git
cd llmc/
pip install -r requirements.txt

找到量化方法的配置文件, 并作修改
base:
    seed: &seed 42
model:
    type: Llama
    path: /home/paul/.cache/huggingface/models/models--unsloth--llama-3-8b-Instruct-lawdata
    torch_dtype: auto
quant:
    method: RTN
    weight:
        bit: 8
        symmetric: True
        granularity: per_group
        group_size: 128
        need_pack: True
eval:
    eval_pos: [fake_quant]
    name: wikitext2
    download: True
    path: /home/paul/paulwong/work/workspaces/llmc/dataset
    bs: 1
    seq_len: 2048
    inference_per_block: False
save:
    save_vllm: True
    save_path: /home/paul/.cache/huggingface/models/models--unsloth--llama-3-8b-Instruct-lawdata-quantization

找到run_llmc.sh, 并作修改
#!/bin/bash

# export CUDA_VISIBLE_DEVICES=0,1

llmc=/home/paul/paulwong/work/workspaces/llmc
export PYTHONPATH=$llmc:$PYTHONPATH

# task_name=awq_w_only
# config=${llmc}/configs/quantization/methods/Awq/awq_w_only.yml
task_name=rtn_for_vllm
config=${llmc}/configs/quantization/backend/vllm/rtn_w8a16.yml

nnodes=1
nproc_per_node=1


find_unused_port() {
    while true; do
        port=$(shuf -i 10000-60000 -n 1)
        if ! ss -tuln | grep -q ":$port "; then
            echo "$port"
            return 0
        fi
    done
}
UNUSED_PORT=$(find_unused_port)


MASTER_ADDR=127.0.0.1
MASTER_PORT=$UNUSED_PORT
task_id=$UNUSED_PORT

nohup \
torchrun \
--nnodes $nnodes \
--nproc_per_node $nproc_per_node \
--rdzv_id $task_id \
--rdzv_backend c10d \
--rdzv_endpoint $MASTER_ADDR:$MASTER_PORT \
${llmc}/llmc/__main__.py --config $config --task_id $task_id \
> ${task_name}.log 2>&1 &

sleep 2
ps aux | grep '__main__.py' | grep $task_id | awk '{print $2}' > ${task_name}.pid

# You can kill this program by 
# xargs kill -9 < xxx.pid
# xxx.pid is ${task_name}.pid file

执行量化操作
bash scripts/run_llmc.sh




posted @ 2025-01-15 18:00 paulwong 阅读(91) | 评论 (0)编辑 收藏

微调资源

Fine-tune Llama 3.1 Ultra-Efficiently with Unsloth
https://huggingface.co/blog/mlabonne/sft-llama3

A beginners guide to fine tuning LLM using LoRA
https://zohaib.me/a-beginners-guide-to-fine-tuning-llm-using-lora/

【Day 23】調教你的 AI 寵物:用微調讓 LLM 乖乖聽話
https://ithelp.ithome.com.tw/articles/10346441


posted @ 2025-01-15 17:56 paulwong 阅读(71) | 评论 (0)编辑 收藏

安装docker版的Nvidia container toolkit

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation

posted @ 2025-01-13 14:20 paulwong 阅读(50) | 评论 (0)编辑 收藏

开源镜像库

华为:
https://mirrors.huaweicloud.com/home
https://mirrors.huaweicloud.com/artifactory/pypi-public/simple/torch/

清华:
https://mirrors.tuna.tsinghua.edu.cn
点击问号进详情

docker:
https://mirrors.huaweicloud.com/mirrorDetail/5ea14d84b58d16ef329c5c13?mirrorName=docker-ce&catalog=docker

posted @ 2025-01-13 10:32 paulwong 阅读(90) | 评论 (0)编辑 收藏

windows中添加端口转发规则

设置端口转发

在 Windows 上,以管理员身份打开 PowerShell,
netsh interface portproxy add v4tov4 listenport=7860 listenaddress=0.0.0.0 connectport=7860 connectaddress=123.45.67.89

在 PowerShell 中使用 netsh interface portproxy 命令设置的端口转发规则是持久性的。这些规则会在系统重启后继续生效,因为它们被存储在 Windows 的注册表中。

删除端口转发规则

如果想删除之前设置的端口转发规则,可以使用以下命令:
netsh interface portproxy delete v4tov4 listenport=7860 listenaddress=0.0.0.0

这里的 listenport 和 listenaddress 应与之前设置时的值一致。

查看当前的端口转发规则

要查看当前系统中所有的端口转发规则,可以运行:
netsh interface portproxy show all


posted @ 2025-01-13 09:34 paulwong 阅读(138) | 评论 (0)编辑 收藏

AI微调框架axolotl安装

1. N卡驱动和toolkit安装
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=runfile_local
 
2. python和mini-conda安装
基本是要下载安装包安装,
python下载地址:https://repo.huaweicloud.com/python/3.12.8/
m
ini-conda下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/
co
nda清华资源:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/


3. 新建一个conda环境
conda create -n axolotl python=3.12

4. cuda版本的pytorch安装
https://download.pytorch.org/whl/cu124/torch-2.5.0%2Bcu124-cp311-cp311-linux_x86_64.whl#sha256=5e3f4a7ba812517c2c1659857b5195f287a288fbd050a5abf9311e03dbe1a28b
如想安装其他版本, 可从以下网址查找:
https://download.pytorch.org/whl/torch

5. git clone https://github.com/axolotl-ai-cloud/axolotl, cd到根目录, 运行
pip3 install --no-build-isolation axolotl[flash-attn,deepspeed]





posted @ 2025-01-12 16:37 paulwong 阅读(63) | 评论 (0)编辑 收藏

内网穿透工具

将内网, 如家庭中的使用wifi建立的网站, 发布到外网, 而无需使用服务器.

https://i.cpolar.com/m/5jN0

reference:
https://www.cpolar.com/blog/cpolar-quick-start-tutorial-ubuntu-series

posted @ 2025-01-12 11:54 paulwong 阅读(158) | 评论 (0)编辑 收藏

安装cuda版本的pytorch

先下载cuda版本的pytorch的整个打包文件:
https://download.pytorch.org/whl/cu124/torch-2.5.1%2Bcu124-cp312-cp312-linux_x86_64.whl#sha256=bf6484bfe5bc4f92a4a1a1bf553041505e19a911f717065330eb061afe0e14d7
https://mirrors.huaweicloud.com/artifactory/pypi-public/simple/torch/


pip install torch-2.5.1+cu124-cp312-cp312-linux_x86_64.whl

验证:
#python
import torch
torch.__version__

posted @ 2025-01-12 11:05 paulwong 阅读(75) | 评论 (0)编辑 收藏

mac使用vscode远程连接win11下的wsl2的方法

1.首先给win11的ssh开一个新端口.(修改C:\ProgramData\ssh\sshd_config即可)

2.win11设置防火墙,开放1中添加的端口.

3.win11进入wsl2,输入ifconfig,查看ip地址(输出信息第二行 inet后面那一串数字).

4.在win11的cmd中输入以下命令:
netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=<步骤1中开放的端口> connectaddress=<步骤3中得到的ip地址> connectport=22


5. ssh连接步骤1中开放的端口就可以连接上wsl2(注意事项:(1)连接时,win11上需要有一个wsl窗口,不然连不上,(2)ssh连接时的用户名写wsl2中的用户名,密码写wsl2中的密码,ip地址写win11的ip地址)

https://www.zhihu.com/question/618935377

posted @ 2025-01-11 09:59 paulwong 阅读(52) | 评论 (0)编辑 收藏

WSL资源

谁来救救被WSL占用的磁盘空间
https://zhuanlan.zhihu.com/p/641436638

利用 VsCode Tunnel 在 Mac 上远程开发
https://juejin.cn/post/7334167506319327283

用 WSL2 搭建 Windows 上更爽的前端开发环境
https://www.bilibili.com/video/BV1BV4y1Z7v4/?vd_source=35b81999db00535703a287d5c98652b1

posted @ 2025-01-11 09:57 paulwong 阅读(34) | 评论 (0)编辑 收藏

GitHub无法访问的办法

浏览器打开https://www.ipaddress.com/website/www.github.com/, 输入www.github.com, 得到相应的ip, 本地clone以ip的方式, 但如果要访问页面, 需改本地的hosts文件:

# /etc/hosts
140.82.112.4    www.github.com




posted @ 2025-01-05 12:08 paulwong 阅读(82) | 评论 (0)编辑 收藏

linux删除多余的旧内核

linux每次升级后都会留下多余的内核, 一键删除的方法(Centos):@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

dnf remove $(dnf repoquery --installonly --latest-limit=-2)


posted @ 2025-01-05 12:01 paulwong 阅读(33) | 评论 (0)编辑 收藏

AI入门

数据分析:从一堆已知的数据中进行分类,总结得出统计数据,如最大 值,最小值,平均值,总和等。
只能对已知数据进行操作,无法预测出新的数据的特征,于是就有了机器学习。

 

机器学习:给出一堆已知的,有特征栏位的和结果栏位的数据,选定一个算法,如线性回归,逻辑回归等,其实就是一条公式,进行学习,其实就是运行一堆函数,比较结果,得出规律,也就是确定了公式中参数的值。当输入新的数据时,就能预测出所需的结果,其实就是把输入数据代入公式,算出结果。
机器学习只能做比较简单的任务,如预测下个月的销售数据,判断文字内容是正面还是反面(分类),对于复杂的任务,如对话,其实就是针对输入文字预测靠谱的输出文字(回答),于是就有了深度学习。

 

深度学习:给出一堆数据,只需两个本栏位,如问题,答案等,选定一个算法,其实就是神经网络的类型,如卷积神经网络(CNN),循环神经网络(RNN),TRANSFORMER神经网络等,进行学习,其实就是运行一堆函数,比较结果,得出规律,也就是确定了公式中参数的值。

posted @ 2024-10-19 22:37 paulwong 阅读(102) | 评论 (0)编辑 收藏

国内网络环境安装docker+container toolkit

操作系统为centos 9.

先安装驱动程序

https://www.nvidia.cn/drivers/lookup/ 中查找对应的驱动程序下载到本地,再运行
#切换成文字界面
sudo systemctl set-default multi-user.target
sudo reboot

sh NVIDIA
-Linux-x86_64-550.107.02.run

#切换成图形界面
sudo systemctl set-default graphical.target
sudo reboot

安装docker:

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
sed -i 's+https://download.docker.com+https://mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo

yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

sudo nvidia-ctk runtime configure --runtime=docker

改镜像地址:

[paul@paul-pc ~]$ cat /etc/docker/daemon.json
{  
    
"registry-mirrors"[
        "http://xxx.xxx.xxx"
    ]
,
    
"runtimes": {
        
"nvidia": {
            
"args"[],
            
"path""nvidia-container-runtime"
        }
    }
}

安装container-took-kit:

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Rocky&target_version=9&target_type=runfile_local 中找到对应的container-took-kit,下载到本地,再运行
sh cuda_12.6.0_560.28.03_linux.run

验证:

sudo docker run --rm -it --gpus all ubuntu  nvidia-smi
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.107.02             Driver Version: 550.107.02     CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| 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  NVIDIA GeForce RTX 2080 Ti     Off |   00000000:01:00.0  On |                  N/A |
| 62%   36C    P8              4W /  260W |     256MiB /  22528MiB |      1%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  NVIDIA GeForce RTX 2080 Ti     Off |   00000000:02:00.0 Off |                  N/A |
| 64%   35C    P8              5W /  260W |       9MiB /  22528MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      2657      G   /usr/libexec/Xorg                              99MiB |
|    0   N/A  N/A      2735      G   /usr/bin/gnome-shell                           38MiB |
|    0   N/A  N/A      3502      G   /usr/lib64/firefox/firefox                    111MiB |
|    1   N/A  N/A      2657      G   /usr/libexec/Xorg                               4MiB |
+-----------------------------------------------------------------------------------------+
参考地址:
https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

posted @ 2024-08-15 10:49 paulwong 阅读(152) | 评论 (0)编辑 收藏

python界面库

python服务器脚本,生成html,无需写js,css,适合AI项目
https://cheat-sheet.streamlit.app

生成文字的代码:
st.text('Fixed width text')
st.markdown('_Markdown_'# see #*
st.caption('Balloons. Hundreds of them')
st.latex(r''' e^{i\pi} + 1 = 0 ''')
st.write('Most objects'# df, err, func, keras!
st.write(['st''is <', 3]) # see *
st.title('My title')
st.header('My header')
st.subheader('My sub')
st.code('for i in range(8): foo()')

# * optional kwarg unsafe_allow_html = True

生成form控件:
st.button('Hit me')
st.data_editor('Edit data', data)
st.checkbox('Check me out')
st.radio('Pick one:', ['nose','ear'])
st.selectbox('Select', [1,2,3])
st.multiselect('Multiselect', [1,2,3])
st.slider('Slide me', min_value=0, max_value=10)
st.select_slider('Slide to select', options=[1,'2'])
st.text_input('Enter some text')
st.number_input('Enter a number')
st.text_area('Area for textual entry')
st.date_input('Date input')
st.time_input('Time entry')
st.file_uploader('File uploader')
st.download_button('On the dl', data)
st.camera_input("一二三,茄子!")
st.color_picker('Pick a color')

用表格显示数据:
st.dataframe(my_dataframe)
st.table(data.iloc[0:10])
st.json({'foo':'bar','fu':'ba'})
st.metric(label="Temp", value="273 K", delta="1.2 K")


显示加载进度条与状态:
# Show a spinner during a process
>>> with st.spinner(text='In progress'):
>>>   time.sleep(3)
>>>   st.success('Done')

# Show and update progress bar
>>> bar = st.progress(50)
>>> time.sleep(3)
>>> bar.progress(100)

st.balloons()
st.snow()
st.toast('Mr Stay-Puft')
st.error('Error message')
st.warning('Warning message')
st.info('Info message')
st.success('Success message')
st.exception(e)


posted @ 2024-08-12 15:19 paulwong 阅读(92) | 评论 (0)编辑 收藏

通过SSH的方式PUSH代码到GIT

这几天要PUSH代码到GITHUB,发现之前用的密码方式被取消了,需改成SSH KEY的方式。

1.生成SSH-KEY

ssh-keygen
#会产生 
~/.ssh/id_rsa 和 ~/.ssh/id_rsa_pub 文件
#如果是从别的地方拷贝过来的id_rsa,需chmod 400 ~/.ssh/id_rsa更改属性

2.在github上新建仓库

https://github.com/paulwong888/python-ai

3.导入公钥到github

打开你的SSH公钥文件,通常位于~/.ssh/id_rsa.pub。复制公钥内容,然后登录到你的GitHub账户,进入Settings > SSH and GPG keys,点击"New SSH key"按钮,粘贴你的公钥,然后点击"Add SSH key"。

4.克隆仓库

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
git clone git@github.com:paulwong888/python-ai

5.导入project到eclipse

上步克隆时已经在本地新建了一个本地仓库,Import->Git->Project from Git->Existing local repository,选择python-ai/.git文件夹
之后的操作和用密码的方式是一样的。

如果是vs code的操作,可参考:https://juejin.cn/post/6993612656410099719

posted @ 2024-07-24 12:31 paulwong 阅读(136) | 评论 (0)编辑 收藏

微调llama3大模型(2) - 使用ollama搭建chatbot

上篇已经合并出了训练好的大模型,现在要搭建起一套CHATBOT,使得这套大模型能有一个WEBUI用起来。

1.设置环境变量,ollama的模型保存路径,/etc/profile

export OLLAMA_MODELS=/root/autodl-tmp/models/ollama

2.克隆ollama代码

curl -fsSL https://ollama.com/install.sh | sh

3.启动ollama

ollama serve

4.建立ollama镜像的配置文件,Modelfile

# set the base model
FROM /root/.ollama/llamafactory-export/saves/llama3-8b/lora/docker-commnad-nlp/export

# set custom parameter values
PARAMETER temperature 
1
PARAMETER num_keep 
24
PARAMETER stop <|start_header_id|>
PARAMETER stop <|end_header_id|>
PARAMETER stop <|eot_id|>
PARAMETER stop <|reserved_special_token

# set the model template
TEMPLATE 
"""
{{ if .System }}<|start_header_id|>system<|end_header_id|>
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
{{ .Response }}<|eot_id|>
"""

# set the system message
SYSTEM You are llama3 from Meta
, customized and hosted @ Paul Wong (http://paulwong88.tpddns.cn).

# set Chinese lora support
#ADAPTER /root/.ollama/models/lora/ggml-adapter-model.bin
建立镜像命令,create-ollama-image-docker-command-nlp.sh
BIN_PATH=$(cd `dirname $0`; pwd)
cd $BIN_PATH/
pwd
ollama create llama3-docker-commnad-nlp:paul -f Modelfile

5.运行大模型

llama3-docker-commnad-nlp:paul

posted @ 2024-07-08 19:48 paulwong 阅读(123) | 评论 (0)编辑 收藏

微调llama3大模型(1) - 使用Llama Factory微调llama3大模型

对于象META的开源大模型,如llama3,由于都是用通用数据进行预训练,对想使用其模型的公司来说,可能会不适用,因为这大模型对公司的数据不熟悉,因此引入微调(Fine-Tunning)。
通过喂给大模型大量数据,1万条起步,使得大模型也能对公司的数据熟悉,进而用于各种对话场景。

1.克隆并安装LLAMA FACTORY库,install-llamafactory.sh

BIN_PATH=$(cd `dirname $0`; pwd)
cd $BIN_PATH/../
pwd
git clone --depth 
1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
pip install -e 
".[torch,metrics,bitsandbytes,modelscope]"

2.设置环境变量

export USE_MODELSCOPE_HUB=1 #使用modelscop模型库,非huggingface的
export CUDA_VISIBLE_DEVICES
=0 #设置使用GPU
export HF_ENDPOINT
=https://hf-mirror.com #设置huggingface的替代地址
export MODELSCOPE_CACHE
=/root/autodl-tmp/models/modelscope #设置modelscope中的大模型保存路径
export LLAMAFACTORY_HOME=/root/autodl-tmp/LLaMA-Factory

3.准备数据

#在data/dataset_info.json中加入此数据

"docker_command_NL": {
    
"hf_hub_url""MattCoddity/dockerNLcommands"
  }
,
在data目录中加入训练数据,MattCoddity/dockerNLcommands.json
数据格式为:
[
  {
    
"input""Give me a list of containers that have the Ubuntu image as their ancestor.",
    
"instruction""translate this sentence in docker command",
    
"output""docker ps --filter 'ancestor=ubuntu'"
  }
,

]

4.训练大模型

训练的参数文件:llama3_lora_sft_docker_command.yaml
### model
#md model id
model_name_or_path: LLM-Research/Meta-Llama-
3-8B-Instruct
#huggingface model id
#model_name_or_path: meta-llama/Meta-Llama-
3-8B-Instruct

### method
stage: sft
do_train: true
finetuning_type: lora
lora_target: all

### dataset
dataset: docker_command_NL
template: llama3
cutoff_len: 
1024
max_samples: 
1000
overwrite_cache: true
preprocessing_num_workers: 
16

### output
output_dir: /root/autodl-tmp/my-test/saves/llama3-8b/lora/sft/docker-commnad-nlp/sft
logging_steps: 
10
save_steps: 
500
plot_loss: true
overwrite_output_dir: true

### train
per_device_train_batch_size: 
4
gradient_accumulation_steps: 
8
learning_rate: 
1.0e-4
num_train_epochs: 
3.0
lr_scheduler_type: cosine
warmup_ratio: 
0.1
bf16: true
ddp_timeout: 
180000000

### eval
val_size: 
0.1
per_device_eval_batch_size: 
1
eval_strategy: steps
eval_steps: 
500
训练命令:lora-train-docker-command.sh
BIN_PATH=$(cd `dirname $0`; pwd)
cd $BIN_PATH/
pwd
cd $LLAMAFACTORY_HOME
pwd
llamafactory-cli train $BIN_PATH/conf/llama3_lora_sft_docker_command.yaml
执行此命令即可开始训练大模型。

5.合并大模型

合并用的参数文件,llama3_lora_export_docker_command.yaml
### model
#md model id
model_name_or_path: LLM-Research/Meta-Llama-
3-8B-Instruct
#huggingface model id
#model_name_or_path: meta-llama/Meta-Llama-
3-8B-Instruct

adapter_name_or_path: /root/autodl-tmp/my-test/saves/llama3-8b/lora/docker-commnad-nlp/sft
template: llama3
export_dir: /root/autodl-tmp/my-test/saves/llama3-8b/lora/docker-commnad-nlp/export
finetuning_type: lora
export_size: 
2
export_device: gpu
export_legacy_format: False
合并命令,lora-export-docker-command.sh
BIN_PATH=$(cd `dirname $0`; pwd)
cd $BIN_PATH/
pwd
llamafactory-cli export conf/llama3_lora_export_docker_command.yaml

posted @ 2024-07-08 18:44 paulwong 阅读(132) | 评论 (0)编辑 收藏