PaddleNLP UIE 实体关系抽取

news/2024/7/7 18:46:14/文章来源:https://www.cnblogs.com/vipsoft/p/18265581

目录
  • 环境依赖
  • 配置SSH
  • 克隆代码
  • 训练定制
    • 代码结构
    • 数据标注
      • 准备语料库
      • 数据标注
      • 导出数据
    • 数据转换
      • doccano
      • Label Studio
    • 模型微调
  • 问题处理
    • 找不到 'paddlenlp.trainer'
    • 找不到
      • GPU
      • protobuf==3.20.2
    • CUDA/cuDNN/paddle

PaddleNLP UIE 实体关系抽取

PaddlePaddle用户可领取免费Tesla V100在线算力资源,训练模型更高效。每日登陆即送8小时,前往使用免费算力。

随便找个项目如:https://aistudio.baidu.com/projectdetail/1639963 打开后 Fork 一下。

环境依赖

https://gitee.com/paddlepaddle/PaddleNLP/tree/release/2.8#环境依赖

  • python >= 3.7
  • PandleNLP 2.7.2
  • paddlepaddle-gpu >= 2.5.2 # 涉及模型微调,必须 带GPU
### 升级
pip install --upgrade paddlepaddle-gpu==2.5.2
pip install --upgrade paddlenlp==2.7.2aistudio@jupyter-2631487-6335886:~$ pip show paddlepaddle-gpu
Name: paddlepaddle-gpu
Version: 2.5.2
Summary: Parallel Distributed Deep Learning
Home-page: https://www.paddlepaddle.org.cn/
Author: 
Author-email: Paddle-better@baidu.com
License: Apache Software License
Location: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages
Requires: astor, decorator, httpx, numpy, opt-einsum, Pillow, protobuf
Required-by: aistudio@jupyter-2631487-6335886:~$ pip show paddlenlp
Name: paddlenlp
Version: 2.7.2
Summary: Easy-to-use and powerful NLP library with Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including Neural Search, Question Answering, Information Extraction and Sentiment Analysis end-to-end system.
Home-page: https://github.com/PaddlePaddle/PaddleNLP
Author: PaddleNLP Team
Author-email: paddlenlp@baidu.com
License: Apache 2.0
Location: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages
Requires: aistudio-sdk, colorama, colorlog, datasets, dill, fastapi, Flask-Babel, huggingface-hub, jieba, jinja2, multiprocess, onnx, paddle2onnx, paddlefsl, protobuf, rich, safetensors, sentencepiece, seqeval, tool-helpers, tqdm, typer, uvicorn, visualdl
Required-by: paddlehub
aistudio@jupyter-2631487-6335886:~$ 

配置SSH

AI Studio 不能访问 gitee 下载代码,因此可以跳过此小结 直接跳至 代码上传
生成SSH

ssh-keygen -t rsa -C "PandleNLP@UIE"

image

配置公钥
image

验证
ssh -T git@gitee.com
image

克隆代码

AI Studio 不能访问 gitee.com ,通过本地下载。再上传的方式操作
下载 V2.8
image
上传代码
image
解压代码
unzip -cxvf PaddleNLP-release-2.8.zip
image

训练定制

代码结构

model_zoo/uie 目录代码文件说明如下:

.
├── utils.py          # 数据处理工具
├── model.py          # 模型组网脚本
├── doccano.py        # 数据标注脚本 => 下面数据转换时会用到
├── doccano.md        # 数据标注文档
├── finetune.py       # 模型微调、压缩脚本
├── evaluate.py       # 模型评估脚本
└── README.md

对于细分场景推荐使用轻定制功能(标注少量数据进行模型微调)以进一步提升效果

schema =['药品名称','用法','用量','频次']
ie = Taskflow('information_extraction',schema=schema)
pprint(ie("布洛芬分散片,口服或加水分散后服用。用于成人及12岁以上儿童,推荐剂里为一次0.2~0.4(1~2片)一日3次,或遵医嘱"))

如图:只能提取出药品名称,接下来,通过训练数据进行UIE模型微调
image

数据标注

详细过程参考 数据标注工具 doccano | 命名实体识别(Named Entity Recognition,简称NER)

准备语料库

准备语料库、每一行为一条待标注文本,示例:corpus.txt

布洛芬分散片,口服或加水分散后服用。用于成人及12岁以上儿童,推荐剂里为一次0.2~0.4(1~2片)一日3次,或遵医嘱
白加黑(氨酚伪麻美芬片Ⅱ氨麻苯美片),口服。一次1~2片,一日3次(早、中各1~2白片,夜晚1~2片黑片),儿童遵医嘱
氯雷他定片,口服,规格为10mg的氯雷他定片,通常成人及12岁以上儿童1天1次,1次1片
扶他林(双氯芬酸二乙胺乳胶剂),外用。按照痛处面积大小,使用本品适量,轻轻揉搓,使本品渗透皮肤,一日3-4次
七叶洋地黄双苷,外用。用于黄斑变性时,每日3次,每次1滴,滴入眼结膜囊内(近耳侧外眼角)

数据标注

定义标签
Demo简单的定了 "药品名称、通用名、规格、用法、用量、频次"
image
数据标注
在doccano平台上,创建一个类型为序列标注的标注项目。
定义实体标签类别,上例中需要定义的实体标签有[ 药品名称、通用名、规格、用法、用量、频次 ]。
使用以上定义的标签开始标注数据,下面展示了一个doccano标注示例:
image

导出数据

标注完成后,在doccano平台上导出文件,并将其重命名为doccano_ext.json后,放入./data目录下
image
image

数据转换

在这一步最好换成GPU环境,否则切换到GPU环境后,还需要安装 paddlepaddle 等操作

## 模型微调必须使用GPU
pip install --upgrade paddlepaddle-gpu==2.5.2
pip install --upgrade paddlenlp==2.7.2

doccano

在 AI Studio 环境中创建 data 目录,将 doccano_ext.json 放入data目录中
image
执行以下脚本进行数据转换,执行后会在./data目录下生成训练/验证/测试集文件。

python doccano.py \--doccano_file ./data/doccano_ext.json \--task_type ext \--save_dir ./data \--splits 0.8 0.2 0 \--schema_lang ch
# 执行后会在./data目录下生成训练/验证/测试集文件。
[2024-06-26 09:48:38,269] [    INFO] - Save 24 examples to ./data/train.txt.
[2024-06-26 09:48:38,269] [    INFO] - Save 5 examples to ./data/dev.txt.
[2024-06-26 09:48:38,269] [    INFO] - Save 0 examples to ./data/test.txt.

image

可配置参数说明:

  • doccano_file: 从doccano导出的数据标注文件。
  • save_dir: 训练数据的保存目录,默认存储在data目录下。
  • negative_ratio: 最大负例比例,该参数只对抽取类型任务有效,适当构造负例可提升模型效果。负例数量和实际的标签数量有关,最大负例数量 = negative_ratio * 正例数量。该参数只对训练集有效,默认为5。为了保证评估指标的准确性,验证集和测试集默认构造全负例。
  • splits: 划分数据集时训练集、验证集所占的比例。默认为[0.8, 0.1, 0.1]表示按照8:1:1的比例将数据划分为训练集、验证集和测试集。
  • task_type: 选择任务类型,可选有抽取和分类两种类型的任务。
  • options: 指定分类任务的类别标签,该参数只对分类类型任务有效。默认为["正向", "负向"]。
  • prompt_prefix: 声明分类任务的prompt前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
  • is_shuffle: 是否对数据集进行随机打散,默认为True。
  • seed: 随机种子,默认为1000.
  • separator: 实体类别/评价维度与分类标签的分隔符,该参数只对实体/评价维度级分类任务有效。默认为"##"。
  • schema_lang: 选择schema的语言,可选有chen。默认为ch,英文数据集请选择en

备注:

  • 默认情况下 doccano.py 脚本会按照比例将数据划分为 train/dev/test 数据集
  • 每次执行 doccano.py 脚本,将会覆盖已有的同名数据文件
  • 在模型训练阶段我们推荐构造一些负例以提升模型效果,在数据转换阶段我们内置了这一功能。可通过negative_ratio控制自动构造的负样本比例;负样本数量 = negative_ratio * 正样本数量。
  • 对于从doccano导出的文件,默认文件中的每条数据都是经过人工正确标注的。

Label Studio

也可以通过数据标注平台 Label Studio 进行数据标注。 labelstudio2doccano.py 脚本,将 label studio 导出的 JSON 数据文件格式转换成 doccano 导出的数据文件格式,后续的数据转换与模型微调等操作不变。

python labelstudio2doccano.py --labelstudio_file label-studio.json

可配置参数说明:

  • labelstudio_file: label studio 的导出文件路径(仅支持 JSON 格式)。
  • doccano_file: doccano 格式的数据文件保存路径,默认为 "doccano_ext.jsonl"。
  • task_type: 任务类型,可选有抽取("ext")和分类("cls")两种类型的任务,默认为 "ext"。

模型微调

必须使用GPU pip install --upgrade paddlepaddle-gpu==2.5.2推荐使用 Trainer API 对模型进行微调。只需输入模型、数据集等就可以使用 Trainer API 高效快速地进行预训练、微调和模型压缩等任务,可以一键启动多卡训练、混合精度训练、梯度累积、断点重启、日志显示等功能,Trainer API 还针对训练过程的通用训练配置做了封装,比如:优化器、学习率调度等。

使用下面的命令,使用 uie-base 作为预训练模型进行模型微调,将微调后的模型保存至$finetuned_model
单卡启动:

export finetuned_model=./checkpoint/model_bestpython finetune.py  \--device gpu \--logging_steps 10 \--save_steps 100 \--eval_steps 100 \--seed 42 \--model_name_or_path uie-base \--output_dir $finetuned_model \--train_path data/train.txt \--dev_path data/dev.txt  \--per_device_eval_batch_size 16 \--per_device_train_batch_size  16 \--num_train_epochs 20 \--learning_rate 1e-5 \--label_names "start_positions" "end_positions" \--do_train \--do_eval \--do_export \--export_model_dir $finetuned_model \--overwrite_output_dir \--disable_tqdm True \--metric_for_best_model eval_f1 \--load_best_model_at_end  True \--save_total_limit 1

注意:如果模型是跨语言模型 UIE-M,还需设置 --multilingual

可配置参数说明:

  • model_name_or_path:必须,进行 few shot 训练使用的预训练模型。可选择的有 "uie-base"、 "uie-medium", "uie-mini", "uie-micro", "uie-nano", "uie-m-base", "uie-m-large"。
  • multilingual:是否是跨语言模型,用 "uie-m-base", "uie-m-large" 等模型进微调得到的模型也是多语言模型,需要设置为 True;默认为 False。
  • output_dir:必须,模型训练或压缩后保存的模型目录;默认为 None
  • device: 训练设备,可选择 'cpu'、'gpu' 、'npu'其中的一种;默认为 GPU 训练。
  • per_device_train_batch_size:训练集训练过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为 32。
  • per_device_eval_batch_size:开发集评测过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为 32。
  • learning_rate:训练最大学习率,UIE 推荐设置为 1e-5;默认值为3e-5。
  • num_train_epochs: 训练轮次,使用早停法时可以选择 100;默认为10。
  • logging_steps: 训练过程中日志打印的间隔 steps 数,默认100。
  • save_steps: 训练过程中保存模型 checkpoint 的间隔 steps 数,默认100。
  • seed:全局随机种子,默认为 42。
  • weight_decay:除了所有 bias 和 LayerNorm 权重之外,应用于所有层的权重衰减数值。可选;默认为 0.0;
  • do_train:是否进行微调训练,设置该参数表示进行微调训练,默认不设置。
  • do_eval:是否进行评估,设置该参数表示进行评估。

该示例代码中由于设置了参数 --do_eval,因此在训练完会自动进行评估。

image

问题处理

找不到 'paddlenlp.trainer'

报找不到模块:ModuleNotFoundError: No module named 'paddlenlp.trainer'

  import imp
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/scipy/sparse/sputils.py:16: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.supported_dtypes = [np.typeDict[x] for x in supported_dtypes]
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/scipy/special/orthogonal.py:81: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecationsfrom numpy import (exp, inf, pi, sqrt, floor, sin, cos, around, int,
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/scipy/linalg/__init__.py:217: DeprecationWarning: The module numpy.dual is deprecated.  Instead of using dual, use the functions directly from numpy or scipy.from numpy.dual import register_func
Traceback (most recent call last):File "doccano.py", line 25, in <module>from paddlenlp.trainer.argparser import strtobool
ModuleNotFoundError: No module named 'paddlenlp.trainer'

image

pip show paddlepaddle
Name: paddlepaddle
Version: 2.2.2  # 环境中是2.2.2 https://gitee.com/paddlepaddle/PaddleNLP/tree/release/2.8 要求 paddlepaddle >=2.6.0
Summary: Parallel Distributed Deep Learning
Home-page: UNKNOWN
Author: 
Author-email: Paddle-better@baidu.com
License: Apache Software License
Location: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages
Requires: astor, decorator, numpy, Pillow, protobuf, requests, six
Required-by:  

升级Paddlepaddle

pip install --upgrade paddlepaddle-gpu==2.5.2
pip install --upgrade paddlenlp==2.7.2

找不到

ModuleNotFoundError: No module named ‘paddle.fluid.layers.utils

升级 PaddleNLP ,环境中有安装,所以先升下级,其实已经下了源代码。理论上可以卸载 PaddleNLP 直接跑源码的。

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
streamlit 1.13.0 requires importlib-metadata>=1.4, but you have importlib-metadata 0.23 which is incompatible.
streamlit 1.13.0 requires protobuf!=3.20.2,<4,>=3.12, but you have protobuf 4.24.4 which is incompatible.flake8 4.0.1 requires importlib-metadata<4.3; python_version < "3.8", but you have importlib-metadata 6.7.0 which is incompatible.
python-lsp-server 1.5.0 requires ujson>=3.0.0, but you have ujson 1.35 which is incompatible.
streamlit 1.13.0 requires protobuf!=3.20.2,<4,>=3.12, but you have protobuf 4.24.4 which is incompatible

根据提示升级

# importlib-metadata
pip install --upgrade importlib-metadata==1.4
# protobuf
pip install --upgrade protobuf>=1.4
pip install --upgrade ujson==3.0.0

image

GPU

模型微调需使用GPU

Traceback (most recent call last):File "finetune.py", line 262, in <module>main()File "finetune.py", line 98, in mainpaddle.set_device(training_args.device)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/device/__init__.py", line 266, in set_deviceplace = _convert_to_place(device)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/device/__init__.py", line 181, in _convert_to_place"The device should not be 'gpu', "
ValueError: The device should not be 'gpu', since PaddlePaddle is not compiled with CUDA

image

在这一步最好换成GPU环境,否则切换到GPU环境后,还需要安装 paddlepaddle 等操作

image

protobuf==3.20.2

[2024-06-26 11:16:18,349] [    INFO] - All the weights of UIE were initialized from the model checkpoint at uie-base.
If your task is similar to the task the model of the checkpoint was trained on, you can already use UIE for predictions without further training.
[2024-06-26 11:16:18,371] [    INFO] - The global seed is set to 42, local seed is set to 43 and random seed is set to 42.
Traceback (most recent call last):File "finetune.py", line 262, in <module>main()File "finetune.py", line 179, in maincompute_metrics=compute_metrics,File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/trainer.py", line 344, in __init__callbacks, self.model, self.tokenizer, self.optimizer, self.lr_schedulerFile "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/trainer_callback.py", line 307, in __init__self.add_callback(cb)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/trainer_callback.py", line 324, in add_callbackcb = callback() if isinstance(callback, type) else callbackFile "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/integrations.py", line 74, in __init__from visualdl import LogWriterFile "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/visualdl/__init__.py", line 20, in <module>from visualdl.writer.writer import LogWriter  # noqa: F401File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/visualdl/writer/writer.py", line 19, in <module>from visualdl.writer.record_writer import RecordFileWriterFile "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/visualdl/writer/record_writer.py", line 18, in <module>from visualdl.proto import record_pb2File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/visualdl/proto/record_pb2.py", line 40, in <module>serialized_options=None, file=DESCRIPTOR),File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 561, in __new___message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:1. Downgrade the protobuf package to 3.20.x or lower.2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
# 降低 Protobuf 版本
pip install --upgrade protobuf==3.20.2

image

CUDA/cuDNN/paddle

[2024-06-26 11:43:01,264] [   DEBUG] -   Number of trainable parameters = 117,946,370 (per device)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/tokenizer_utils_base.py:2541: FutureWarning: The `max_seq_len` argument is deprecated and will be removed in a future version, please use `max_length` instead.FutureWarning,
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/tokenizer_utils_base.py:1944: FutureWarning: The `pad_to_max_length` argument is deprecated and will be removed in a future version, use `padding=True` or `padding='longest'` to pad to the longest sequence in the batch, or use `padding='max_length'` to pad to a max length. In this case, you can give a specific length with `max_length` (e.g. `max_length=45`) or leave max_length to None to pad to the maximal input size of the model (e.g. 512 for Bert).FutureWarning,
Traceback (most recent call last):File "finetune.py", line 262, in <module>main()File "finetune.py", line 193, in maintrain_result = trainer.train(resume_from_checkpoint=checkpoint)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/trainer.py", line 924, in traintr_loss_step = self.training_step(model, inputs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/trainer.py", line 1955, in training_steploss = self.compute_loss(model, inputs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/trainer.py", line 1899, in compute_lossoutputs = model(**inputs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/distributed/parallel.py", line 531, in forwardoutputs = self._layers(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/ernie/modeling.py", line 1275, in forwardreturn_dict=return_dict,File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/ernie/modeling.py", line 363, in forwardreturn_dict=return_dict,File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/model_outputs.py", line 312, in _transformer_encoder_fwdoutput_attentions=output_attentions,File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/model_outputs.py", line 83, in _transformer_encoder_layer_fwdattn_outputs = self.self_attn(src, src, src, src_mask, cache)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/transformer.py", line 418, in forwardq, k, v = self._prepare_qkv(query, key, value, cache)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/transformer.py", line 242, in _prepare_qkvq = self.q_proj(query)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/layers.py", line 1254, in __call__return self.forward(*inputs, **kwargs)File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/common.py", line 175, in forwardx=input, weight=self.weight, bias=self.bias, name=self.nameFile "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/functional/common.py", line 1842, in linearreturn _C_ops.linear(x, weight, bias)
OSError: (External) CUBLAS error(7). [Hint: 'CUBLAS_STATUS_INVALID_VALUE'.  An unsupported value or parameter was passed to the function (a negative vector size, for example). To correct: ensure that all the parameters being passed have valid values. ] (at ../paddle/phi/backends/gpu/gpu_context.cc:599)[operator < linear > error]
aistudio@jupyter-2631487-6335886:~/PaddleNLP-release-2.8/model_zoo/uie$ 
aistudio@jupyter-2631487-6335886:~$ python
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> paddle.utils.run_check()

image

未完待续

![image](https://img2024.cnblogs.com/blog/80824/202406/80824-20240624173314294-529178150.png) 克隆代码,`git clone git@gitee.com:paddlepaddle/PaddleNLP.git` ![image](https://img2024.cnblogs.com/blog/80824/202406/80824-20240625085550212-1652671662.png)

image
image

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/736403.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python对历年高考分数线数据用聚类、决策树可视化分析一批、二批高校专业、位次、计划人数数据|附代码数据

全文链接:https://tecdat.cn/?p=36626 原文出处:拓端数据部落公众号 随着高等教育的普及与竞争的日益激烈,高考作为通往高等教育的重要门槛,其分数线的波动、高校及专业的选择成为了社会广泛关注的焦点。考生和家长在面临众多高校和专业的选择时,往往需要综合考虑多种因素…

阿里228x82y还原之递归数组解密

声明 本文章中所有内容仅供学习交流,抓包内容、敏感网址、数据接口均已做脱敏处理,严禁用于商业用途和非法用途,否则由此产生的一切后果均与作者无关,若有侵权,请联系我立即删除! 目标网站 某里228 分析逆向流程 228递归函数str解密 原理就是用数组push最后填充下,然…

ffmpeg在Windows上的安装

首先进入官网Download FFmpeg 选择windows版本下载想要的版本 Gyan.dev的版本可能会更符合Windows标准,而BtbN的版本可能会更加开放和跨平台往下拉选择想要的版本进行下载 我下载的是第一个下载好之后解压文件复制bin目录的路径 接着按照下面的顺序进行环境配置,结束后一路确…

leaflet如何把低层级瓦片在高层级显示

https://leafletjs.cn/reference.html#gridlayer使用了maxNativeZoom属性 示例 let map = L.map("map", {attributionControl: false,maxZoom: 18, }).setView([62, -82], 6);let layer_keepLevel_16 = L.tileLayer("url", {minZoom: 1,maxZoom: 18,maxNat…

Java JVM——11. 执行引擎

1.概述执行引擎属于JVM的下层,里面包括:解释器、即时编译器、垃圾回收器。执行引擎是Java虚拟机核心的组成部分之一。“虚拟机”是一个相对于“物理机”的概念,这两种机器都有代码执行能力,其区别是物理机的执行引擎是直接建立在处理器、缓存、指令集和操作系统层面上的,而…

vue3+vite打包优化

1、清除console和debugger 安装 terser插件npm install terser -Dbuild里添加terserOptions配置// 打包环境移除console.log,debugger terserOptions: { compress: { drop_console: true, drop_debugger: true } }, 二、gzip静态资源压缩 第一步:客户端打包开启首先下载 vit…

Java JVM 执行引擎深入解析

1.执行引擎概述执行引擎属于JVM的下层,里面包括:解释器、即时编译器、垃圾回收器。执行引擎是Java虚拟机核心的组成部分之一。“虚拟机”是一个相对于“物理机”的概念,这两种机器都有代码执行能力,其区别是物理机的执行引擎是直接建立在处理器、缓存、指令集和操作系统层面…

Vuex

Vuex 什么是Vuex? 概念:专门在Vue中实现集中式状态(数据)管理的一个Vue插件,对应用中多个组件的共享状态进行集中式管理(读/写),也是组件间通信的方式,且适用于任意组件间通信 之前想要传递数据,可以使用全局事件总线/消息订阅去实现,但是如果有很多组件都想要去读和写…

27-String类

String字符串是常量,创建之后不可改变 字符串字面值存储在字符串池中,可以共享 String s = "hello"; 产生一个对象,字符串池中存储 String s = new String("hello");//产生两个对象,堆、池各存储一个String name = "hello";//"hello…

01字典树和可持久化01字典树

01字典树 01字典树是一种只有0和1两种边的字典树。可以解决查询第 \(k\) 小,查询 \(x\) 是第几小等问题。 查询第 \(k\) 小 可以把输入的数转成等长二进制,然后插入01字典树。比如将 \([0,0,1,3,3]\) 插入字典树:这里红色数字表示以该段为前缀的数的个数,黑色表示对应的数。…

c# , net 创建树形结构,创建树形节点

/// <summary> /// 生成树形结构 /// </summary> public void GetTreeNode() {//SqlHelper.GetSqlDataReader是封装的查询数据库语句,可根据自己需求封装//假设获取所有一级节点List<Products> products = SqlHelper.GetSqlDataReader(sql);for (int i = 0; …

abc360 E 题解

E 对于位置2~n,它们的概率是相等的。 n*n个(x,y)对。其中x可以等于y。对于x/y,y的逆元rev(y)为mul(y,mod-2)。 加、减、乘、除都可以做。比如48/9和16/3的结果是一样的,48*rev(9)%mod = 16*rev(3)%mod。比如3*rev(2)%mod = (rev(2)+rev(2)+rev(2))%mod.对于每次操作,有多少…

数业智能荣登「全球应用算法模型大赛50强」

近日,由上海市经济和信息化委员会、上海市普陀区人民政府,上海市人工智能行业协会主办,上海人工智能研究院等单位联合承办的《BPAA第四届全球应用算法模型典范大赛》经过一个多月的角逐,最终公布《BPAA第四届全球应用算法模型典范大赛TOP50榜单》。数业智能心大陆凭借独立自…

快速调用 GLM-4-9B-Chat 语言模型

一、确认本机显卡配置二、下载大模型 国内可以从魔搭社区下载, 下载地址:https://modelscope.cn/models/ZhipuAI/glm-4-9b-chat/files 三、运行官方代码import torch from transformers import AutoModelForCausalLM, AutoTokenizerdevice = "cuda"tokenizer = A…

戴尔服务器SQL server数据恢复

服务器数据恢复环境: 一台Dell服务器,共有10块硬盘,配置了raid5磁盘阵列,操作系统:linux,里面存有SQL server数据库。服务器数据恢复故障检测分析: 服务器在正常运行过程中,对服务器进行重装系统操作,操作成功后发现服务器的磁盘分区与原来不同,其中一个分区丢失,其…

网络安全:Nginx安全问题使1400多万台服务器容易受到ddos攻击

据外媒报道,近日 nginx 被爆出存在安全问题,有可能会致使 1400 多万台服务器易遭受 DoS 攻击。 而导致安全问题的漏洞存在于 HTTP/2 和 MP4 模块中。 新版本的Nginx Web服务器已于11月6日发布,用于修复影响1.15.6,1.14.1之前版本的多个安全问题, 该漏洞允许潜在的攻击者触发…

服务器硬盘亮红灯数据恢复

故障服务器数据恢复环境: 一台故障服务器,有3块SAS 320GB的硬盘组建的raid5磁盘阵列。 故障服务器数据恢复检测分析: 服务器运行过程中有一块硬盘的指示灯变为红色,raid5磁盘阵列出现故障,服务器上层操作系统的分区无法识别。服务器数据恢复过程: 1、将故障服务器上磁盘编…

服务器RAID5故障该如何解决

故障服务器恢复环境: 一台HP LH6000的服务器,4块18GB的硬盘做成RAID5磁盘阵列,操作系统为Window 2000,数据库是Server 2000。 故障服务器检测分析: 故障服务器经检测发现,一块硬盘红灯闪亮,机器还在正常运行,但没有多久,系统就不能正常运行,这时才发现另一块硬盘的红…

存储断电导致虚拟机无法启动

故障存储虚拟机环境: 一台VMware虚拟机无法启动(虚拟机中存储了oracle数据库)。故障存储虚拟机检测分析: 发生故障的存是由于机房意外断电导致,清空cache并尝试重新启动该虚拟机但失败。需要对该存储进行数据恢复。 故障虚拟机数据恢复流程: 1.合并虚拟机快照(因虚拟机中…