分类目录归档: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安装依赖

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()

thinkphp 关联查询 with

范例

$info=LeaseModel::with(
            [
                "fapiao"=>function($query) use($time_start,$time_end,$is_created,$is_done,$is_print){
                    $query->where('time_start','>=',$time_start);
                    $query->where('time_end','<=',$time_end);
                    if($is_done>0){
                        $query->where('is_done','>',$is_done);
                    }elseif($is_done==='0'){
                        $query->where('is_done','=',$is_done);
                    }
                    if($is_created>0){
                        $query->where('is_created','>',$is_created);
                    }elseif($is_created==='0'){
                        $query->where('is_created','=',$is_created);
                    }
                    if($is_print>0){
                        $query->where('is_print','>',$is_print);
                    }elseif($is_print==='0'){
                        $query->where('is_print','=',$is_print);
                    }
                },"lease_contract","lease_contract.ca","lease_contract.cb","lease_contract.cc","lease_contract.cd","propertyone","propertyone.property"
            ])->alias("a")
            ->join("lease_contract b","a.lease_id=b.id")
            ->join("property_one c","a.po_id=c.id")
            ->where($where)
            ->leftJoin("co name_a","name_a.id=b.a")
            ->leftJoin("co name_b","name_b.id=b.b")
            ->leftJoin("co name_c","name_c.id=b.c")
            ->leftJoin("co name_d","name_d.id=b.d")
            ->where($where)
            ->whereNull("b.delete_time")
            ->whereNull("c.delete_time")
            ->whereNull("name_a.delete_time")
            ->whereNull("name_b.delete_time")
            ->whereNull("name_c.delete_time")
            ->whereNull("name_d.delete_time")
            ->field("a.*")
            ->select();

多重调用 ,with多级关联 ,join ,

其中fields(a.*) 因为有表格join时候和本表中有键值冲突所以中使用 a.* 反正都用了关联模型