当前位置: 首页 > news >正文

Ubuntu2204下使用NVIDIA GeForce RTX 4090进行DeepSeek-R1-Distill-Llama-8B模型微调

Ubuntu2204下使用NVIDIA GeForce RTX 4090进行DeepSeek-R1-Distill-Llama-8B模型微调

  • 环境准备
    • 创建Python微调环境
    • 准备数据集
    • 准备模型文件
  • 模型微调
  • 模型预测
    • 原始模型预测
    • 微调模型预测

使用unsloth,可以方便地对大模型进行微调。以微调DeepSeek-R1-Distill-Llama-8B为例:

  • 微调过程中,大概需要9G以上的显存,即可正常工作。
  • 训练时间与训练的参数per_device_train_batch_sizemax_steps有关。当per_device_train_batch_size为2时,使用RTX 4090训练一次大概需要3秒,训练600次,大概用于30分钟。训练10000次,大概需要8个小时。
  • 训练的loss初步测试,在训练8小时后,由最初的2.3左右,下降在1.1左右。24小时的训练损失,还在测试中。
  • 下面文章中进行的验证,只是训练600次后的结果。
原模型输出结果微调模型输出结果
根据病人的症状和检查结果,建议采取以下步骤:\n\n1. 进一步诊断:进行腹部超声检查以明确包块的性质,确认是否为脓肿、肝炎或其他结构。\n2. 实验室检查:包括血常规、C反应蛋白、结核菌素试验、血培养和肝肾功能测试,以评估感染情况。\n3. 抗生素治疗:根据实验室结果,选择敏感的抗生素开始治疗,覆盖可能的菌落。\n4. 影像学引流:如果确诊为脓肿,考虑腹腔镜下引流或外科手术。\n5. 综合治疗:结合抗生素治疗和支持治疗,如营养补充和疼痛管理。\n6. 监测与随访:定期复查,监测病情进展,评估治疗效果。根据病人的症状和体检结果,虽然右下腹存在压痛的包块,但目前病人的症状还没有完全稳定,腹痛仅有轻微减轻,仍然有发热。这种情况下,通常不需要立即进行手术治疗。通常,急性阑尾炎可以通过观察、药物治疗和营养支持来缓解症状。然而,包块的存在可能提示炎症已经发展到一定程度,需要密切监测。\n\n在这种情况下,建议继续使用抗生素和止痛药,以缓解症状,并密切观察病情的变化。如果病情进一步恶化,比如包块增大、腹痛加重或伴随发热不退、呕吐、发黄等症状,可能需要考虑进一步的处理,包括影像学检查或手术。\n\n总之,目前的处理策略是继续观察和治疗,同时密切监测病情变化,以便及时调整治疗方案。希望病人能够尽快恢复健康。<|end▁of▁sentence|>

训练10000次的损失情况。

在这里插入图片描述

下面内容为微调过程的笔记整理。

环境准备

创建Python微调环境

创建一个Python虚拟环境,并激活环境。

conda create -n unsloth_sft python=3.10
conda activate unsloth_sft

创建一个requirements文件

(unsloth) ubuntu@ubuntu-server:~/train$ cat requirements.txt 
accelerate==1.3.0
aiohappyeyeballs==2.4.6
aiohttp==3.11.12
aiohttp-cors==0.7.0
aiosignal==1.3.2
airportsdata==20241001
annotated-types==0.7.0
anyio==4.8.0
astor==0.8.1
async-timeout==5.0.1
attrs==25.1.0
bitsandbytes==0.45.2
blake3==1.0.4
cachetools==5.5.1
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
cloudpickle==3.1.1
colorful==0.5.6
compressed-tensors==0.9.1
cut-cross-entropy==25.1.1
datasets==3.2.0
depyf==0.18.0
dill==0.3.8
diskcache==5.6.3
distlib==0.3.9
distro==1.9.0
docstring_parser==0.16
einops==0.8.1
exceptiongroup==1.2.2
fastapi==0.115.8
filelock==3.17.0
frozenlist==1.5.0
fsspec==2024.9.0
gguf==0.10.0
google-api-core==2.24.1
google-auth==2.38.0
googleapis-common-protos==1.67.0rc1
grpcio==1.70.0
h11==0.14.0
hf_transfer==0.1.9
httpcore==1.0.7
httptools==0.6.4
httpx==0.28.1
huggingface-hub==0.28.1
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.0.0
interegular==0.3.3
Jinja2==3.1.5
jiter==0.8.2
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
lark==1.2.2
lm-format-enforcer==0.10.9
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
mistral_common==1.5.3
modelscope==1.22.3
mpmath==1.3.0
msgpack==1.1.0
msgspec==0.19.0
multidict==6.1.0
multiprocess==0.70.16
nest-asyncio==1.6.0
networkx==3.4.2
numpy==1.26.4
nvidia-cublas-cu12==12.4.5.8
nvidia-cuda-cupti-cu12==12.4.127
nvidia-cuda-nvrtc-cu12==12.4.127
nvidia-cuda-runtime-cu12==12.4.127
nvidia-cudnn-cu12==9.1.0.70
nvidia-cufft-cu12==11.2.1.3
nvidia-curand-cu12==10.3.5.147
nvidia-cusolver-cu12==11.6.1.9
nvidia-cusparse-cu12==12.3.1.170
nvidia-cusparselt-cu12==0.6.2
nvidia-ml-py==12.570.86
nvidia-nccl-cu12==2.21.5
nvidia-nvjitlink-cu12==12.4.127
nvidia-nvtx-cu12==12.4.127
openai==1.61.1
opencensus==0.11.4
opencensus-context==0.1.3
opencv-python-headless==4.11.0.86
outlines==0.1.11
outlines_core==0.1.26
packaging==24.2
pandas==2.2.3
partial-json-parser==0.2.1.1.post5
peft==0.14.0
pillow==11.1.0
pip==25.0
platformdirs==4.3.6
pluggy==1.5.0
prometheus_client==0.21.1
prometheus-fastapi-instrumentator==7.0.2
propcache==0.2.1
proto-plus==1.26.0
protobuf==3.20.3
psutil==6.1.1
py-cpuinfo==9.0.0
py-spy==0.4.0
pyarrow==19.0.0
pyasn1==0.6.1
pyasn1_modules==0.4.1
pybind11==2.13.6
pycountry==24.6.1
pydantic==2.10.6
pydantic_core==2.27.2
Pygments==2.19.1
pytest==8.3.4
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2025.1
PyYAML==6.0.2
pyzmq==26.2.1
ray==2.42.1
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
rich==13.9.4
rpds-py==0.22.3
rsa==4.9
safetensors==0.5.2
sentencepiece==0.2.0
setuptools==75.8.0
shtab==1.7.1
six==1.17.0
smart-open==7.1.0
sniffio==1.3.1
starlette==0.45.3
sympy==1.13.1
tiktoken==0.8.0
tokenizers==0.21.0
tomli==2.2.1
torch==2.5.1
torchaudio==2.5.1
torchvision==0.20.1
tqdm==4.67.1
transformers==4.48.3
triton==3.1.0
trl==0.14.0
typeguard==4.4.1
typing_extensions==4.12.2
tyro==0.9.14
tzdata==2025.1
unsloth==2025.2.4
unsloth_zoo==2025.2.3
urllib3==2.3.0
uvicorn==0.34.0
uvloop==0.21.0
virtualenv==20.29.2
vllm==0.7.2
watchfiles==1.0.4
websockets==14.2
wheel==0.45.1
wrapt==1.17.2
xformers==0.0.28.post3
xgrammar==0.1.11
xxhash==3.5.0
yarl==1.18.3
zipp==3.21.0

安装依赖包

pip install -r requirements.txt

安装后的Python依赖信息

(unsloth_sft) ubuntu@ubuntu-server:~$ pip list
Package                           Version
--------------------------------- -------------
accelerate                        1.3.0
aiohappyeyeballs                  2.4.6
aiohttp                           3.11.12
aiohttp-cors                      0.7.0
aiosignal                         1.3.2
airportsdata                      20241001
annotated-types                   0.7.0
anyio                             4.8.0
astor                             0.8.1
async-timeout                     5.0.1
attrs                             25.1.0
bitsandbytes                      0.45.2
blake3                            1.0.4
cachetools                        5.5.1
certifi                           2025.1.31
charset-normalizer                3.4.1
click                             8.1.8
cloudpickle                       3.1.1
colorful                          0.5.6
compressed-tensors                0.9.1
cut-cross-entropy                 25.1.1
datasets                          3.2.0
depyf                             0.18.0
dill                              0.3.8
diskcache                         5.6.3
distlib                           0.3.9
distro                            1.9.0
docstring_parser                  0.16
einops                            0.8.1
exceptiongroup                    1.2.2
fastapi                           0.115.8
filelock                          3.17.0
frozenlist                        1.5.0
fsspec                            2024.9.0
gguf                              0.10.0
google-api-core                   2.24.1
google-auth                       2.38.0
googleapis-common-protos          1.67.0rc1
grpcio                            1.70.0
h11                               0.14.0
hf_transfer                       0.1.9
httpcore                          1.0.7
httptools                         0.6.4
httpx                             0.28.1
huggingface-hub                   0.28.1
idna                              3.10
importlib_metadata                8.6.1
iniconfig                         2.0.0
interegular                       0.3.3
Jinja2                            3.1.5
jiter                             0.8.2
jsonschema                        4.23.0
jsonschema-specifications         2024.10.1
lark                              1.2.2
lm-format-enforcer                0.10.9
markdown-it-py                    3.0.0
MarkupSafe                        3.0.2
mdurl                             0.1.2
mistral_common                    1.5.3
modelscope                        1.22.3
mpmath                            1.3.0
msgpack                           1.1.0
msgspec                           0.19.0
multidict                         6.1.0
multiprocess                      0.70.16
nest-asyncio                      1.6.0
networkx                          3.4.2
numpy                             1.26.4
nvidia-cublas-cu12                12.4.5.8
nvidia-cuda-cupti-cu12            12.4.127
nvidia-cuda-nvrtc-cu12            12.4.127
nvidia-cuda-runtime-cu12          12.4.127
nvidia-cudnn-cu12                 9.1.0.70
nvidia-cufft-cu12                 11.2.1.3
nvidia-curand-cu12                10.3.5.147
nvidia-cusolver-cu12              11.6.1.9
nvidia-cusparse-cu12              12.3.1.170
nvidia-cusparselt-cu12            0.6.2
nvidia-ml-py                      12.570.86
nvidia-nccl-cu12                  2.21.5
nvidia-nvjitlink-cu12             12.4.127
nvidia-nvtx-cu12                  12.4.127
openai                            1.61.1
opencensus                        0.11.4
opencensus-context                0.1.3
opencv-python-headless            4.11.0.86
outlines                          0.1.11
outlines_core                     0.1.26
packaging                         24.2
pandas                            2.2.3
partial-json-parser               0.2.1.1.post5
peft                              0.14.0
pillow                            11.1.0
pip                               25.0
platformdirs                      4.3.6
pluggy                            1.5.0
prometheus_client                 0.21.1
prometheus-fastapi-instrumentator 7.0.2
propcache                         0.2.1
proto-plus                        1.26.0
protobuf                          3.20.3
psutil                            6.1.1
py-cpuinfo                        9.0.0
py-spy                            0.4.0
pyarrow                           19.0.0
pyasn1                            0.6.1
pyasn1_modules                    0.4.1
pybind11                          2.13.6
pycountry                         24.6.1
pydantic                          2.10.6
pydantic_core                     2.27.2
Pygments                          2.19.1
pytest                            8.3.4
python-dateutil                   2.9.0.post0
python-dotenv                     1.0.1
pytz                              2025.1
PyYAML                            6.0.2
pyzmq                             26.2.1
ray                               2.42.1
referencing                       0.36.2
regex                             2024.11.6
requests                          2.32.3
rich                              13.9.4
rpds-py                           0.22.3
rsa                               4.9
safetensors                       0.5.2
sentencepiece                     0.2.0
setuptools                        75.8.0
shtab                             1.7.1
six                               1.17.0
smart-open                        7.1.0
sniffio                           1.3.1
starlette                         0.45.3
sympy                             1.13.1
tiktoken                          0.8.0
tokenizers                        0.21.0
tomli                             2.2.1
torch                             2.5.1
torchaudio                        2.5.1
torchvision                       0.20.1
tqdm                              4.67.1
transformers                      4.48.3
triton                            3.1.0
trl                               0.14.0
typeguard                         4.4.1
typing_extensions                 4.12.2
tyro                              0.9.14
tzdata                            2025.1
unsloth                           2025.2.4
unsloth_zoo                       2025.2.3
urllib3                           2.3.0
uvicorn                           0.34.0
uvloop                            0.21.0
virtualenv                        20.29.2
vllm                              0.7.2
watchfiles                        1.0.4
websockets                        14.2
wheel                             0.45.1
wrapt                             1.17.2
xformers                          0.0.28.post3
xgrammar                          0.1.11
xxhash                            3.5.0
yarl                              1.18.3
zipp                              3.21.0
(unsloth_sft) ubuntu@ubuntu-server:~$ 

准备数据集

数据集下载地址:

https://modelscope.cn/datasets/FreedomIntelligence/medical-o1-reasoning-SFT/files

下载数据集,可以使用modelscope命令。

安装modelscope软件包

pip install modelscope

使用下面的命令下载数据集。

modelscope download --dataset FreedomIntelligence/medical-o1-reasoning-SFT --local_dir ./medical-o1-reasoning-SFT

下载完成后

(unsloth_sft) ubuntu@ubuntu-server:~/datasets/medical-o1-reasoning-SFT$ pwd
/home/ubuntu/datasets/medical-o1-reasoning-SFT
(unsloth_sft) ubuntu@ubuntu-server:~/datasets/medical-o1-reasoning-SFT$ ll
total 135748
drwxrwxr-x 2 ubuntu ubuntu     4096  2月 12 18:24 ./
drwxrwxr-x 4 ubuntu ubuntu     4096  2月 12 18:22 ../
-rw-rw-r-- 1 ubuntu ubuntu 64814379  2月 12 18:23 medical_o1_sft_Chinese.json
-rw-rw-r-- 1 ubuntu ubuntu 74078226  2月 12 18:23 medical_o1_sft.json
-rw-rw-r-- 1 ubuntu ubuntu    99913  2月 12 18:23 README.md
(unsloth_sft) ubuntu@ubuntu-server:~/datasets/medical-o1-reasoning-SFT$ 

准备模型文件

使用下面的命令,下载模型文件

modelscope download --model unsloth/DeepSeek-R1-Distill-Llama-8B --local_dir .

下载完成后

(unsloth_sft) ubuntu@ubuntu-server:~/model/DeepSeek-R1-Distill-Llama-8B$ pwd
/home/ubuntu/model/DeepSeek-R1-Distill-Llama-8B
(unsloth_sft) ubuntu@ubuntu-server:~/model/DeepSeek-R1-Distill-Llama-8B$ ll -h
total 15G
drwxrwxr-x 3 ubuntu ubuntu 4.0K  2月 12 17:43 ./
drwxrwxr-x 7 ubuntu ubuntu 4.0K  2月 12 16:29 ../
-rw-rw-r-- 1 ubuntu ubuntu  959  2月 12 16:44 config.json
-rw-rw-r-- 1 ubuntu ubuntu   73  2月 12 16:44 configuration.json
-rw-rw-r-- 1 ubuntu ubuntu  236  2月 12 16:44 generation_config.json
-rw-rw-r-- 1 ubuntu ubuntu 4.7G  2月 12 17:05 model-00001-of-00004.safetensors
-rw-rw-r-- 1 ubuntu ubuntu 4.7G  2月 12 17:23 model-00002-of-00004.safetensors
-rw-rw-r-- 1 ubuntu ubuntu 4.6G  2月 12 17:39 model-00003-of-00004.safetensors
-rw-rw-r-- 1 ubuntu ubuntu 1.1G  2月 12 17:43 model-00004-of-00004.safetensors
-rw-rw-r-- 1 ubuntu ubuntu  24K  2月 12 17:43 model.safetensors.index.json
-rw------- 1 ubuntu ubuntu  952  2月 12 17:43 .msc
-rw-rw-r-- 1 ubuntu ubuntu   36  2月 12 17:43 .mv
-rw-rw-r-- 1 ubuntu ubuntu  16K  2月 12 17:43 README.md
-rw-rw-r-- 1 ubuntu ubuntu  483  2月 12 17:43 special_tokens_map.json
drwxrwxr-x 2 ubuntu ubuntu 4.0K  2月 12 17:43 ._____temp/
-rw-rw-r-- 1 ubuntu ubuntu  52K  2月 12 17:43 tokenizer_config.json
-rw-rw-r-- 1 ubuntu ubuntu  17M  2月 12 17:43 tokenizer.json
(unsloth_sft) ubuntu@ubuntu-server:~/model/DeepSeek-R1-Distill-Llama-8B$ 

模型微调

编写模型训练代码train.py

$ cat train.py from datasets import load_dataset, Dataset
from datasets.features.features import Featuresfrom unsloth import FastLanguageModel 
from unsloth import is_bfloat16_supported
import torch
from trl import SFTTrainer
from transformers import TrainingArguments# 数据集路径
dataset_path = "/home/ubuntu/datasets/medical-o1-reasoning-SFT"# 加载本地数据集
dataset = load_dataset(path=dataset_path,data_files=["medical_o1_sft_Chinese.json"],split="train",)print(dataset)# 数据集信息
# Dataset({
#     features: ['Question', 'Complex_CoT', 'Response'],
#     num_rows: 24772
# })# features = dataset.features# print(features)
# print(type(features))# data = dataset[:5]# print(data)# question = dataset.features["Question"]# print(question)prompt_style = """
Below is an instruction that describes a task, paired with an input that provides further context. 
Write a response that appropriately completes the request. 
Before answering, think carefully about the question and create a step-by-step chain of thoughts to ensure a logical and accurate response.### Instruction:
# You are a medical expert with advanced knowledge in clinical reasoning, diagnostics, and treatment planning. Please answer the following medical question. ### Question:
{}### Response:
# <think>{}"""train_prompt_style = """
Below is an instruction that describes a task, paired with an input that provides further context. 
Write a response that appropriately completes the request. 
Before answering, think carefully about the question and create a step-by-step chain of thoughts to ensure a logical and accurate response.### Instruction:
You are a medical expert with advanced knowledge in clinical reasoning, diagnostics, and treatment planning. Please answer the following medical question. ### Question:
{}### Response:
<think>
{}
</think>
{}"""# 定义问题
question = "一个患有急性阑尾炎的病人已经发病5天,腹痛稍有减轻但仍然发热,在体检时发现右下腹有压痛的包块,此时应如何处理?"max_seq_length = 2048
max_lora_rank = 32# 加载模型
model, tokenizer = FastLanguageModel.from_pretrained(model_name = "/home/ubuntu/model/DeepSeek-R1-Distill-Llama-8B",max_seq_length = max_seq_length,dtype = None,load_in_4bit = True,# fast_inference=True,# max_lora_rank=max_lora_rank,# gpu_memory_utilization=0.6,
)# 模型预测
FastLanguageModel.for_inference(model=model)inputs = tokenizer(prompt_style.format(question, ""), return_tensors="pt").to("cuda")outputs = model.generate(input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,max_new_tokens=1300,use_cache=True,
)response = tokenizer.batch_decode(outputs)    print(response[0].split("### Response:")[1])# ########################################################
# (unsloth) (base) ubuntu@ubuntu-server:~/code/unsloth_train$ /home/ubuntu/miniconda3/envs/unsloth/bin/python /home/ubuntu/code/unsloth_train/train.py
# 🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
# 🦥 Unsloth Zoo will now patch everything to make training faster!
# INFO 02-13 09:35:53 __init__.py:190] Automatically detected platform cuda.
# Repo card metadata block was not found. Setting CardData to empty.
# Dataset({
#     features: ['Question', 'Complex_CoT', 'Response'],
#     num_rows: 24772
# })
# ==((====))==  Unsloth 2025.2.4: Fast Llama patching. Transformers: 4.48.3.
#    \\   /|    GPU: NVIDIA GeForce RTX 4090. Max memory: 23.635 GB. Platform: Linux.
# O^O/ \_/ \    Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0
# \        /    Bfloat16 = TRUE. FA [Xformers = 0.0.28.post3. FA2 = False]
#  "-____-"     Free Apache license: http://github.com/unslothai/unsloth
# Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
# Loading checkpoint shards: 100%|██████████████████████████████████████████████████████| 4/4 [00:07<00:00,  1.89s/it]# # <think>
# 嗯,我现在要处理一个急性阑尾炎的病人,他已经发病5天了,腹痛稍微减轻但仍然发热。在体检时发现右下腹有压痛的包块。这是个需要仔细考虑的临床情况。# 首先,急性阑尾炎的常见症状包括发热、腹痛、发热、腹部压痛,尤其是右下腹。包块的出现可能提示着阑炎已经进展,可能形成了腺体或者其他结构的变化。但也有可能是误诊,比如肝炎、肝脓肿、胃肠梗阻等。# 接下来,考虑到病人已经发病5天,腹痛减轻但仍有发热,这可能意味着炎症正在缓解,但并没有完全消失。包块的存在可能提示了局部的炎症变化,但需要进一步的评估。# 我应该考虑进行腹部超声检查,以评估包块的性质。超声可以帮助确定包块是实体还是虚实体,以及是否有积液、腺体或其他结构异常。同时,检查是否有其他器官受累,如肝脏、胆囊等。# 如果超声发现阑尾周围有积液,或者有明显的腺体变化,那么可能需要考虑内镜下引流或手术治疗。但如果包块是虚实体,或者伴随有其他结构异常,可能需要进一步的影像学评估,如CT或者MRI。# 在此同时,药物治疗仍然是主要的治疗手段。抗生素治疗应根据药敏结果选择敏感的药物。如果包块已经形成,可能需要考虑抗生素的选择是否足够覆盖可能的病原体,比如扩谱青霉素、第三代 cephalosporin 或者 fluconazole,如果有怀疑真菌感染的话。# 此外,考虑到病人已经有5天的发热,可能存在感染的延误或并发症,比如感染性休克、多器官功能障碍等,因此需要密切监测患者的生命体征和各项代谢指标,必要时进行支持治疗。# 总结一下,处理步骤应该是:# 1. 进行腹部超声检查,确定包块的性质和周围情况。
# 2. 根据超声结果决定是否需要进一步的影像学检查,如CT或MRI。
# 3. 根据药敏结果选择合适的抗生素,可能需要考虑包块形成的原因,如真菌感染等。
# 4. 监测患者的临床状况,及时调整治疗方案。
# 5. 在必要时,考虑内镜下引流或手术治疗。# 这样可以全面评估病情,制定合适的治疗方案,确保病人的好转。
# </think># 对于一个患有急性阑尾炎的病人,腹痛稍有减轻但仍发热,并在右下腹发现压痛包块,建议的处理步骤如下:# 1. **腹部超声检查**:首先进行腹部超声,以确定包块的性质。检查是否为实体或虚实体,是否有积液、腺体或其他异常结构。# 2. **进一步影像学评估**:如果超声结果显示为实体或有明显结构异常,考虑进行CT或MRI以进一步评估包块的性质和周围组织。# 3. **药物治疗**:根据药敏结果选择敏感的抗生素,如扩谱青霉素、第三代 cephalosporin 或 fluconazole,以覆盖可能的病原体。# 4. **监测病情**:密切观察患者的生命体征和各项代谢指标,及时调整治疗方案,防止并发症如感染性休克等。# 5. **手术或内镜引流**:如果包块伴随腺体变化或其他结构异常,必要时考虑内镜下引流或手术治疗。# 通过以上步骤,可以全面评估病情,制定合适的治疗方案,确保病人的好转。<|end▁of▁sentence|>
# (unsloth) (base) ubuntu@ubuntu-server:~/code/unsloth_train$ 
# ########################################################EOS_TOKEN = tokenizer.eos_token  # Must add EOS_TOKEN# Define a formatting prompts function
def formatting_prompts_func(examples):    inputs = examples["Question"]    cots = examples["Complex_CoT"]    outputs = examples["Response"]    texts = []    for input, cot, output in zip(inputs, cots, outputs):        text = train_prompt_style.format(input, cot, output) + EOS_TOKEN        texts.append(text)    return {        "text": texts,    }dataset = dataset.map(formatting_prompts_func, batched=True)print(dataset)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, # Supports any, but = 0 is optimizedbias = "none",    # Supports any, but = "none" is optimized# [NEW] "unsloth" uses 30% less VRAM, fits 2x larger batch sizes!use_gradient_checkpointing = "unsloth", # True or "unsloth" for very long contextrandom_state = 3407,max_seq_length = max_seq_length,use_rslora = False,  # We support rank stabilized LoRAloftq_config = None, # And LoftQ
)trainer = SFTTrainer(model = model,train_dataset = dataset,dataset_text_field = "text",max_seq_length = max_seq_length,tokenizer = tokenizer,args = TrainingArguments(per_device_train_batch_size = 2,gradient_accumulation_steps = 4,warmup_steps = 10,max_steps = 600,fp16 = not is_bfloat16_supported(),bf16 = is_bfloat16_supported(),logging_steps = 1,output_dir = "outputs",optim = "adamw_8bit",seed = 3407,),
)
trainer.train()trainer.save_model("model_20250226")   

运行程序,开始训练

python train.py

在这里插入图片描述

训练过程中的GPU使用情况

在这里插入图片描述

训练完成后的目录情况

(unsloth_sft) ubuntu@ubuntu-server:~/train$ tree
.
├── model_20250226
│   ├── adapter_config.json
│   ├── adapter_model.safetensors
│   ├── README.md
│   ├── special_tokens_map.json
│   ├── tokenizer_config.json
│   ├── tokenizer.json
│   └── training_args.bin
├── outputs
│   ├── checkpoint-500
│   │   ├── adapter_config.json
│   │   ├── adapter_model.safetensors
│   │   ├── optimizer.pt
│   │   ├── README.md
│   │   ├── rng_state.pth
│   │   ├── scheduler.pt
│   │   ├── special_tokens_map.json
│   │   ├── tokenizer_config.json
│   │   ├── tokenizer.json
│   │   ├── trainer_state.json
│   │   └── training_args.bin
│   └── checkpoint-600
│       ├── adapter_config.json
│       ├── adapter_model.safetensors
│       ├── optimizer.pt
│       ├── README.md
│       ├── rng_state.pth
│       ├── scheduler.pt
│       ├── special_tokens_map.json
│       ├── tokenizer_config.json
│       ├── tokenizer.json
│       ├── trainer_state.json
│       └── training_args.bin
├── requirements.txt
└── train.py4 directories, 31 files
(unsloth_sft) ubuntu@ubuntu-server:~/train$ 

模型预测

原始模型预测

源代码

(unsloth_sft) ubuntu@ubuntu-server:~/train$ cat inference1.py 
from datasets import load_dataset, Dataset
from datasets.features.features import Featuresfrom unsloth import FastLanguageModel 
from unsloth import is_bfloat16_supported
import torch
from trl import SFTTrainer
from transformers import TrainingArgumentsmax_seq_length = 2048
max_lora_rank = 32
question = "一个患有急性阑尾炎的病人已经发病5天,腹痛稍有减轻但仍然发热,在体检时发现右下腹有压痛的包块,此时应如何处理?"prompt_style = """
Below is an instruction that describes a task, paired with an input that provides further context. 
Write a response that appropriately completes the request. 
Before answering, think carefully about the question and create a step-by-step chain of thoughts to ensure a logical and accurate response.### Instruction:
# You are a medical expert with advanced knowledge in clinical reasoning, diagnostics, and treatment planning. Please answer the following medical question. ### Question:
{}### Response:
# <think>{}"""# 加载模型
model, tokenizer = FastLanguageModel.from_pretrained(model_name = "/home/ubuntu/model/DeepSeek-R1-Distill-Llama-8B",max_seq_length = max_seq_length,dtype = None,load_in_4bit = True,# fast_inference=True,# max_lora_rank=max_lora_rank,# gpu_memory_utilization=0.6,
)# 模型预测
FastLanguageModel.for_inference(model=model)inputs = tokenizer(prompt_style.format(question, ""), return_tensors="pt").to("cuda")outputs = model.generate(input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,max_new_tokens=1300,use_cache=True,
)response = tokenizer.batch_decode(outputs)    print(response[0].split("### Response:")[1])(unsloth_sft) ubuntu@ubuntu-server:~/train$ 

预测结果

(unsloth_sft) ubuntu@ubuntu-server:~/train$ python inference1.py 
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
INFO 02-26 20:20:00 __init__.py:190] Automatically detected platform cuda.
==((====))==  Unsloth 2025.2.4: Fast Llama patching. Transformers: 4.48.3.\\   /|    GPU: NVIDIA GeForce RTX 4090. Max memory: 23.635 GB. Platform: Linux.
O^O/ \_/ \    Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0
\        /    Bfloat16 = TRUE. FA [Xformers = 0.0.28.post3. FA2 = False]"-____-"     Free Apache license: http://github.com/unslothai/unsloth
Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████| 4/4 [00:02<00:00,  1.56it/s]# <think>
嗯,我现在要处理一个急性阑尾炎的病人,这个病人已经发病5天了,腹痛稍微减轻但仍然发热。在体检时发现了右下腹有压痛的包块。首先,我得想想急性阑尾炎的常见症状和处理方法。急性阑尾炎通常表现为右下腹部的阵发性疼痛,尤其在饭后或空腹时加重,伴随发热、恶心、呕吐,可能还有腹泻。而且,通常是单侧疼痛,但有时候也可能两侧不明显。这个病人已经有五天的发病时间,腹痛虽然减轻,但仍有发热,这可能意味着炎症正在缓解,但仍未完全恢复。现在,体检发现了右下腹有压痛的包块,这让我有点困惑。急性阑尾炎通常在发病期不明显,或者可能有轻微的触痛,但包块的出现可能意味着炎症已经转移到了某个结构,比如肝或脾,或者是某种并发症,比如脓肿或者其他感染情况。首先,我需要确认是否确实存在阑尾炎。因为有时候包块可能提示其他问题,比如肝炎、肝脓肿、脾炎、appendicitis的并发症或者其他腹膜炎症。所以,首先要考虑是否需要进一步的影像学检查,比如超声、CT或者MRI,来确认包块的性质。如果包块是脓肿,那么处理方式会是抗生素治疗,可能需要引流。或者,如果是肝的压痛包块,可能需要处理肝炎。但是,急性阑尾炎通常不会直接导致肝的问题,除非有并发症。另外,包块的出现可能意味着感染已经扩散,或者是阑尾炎转化为其他形式。所以,除了考虑是否需要进一步的诊断,还要评估病人的整体状况,比如是否有发热、白细胞增高、C反应蛋白升高等。在这种情况下,我认为应该首先进行全面的体征和实验室检查,包括血常规、C反应蛋白、结核菌素试验、血培养、腹部超声等,以确认是否存在脓肿、肝炎或其他并发症。如果确诊为脓肿,需要考虑抗生素的选择和引流的可能性。如果有其他并发症,如肝炎或脾炎,也需要相应的治疗。此外,可能需要考虑是否需要进行肠道外科的评估,尤其是如果包块位于右下腹,可能需要进一步的探查。同时,考虑到病人的发病5天,腹痛虽有所缓解,但仍有发热,这可能提示炎症正在积累,可能需要继续观察和支持治疗,同时准备进一步的诊断。总的来说,处理这种情况的关键是先确认诊断,再根据具体情况选择治疗方案,可能需要综合多个方面的医疗专家意见。
</think>根据病人的症状和检查结果,建议采取以下步骤:1. **进一步诊断**:进行腹部超声检查以明确包块的性质,确认是否为脓肿、肝炎或其他结构。
2. **实验室检查**:包括血常规、C反应蛋白、结核菌素试验、血培养和肝肾功能测试,以评估感染情况。
3. **抗生素治疗**:根据实验室结果,选择敏感的抗生素开始治疗,覆盖可能的菌落。
4. **影像学引流**:如果确诊为脓肿,考虑腹腔镜下引流或外科手术。
5. **综合治疗**:结合抗生素治疗和支持治疗,如营养补充和疼痛管理。
6. **监测与随访**:定期复查,监测病情进展,评估治疗效果。此外,建议与多个医疗专家沟通,制定个性化治疗方案。<|end▁of▁sentence|>
(unsloth_sft) ubuntu@ubuntu-server:~/train$ 

微调模型预测

源代码

(unsloth_sft) ubuntu@ubuntu-server:~/train$ cat inference2.py 
from datasets import load_dataset, Dataset
from datasets.features.features import Featuresfrom unsloth import FastLanguageModel 
from unsloth import is_bfloat16_supported
import torch
from trl import SFTTrainer
from transformers import TrainingArgumentsmax_seq_length = 2048
max_lora_rank = 32
question = "一个患有急性阑尾炎的病人已经发病5天,腹痛稍有减轻但仍然发热,在体检时发现右下腹有压痛的包块,此时应如何处理?"prompt_style = """
Below is an instruction that describes a task, paired with an input that provides further context. 
Write a response that appropriately completes the request. 
Before answering, think carefully about the question and create a step-by-step chain of thoughts to ensure a logical and accurate response.### Instruction:
# You are a medical expert with advanced knowledge in clinical reasoning, diagnostics, and treatment planning. Please answer the following medical question. ### Question:
{}### Response:
# <think>{}"""# 加载模型
model, tokenizer = FastLanguageModel.from_pretrained(model_name = "./model_20250226",max_seq_length = max_seq_length,dtype = None,load_in_4bit = True,# fast_inference=True,# max_lora_rank=max_lora_rank,# gpu_memory_utilization=0.6,
)# 模型预测
FastLanguageModel.for_inference(model=model)inputs = tokenizer(prompt_style.format(question, ""), return_tensors="pt").to("cuda")outputs = model.generate(input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,max_new_tokens=1300,use_cache=True,
)response = tokenizer.batch_decode(outputs)    print(response[0].split("### Response:")[1])(unsloth_sft) ubuntu@ubuntu-server:~/train$ 

预测结果

(unsloth_sft) ubuntu@ubuntu-server:~/train$ python inference2.py 
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
INFO 02-26 20:14:40 __init__.py:190] Automatically detected platform cuda.
==((====))==  Unsloth 2025.2.4: Fast Llama patching. Transformers: 4.48.3.\\   /|    GPU: NVIDIA GeForce RTX 4090. Max memory: 23.635 GB. Platform: Linux.
O^O/ \_/ \    Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0
\        /    Bfloat16 = TRUE. FA [Xformers = 0.0.28.post3. FA2 = False]"-____-"     Free Apache license: http://github.com/unslothai/unsloth
Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████| 4/4 [00:02<00:00,  1.57it/s]
Unsloth 2025.2.4 patched 32 layers with 32 QKV layers, 32 O layers and 32 MLP layers.# <think>
哦,这个病人已经有5天的急性阑尾炎了,腹痛稍微减轻,但还是发烧。体检发现右下腹有压痛的包块,这听起来很像是阑尾炎的典型表现。哦,可能是因为阑尾炎引起了炎症,导致了包块。我记得急性阑尾炎一般不需要立即手术处理,通常是观察和药物治疗。不过,这个病人的情况有点复杂,包块的存在可能意味着炎症已经发展到某种程度。要是包块比较大,或者有明显的压痛,可能会需要考虑手术。毕竟,如果包块太大,可能会压迫到其他重要器官,比如肾脏,这就麻烦了。不过,等等,虽然包块存在,但病人还没有完全无痛的症状。腹痛稍微减轻但仍然发烧,这可能只是炎症的发展阶段,还没有到需要手术的阶段。所以,或许我们可以先观察一下,等病情进一步发展或稳定后,再考虑手术。同时,继续使用抗生素和止痛药来缓解症状。这样想来,先不急着手术,继续观察和治疗似乎是更合理的选择。希望病人能够好转,避免不必要的手术风险。
</think>
根据病人的症状和体检结果,虽然右下腹存在压痛的包块,但目前病人的症状还没有完全稳定,腹痛仅有轻微减轻,仍然有发热。这种情况下,通常不需要立即进行手术治疗。通常,急性阑尾炎可以通过观察、药物治疗和营养支持来缓解症状。然而,包块的存在可能提示炎症已经发展到一定程度,需要密切监测。在这种情况下,建议继续使用抗生素和止痛药,以缓解症状,并密切观察病情的变化。如果病情进一步恶化,比如包块增大、腹痛加重或伴随发热不退、呕吐、发黄等症状,可能需要考虑进一步的处理,包括影像学检查或手术。总之,目前的处理策略是继续观察和治疗,同时密切监测病情变化,以便及时调整治疗方案。希望病人能够尽快恢复健康。<|end▁of▁sentence|>
(unsloth_sft) ubuntu@ubuntu-server:~/train$ 

相关文章:

Ubuntu2204下使用NVIDIA GeForce RTX 4090进行DeepSeek-R1-Distill-Llama-8B模型微调

Ubuntu2204下使用NVIDIA GeForce RTX 4090进行DeepSeek-R1-Distill-Llama-8B模型微调 环境准备创建Python微调环境准备数据集准备模型文件 模型微调模型预测原始模型预测微调模型预测 使用unsloth&#xff0c;可以方便地对大模型进行微调。以微调DeepSeek-R1-Distill-Llama-8B为…...

Ubuntu20.04安装Redis

目录 切换到root用户 使用 apt install redis 安装redis 修改配置文件 ​编辑 重新启动服务器 使用Redis客户端连接服务器 切换到root用户 如果没有切换到root用户的&#xff0c;切换到root用户。 使用 apt install redis 安装redis 遇到y/n直接y即可。 redis安装好之…...

【Word2Vec】Skip-gram 的直观理解(深入浅出)

01 什么是skip-gram 一句话来说就是&#xff0c;给定中心词&#xff0c;然后预测其周围的词&#xff1a; 02 模型结构 对于skip-gram来说&#xff0c;输入是一个[1 x V]维的ont-hot向量&#xff0c;其中V为词表大小&#xff0c;值为1的那一项就表示我们的中心词。经过一个[V x…...

MQ 笔记

什么是消息队列&#xff1f; 消息队列&#xff08;Message Queue, MQ&#xff09;是一种用于在分布式系统中传递消息的中间件技术。 它允许应用程序通过发送和接收消息进行异步通信。 消息队列的核心思想是解耦生产者和消费者&#xff0c;生产者将消息发送到队列中&#xff…...

leetcode第216题组合总和Ⅲ

原题出于leetcode第216题https://leetcode.cn/problems/combination-sum-iii/description/题目为&#xff1a; 找出所有相加之和为 n 的 k 个数的组合&#xff0c;且满足下列条件&#xff1a; 只使用数字1到9 每个数字 最多使用一次 返回 所有可能的有效组合的列表 。该列表…...

【零基础C语言】第四节 数组

【零基础C语言系列】 【零基础C语言】第一节 C语言概述【数制进制码制】-CSDN博客 【零基础C语言】第二节 数据类型、运算符、表达式-CSDN博客 【零基础C语言】第三节 控制结构-CSDN博客 一、一维数组...

20250225-代码笔记03-class CVRPModel AND other class

文章目录 前言一、class CVRPModel(nn.Module):__init__(self, **model_params)函数功能函数代码 二、class CVRPModel(nn.Module):pre_forward(self, reset_state)函数功能函数代码 三、class CVRPModel(nn.Module):forward(self, state)函数功能函数代码 四、def _get_encodi…...

京准电钟快讯:NTP时钟同步服务在智造行业应用

京准电钟快讯&#xff1a;NTP时钟同步服务在智造行业应用 京准电钟快讯&#xff1a;NTP时钟同步服务在智造行业应用 一、NTP技术概述 基本原理 NTP&#xff08;Network Time Protocol&#xff09;是一种用于同步计算机系统时间的网络协议&#xff0c;通过分层时钟源&#xff…...

【Qt】详细介绍如何在Visual Studio Code中编译、运行Qt项目

Visual Studio Code一只用的顺手&#xff0c;写Qt的时候也能用VS Code开发就方便多了。 理论上也不算困难&#xff0c;毕竟Qt项目其实就是CMake&#xff08;QMake的情况这里就暂不考虑了&#xff09;项目&#xff0c;VS Code在编译、运行CMake项目还是比较成熟的。 这里笔者打…...

jsherp importItemExcel接口存在SQL注入

一、漏洞简介 很多人说管伊佳ERP&#xff08;原名&#xff1a;华夏ERP&#xff0c;英文名&#xff1a;jshERP&#xff09;是目前人气领先的国产ERP系统虽然目前只有进销存财务生产的功能&#xff0c;但后面将会推出ERP的全部功能&#xff0c;有兴趣请帮点一下 二、漏洞影响 …...

Node.js, Bun, Deno 比较概述

以下是 Node.js、Bun 和 Deno 的对比分析 概览 对比维度Node.jsDenoBun首次发布200920202022创始人Ryan DahlRyan Dahl&#xff08;Node.js 原作者&#xff09;Jarred Sumner运行时引擎V8&#xff08;Chrome&#xff09;V8&#xff08;Chrome&#xff09;JavaScriptCore&#…...

大白话跨域问题怎么破,解决方法有啥?

大白话跨域问题怎么破&#xff0c;解决方法有啥&#xff1f; 啥是跨域问题 咱先说说啥是跨域。你可以把每个网站想象成一个独立的小房子&#xff0c;每个房子都有自己的地址&#xff08;也就是域名&#xff09;。正常情况下&#xff0c;一个房子里的东西只能在这个房子里用&a…...

DeepSeek R1满血+火山引擎详细教程

DeepSeek R1满血火山引擎详细教程 一、安装Cherry Studio。 Cherry Studio AI 是一款强大的多模型 AI 助手,支持 iOS、macOS 和 Windows 平台。可以快速切换多个先进的 LLM 模型,提升工作学习效率。下载地址 https://cherry-ai.com/ 认准官网&#xff0c;无强制注册。 这…...

Pytorch中的ebmedding到底怎么理解?

在 PyTorch 中&#xff0c;nn.Embedding 是一个用于处理离散符号映射到连续向量空间的模块。它通常用于自然语言处理&#xff08;NLP&#xff09;任务&#xff08;如词嵌入&#xff09;、处理分类特征&#xff0c;或任何需要将离散索引转换为密集向量的场景。 核心理解 功能&am…...

【JAVA面试题】什么是面向对象?谈谈你对面向对象的理解。

【JAVA面试题】什么是面向对象&#xff1f;谈谈你对面向对象的理解 在 Java 面试中&#xff0c;面向对象 是一个高频考点。它不仅是一种编程思想&#xff0c;更是现代软件开发的核心方法论。本文将从 面向对象的概念、与面向过程的对比、以及 面向对象的三大特性&#xff08;封…...

【C】链式二叉树算法题1 -- 单值二叉树

leetcode链接https://leetcode.cn/problems/univalued-binary-tree/description/ 1 题目描述 如果二叉树每个节点都具有相同的值&#xff0c;那么该二叉树就是单值二叉树。只有给定的树是单值二叉树时&#xff0c;才返回 true&#xff1b;否则返回 false。 示例 1&#xff1…...

基于单片机的GPS定位系统设计

1 系统硬件 1.1单片机模块 单片机的种类和型号可以说是有成百上千种&#xff0c;很多大的公司和企业都生产开发自己的单片机芯片&#xff0c;并且广泛应用于各种产品。Intel、 philips、 摩托罗拉、凌阳、宏晶等等种类繁多。大体上可以分为51系列单片机和非51系列单片机。 其…...

[React]Render Props、自定义Hooks和Context API优化详解

关于React中的Render Props、自定义Hooks和Context API优化的详解。我需要根据我搜索到的资料来综合回答这三个部分。首先&#xff0c;我需要分别理解每个概念的定义、用途以及优化方法。 首先看Render Props。根据Render Props是一种通过传递函数作为prop来共享组件间逻辑的技…...

关于大型语言模型的结构修剪

本文介绍了一种名为 **LLM-Pruner** 的方法&#xff0c;用于对大型语言模型&#xff08;LLMs&#xff09;进行结构化剪枝&#xff0c;以减少模型大小和计算需求&#xff0c;同时保留其多任务解决和语言生成能力。LLM-Pruner 通过依赖检测和重要性估计实现高效剪枝&#xff0c;并…...

【语法】C++中string类中的两个问题及解答

贴主在学习string类时遇到过两个困扰我的问题&#xff0c;今天拿出来给大家分享一下我是如何解决的 一、扩容时capacity的增长问题 在string的capacity()接口中&#xff0c;调用的是这个string对象的容量(可以存多少个有效字符)&#xff0c;而size()是调用的string对象现在有…...

Linux(centOS) 命令提示符格式修改(PS1)

1. 命令提示符的组成 命令提示符&#xff08;PS1&#xff09;通常由以下部分组成&#xff1a; 部分示例说明[ 和 ][...]提示符的开头和结尾&#xff0c;用于视觉分隔。用户名root 或 tianjiajie当前登录的用户。root 是超级用户&#xff0c;普通用户可能是其他名称。分隔用户…...

QwenVL 2.5-本地安装编译布署全教程

开篇 DeepSeek开源后我国又开源了一个震撼大模型,QwenVL2.5,这是一个多模态的模形,它可以认图、识图、更能作图,还能读懂video。 Qwen2.5-VL 的主要特点如下所示: 感知更丰富的世界:Qwen2.5-VL 不仅擅长识别常见物体,如花、鸟、鱼和昆虫,还能够分析图像中的文本、图表…...

Hutool - JWT:轻松玩转 JSON Web Token

各位开发者朋友们&#xff0c;在现代的前后端分离开发模式里&#xff0c;身份验证和授权可是至关重要的环节。JSON Web Token&#xff08;JWT&#xff09;作为一种轻量级的身份验证和授权机制&#xff0c;在很多项目中都得到了广泛应用。它可以在客户端和服务器之间安全地传输信…...

2024年第十五届蓝桥杯大赛软件赛省赛Python大学A组真题解析《更新中》

文章目录 试题A: 拼正方形(本题总分:5 分)解析答案试题B: 召唤数学精灵(本题总分:5 分)解析答案试题C: 数字诗意解析答案试题D:回文数组试题A: 拼正方形(本题总分:5 分) 【问题描述】 小蓝正在玩拼图游戏,他有7385137888721 个2 2 的方块和10470245 个1 1 的方块,他需…...

【2025年2月28日稳定版】小米路由器4C刷机Immortalwrt 23.05.4系统搭载mentohust 0.3.1插件全记录

小米路由器4C刷机Immortalwrt系统搭载mentohust插件全记录 首先将路由器按住后面的reset&#xff0c;用一个针插进去然后等待5s左右&#xff0c;松开&#xff0c;即可重置路由器。 然后要用物理网线物理连接路由器Lan口和电脑&#xff0c;并将路由器WAN口连接至网口。确保电脑…...

W3C标准和ES规范之一文通

W3C标准和ES规范之一文通 以下是关于W3C标准和ES规范的透彻解析&#xff0c;通过结构化对比和生活化类比帮助理解和记忆&#xff1a; 一、核心概念对比&#xff08;总览&#xff09; 维度W3C标准ES规范&#xff08;ECMAScript&#xff09;定位Web技术的建筑蓝图JavaScript的语…...

Linux:应用层协议

协议是一种 "约定". socket api的接口, 在读写数据时, 都是按 "字符串" 的方式来发送接收的. 如果我们要传输一些"结构化的数据" 怎么办呢? 无论我们采用什么方案, 只要保证, 一端发送时构造的数据, 在另一端能够正确的进行解析, 就是ok的. 这种…...

深度学习五大模型:CNN、Transformer、BERT、RNN、GAN详细解析

# 深度学习五虎将&#xff1a;当CNN遇见Transformer的奇幻漂流 ## 序章&#xff1a;AI江湖的兵器谱排行 2012年&#xff0c;多伦多大学的厨房里&#xff0c;Hinton的学生们用GPU煎了个"AlexNet"荷包蛋&#xff0c;从此开启了深度学习的热兵器时代。如今五大模型各显…...

微服务组件详解——sentinel

1.启动sentinel&#xff1a; 下载jar sentinel-dashboard-1.8.0.jar 使用以下命令直接运行 jar 包&#xff08;JDK 版本必须≥ 1.8&#xff09;&#xff1a; java -Dserver.port9999 -jar D:\sentinel-dashboard-1.8.0.jar 控制台访问地址&#xff1a;http://localhost:9999…...

波导阵列天线 学习笔记11双极化全金属垂直公共馈电平板波导槽阵列天线

摘要&#xff1a; 本communicaition提出了一种双极化全金属垂直公共馈电平板波导槽阵列天线。最初提出了一种公共馈电的单层槽平板波导来实现双极化阵列。此设计消除了传统背腔公共馈电的复杂腔体边缘的必要性&#xff0c;提供了一种更简单的天线结构。在2x2子阵列种发展了宽十…...

swift 开发效率提升工具

安装github copliot for xcode github/CopilotForXcode brew install --cask github-copilot-for-xcode安装swiftformat for xcode brew install swiftformatXcode Swift File代码格式化-SwiftFormat...

3-5 WPS JS宏 工作表的移动与复制学习笔记

************************************************************************************************************** 点击进入 -我要自学网-国内领先的专业视频教程学习网站 *******************************************************************************************…...

Centos7部署k8s(单master节点安装)

单master节点部署k8s集群(Centos) 一、安装前准备 1、修改主机名 按照资源准备修改即可 # master01 hostnamectl set-hostname master01 ; bash # node1 hostnamectl set-hostname node1 ; bash # node2 hostnamectl set-hostname node2 ; bash2、修改hosts文件 以下命令所…...

Tomcat

1.Tomcat是什么&#xff1f; Tomcat 是一个开源的、轻量级的 Servlet 容器&#xff0c;也被称为 Web 服务器&#xff0c;由 Apache 软件基金会的 Jakarta 项目开发&#xff0c;在 Java Web 开发领域应用广泛。 1&#xff09;Servlet 容器&#xff1a;Servlet 是 Java 语言编写…...

基于SpringBoot+Vue的电影订票及评论网站的设计与实现(源码+SQL脚本+LW+部署讲解等)

专注于大学生项目实战开发,讲解,毕业答疑辅导&#xff0c;欢迎高校老师/同行前辈交流合作✌。 技术范围&#xff1a;SpringBoot、Vue、SSM、HLMT、小程序、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、安卓app、大数据、物联网、机器学习等设计与开发。 主要内容&#xff1a;…...

地基简识Spring MVC 组件

Spring MVC 是一个基于 MVC 设计模式的框架&#xff0c;其核心组件协同工作以处理 HTTP 请求并生成响应。以下是各组件的详细说明及其协作流程&#xff1a; 一、​核心组件 ​DispatcherServlet&#xff08;前端控制器&#xff09;​ ​作用&#xff1a;接收所有请求并协调其他…...

如何通过Python网络爬虫技术应对复杂的反爬机制?

要使用Python网络爬虫技术绕过复杂的反爬虫机制&#xff0c;可以采取以下几种策略&#xff1a; 设置User-Agent&#xff1a;通过设置不同的User-Agent&#xff0c;模拟正常用户的浏览器访问&#xff0c;避免被网站识别为爬虫。可以使用fake_useragent库来随机生成User-Agent。…...

深入浅出:Spring AI 集成 DeepSeek 构建智能应用

Spring AI 作为 Java 生态中备受瞩目的 AI 应用开发框架&#xff0c;凭借其简洁的 API 设计和强大的功能&#xff0c;为开发者提供了构建智能应用的强大工具。与此同时&#xff0c;DeepSeek 作为领先的 AI 模型服务提供商&#xff0c;在自然语言处理、计算机视觉等领域展现了卓…...

Node.js二:第一个Node.js应用

精心整理了最新的面试资料和简历模板&#xff0c;有需要的可以自行获取 点击前往百度网盘获取 点击前往夸克网盘获取 创建的时候我们需要用到VS code编写代码 我们先了解下 Node.js 应用是由哪几部分组成的&#xff1a; 1.引入 required 模块&#xff1a;我们可以使用 requi…...

【HarmonyOS Next】鸿蒙状态管理装饰器V1和V2混用方案

【HarmonyOS Next】鸿蒙状态管理装饰器V1和V2混用方案 一、V1和V2为什么需要混用 自从api7开始&#xff0c;一直到api10。V1的实际使用中&#xff0c;开发人员发现Observed和ObjectLink 监听实现多层级嵌套对象的更新的方案&#xff0c;太过于臃肿。当需要监听处理更新的多层…...

【技海登峰】Kafka漫谈系列(三)详解Kafka的数据结构与存储机制

【技海登峰】Kafka漫谈系列(三)详解Kafka的数据结构与存储机制 Kafka 使用消息日志(Log)机制来持久化保存数据,我们知道Kafka实际是以Partition分区为单位进行负载均衡和资源分配,每个Partition又由多个Replica副本组成,副本之间分布于不同的Broker上来保证高可用,因此…...

PyCharm接入本地部署DeepSeek 实现AI编程!【支持windows与linux】

今天尝试在pycharm上接入了本地部署的deepseek&#xff0c;实现了AI编程&#xff0c;体验还是很棒的。下面详细叙述整个安装过程。 本次搭建的框架组合是 DeepSeek-r1:1.5b/7b Pycharm专业版或者社区版 Proxy AI&#xff08;CodeGPT&#xff09; 首先了解不同版本的deepsee…...

腾讯云扩容记录

腾讯云扩容&#xff1a; sudo yum install -y cloud-utils-growpart 安装扩容工具 sudo file -s /dev/vda1 有数据 sudo LC_ALLen_US.UTF-8 growpart /dev/vda 1 sudo resize2fs /dev/vda1 df -Th 完毕 以下是对执行的命令的详细解释以及背后的原理&#xff1a; 1. 安装 cloud…...

计算机毕业设计Hadoop+Spark+DeepSeek-R1大模型音乐推荐系统 音乐数据分析 音乐可视化 音乐爬虫 知识图谱 大数据毕业设计

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…...

本地部署大语言模型-DeepSeek

DeepSeek 是国内顶尖 AI 团队「深度求索」开发的多模态大模型&#xff0c;具备数学推理、代码生成等深度能力&#xff0c;堪称"AI界的六边形战士"。 Hostease AMD 9950X/96G/3.84T NVMe/1G/5IP/RTX4090 GPU服务器提供多种计费模式。 DeepSeek-R1-32B配置 配置项 规…...

Windows逆向工程入门之MASM数据结构使用

公开视频 -> 链接点击跳转公开课程博客首页 -> ​​​链接点击跳转博客主页 目录 第一章&#xff1a;MASM数据定义体系精要 1.1 基础数据类型全景 1.1.1 整型数据规范 1.1.2 浮点数据编码 1.2 复合数据结构 1.2.1 多维数组定义 1.2.2 复杂结构体 第二章&#xf…...

python 之协程笔记

协程 协程的本质是用户态线程&#xff0c;由程序自行控制切换时机&#xff0c;无需操作系统介入。与线程相比&#xff0c;协程的三大核心优势&#xff1a; 资源占用极低&#xff1a;一个协程仅需KB级内存&#xff0c;可轻松创建数万个切换效率惊人&#xff1a;上下文切换在用户…...

使用 REINFORCE 算法强化梯度策略

一、整体概述 此代码利用 REINFORCE 算法&#xff08;一种基于策略梯度的强化学习算法&#xff09;来解决 OpenAI Gym 中的 CartPole-v1 环境问题。CartPole-v1 环境的任务是控制一个小车&#xff0c;使连接在小车上的杆子保持平衡。代码通过构建一个神经网络作为策略网络&…...

【C++并发编程实战】第1章 你好,C++的并发世界!

文章目录 1. 何谓并发2. 为什么使用并发&#xff1f;3. 什么时候不使用并发4. C多线程历史5. 第一个并发程序 1. 何谓并发 最简单和最基本的并发,是指两个或更多独立的活动同时发生。计算机领域的并发指的是在单个系统里同时执行多个独立的任务&#xff0c;而非顺序的进行一些…...

【QT线程】子线程阻塞主线程的一次网络api请求案例

阻塞源码赏析 这是最近一次项目遇到的问题&#xff0c;原因是我觉得子线程里俩次请求间隔太短了&#xff0c;会引起服务器屏蔽我的api因此&#xff0c;我故作聪明加多了一个延时函数&#xff0c;欢迎各位鉴赏代码。 // 并行发起双请求 QNetworkRequest liveRequest(liveUrl);…...