pip设置阿里云源

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

一条命令即可

发表在 None | 留下评论

comfyui安装ComfyUI-Manager easy_use

安装ComfyUI-Manger

  1. 到 ComfyUI/custom_nodes 目录(CMD 命令行下)
  2. git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager (执行)
  3. 重启 ComfyUI

通过Manger搜索easy use 安装即可(方法一)


安装easy use(方法二)不需要comfyui-manager

到 ComfyUI/custom_nodes 目录(CMD 命令行下)

到 ComfyUI/custom_nodes目录(CMD 命令行下)git clone https://github.com/yolain/ComfyUI-Easy-Use.git
cd ComfyUI-Easy-Use
pip install -r requirements.txt

安装easy use(方法三 )不需要comfyui-manager

到 ComfyUI/custom_nodes目录(CMD 命令行下)git clone 
git clone https://github.com/yolain/ComfyUI-Easy-Use
#2. 安装依赖
双击install.bat安装依赖
发表在 None | 留下评论

thinkphp 拷贝一条数据重新插入表

use \app\model\Staff;   // 模型类

// 1. 取出原记录
$old = Staff::find($id)->toArray();   // 也可以用 get()

// 2. 去掉主键(自增id)
unset($old['id']);

// 3. 插入新记录
$newId = Staff::insertGetId($old);    // 返回新的主键值
发表在 None | 留下评论

Unsolth安装 微调 lora Qlora

https://unsloth.ai


如何运行 Unsloth

1. 安装环境

Conda 安装

conda create --name unsloth_env \
    python=3.11 \
    pytorch-cuda=12.1 \
    pytorch cudatoolkit xformers -c pytorch -c nvidia -c xformers \
    -y
conda activate unsloth_env

pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps trl peft accelerate bitsandbytes

Pip 安装

pip install --upgrade pip
pip install "unsloth[cu121-torch240] @ git+https://github.com/unslothai/unsloth.git"

使用教程

unsloth的使用非常简单,主要分为以下几个步骤:

  1. 导入必要的库:
from unsloth import FastLanguageModel
from unsloth import is_bfloat16_supported
import torch
from trl import SFTTrainer
from transformers import TrainingArgumentsrom datasets import load_dataset
  1. 加载预训练模型:
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "unsloth/llama-3-8b-bnb-4bit",
    max_seq_length = 2048,
    dtype = None,
    load_in_4bit = True,
)
  1. 应用LoRA进行微调:
model = FastLanguageModel.get_peft_model(
    model,
    r = 16,
    target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
                      "gate_proj", "up_proj", "down_proj",],
    lora_alpha = 16,
    lora_dropout = 0,
    bias = "none",    
    use_gradient_checkpointing = "unsloth",
    random_state = 3407,
    max_seq_length = 2048,
)
  1. 开始训练:
trainer = SFTTrainer(
    model = model,
    train_dataset = dataset,
    dataset_text_field = "text",
    max_seq_length = 2048,
    tokenizer = tokenizer,
    args = TrainingArguments(
        per_device_train_batch_size = 2,
        gradient_accumulation_steps = 4,
        warmup_steps = 10,
        max_steps = 60,
        fp16 = not is_bfloat16_supported(),
        bf16 = is_bfloat16_supported(),
        logging_steps = 1,
        output_dir = "outputs",
        optim = "adamw_8bit",
        seed = 3407,
    ),
)
trainer.train()
发表在 None | 留下评论

Tinkphp success error AJAX返回 code 1 0

 return $this->success("ok",null,['id'=>$info]);

AJAX

{
"code":1,
"msg":"ok",
"data":{"id":"9"},
"url":"http:\/\/test.acfun.org.cn\/portal\/money\/get_id.html?id=69",
"wait":3}
发表在 None | 留下评论