@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://www.aygfsteel.com/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”這個模型, 進行微調出專用模型即可,
讓大模型成為專業的判卷老師
考試
用扣子打一個智能體,實現不同學員對掌握的知識進行測試,根據測試結果進行打分和二次出題測試
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 .["vllm","gptq"]
5. 啟動webui
6. 在頁面中填入相關參數進行操作
VLLM量化推理
安裝此工具前需安裝兩個包:
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
執行量化操作
Fine-tune Llama 3.1 Ultra-Efficiently with Unsloth
A beginners guide to fine tuning LLM using LoRA
【Day 23】調教你的 AI 寵物:用微調讓 LLM 乖乖聽話
設置端口轉發
在 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
1. N卡驅動和toolkit安裝
pip3 install --no-build-isolation axolotl[flash-attn,deepspeed]
將內網, 如家庭中的使用wifi建立的網站, 發布到外網, 而無需使用服務器.
reference:
先下載cuda版本的pytorch的整個打包文件:
pip install torch-2.5.1+cu124-cp312-cp312-linux_x86_64.whl
驗證:
#python
import torch
torch.__version__