使用华为云免费资源训练Paddle UIE模型

news/2025/2/21 6:26:33/

一、创建虚拟环境

好习惯,首先创建单独的运行环境

conda create -n uie python=3.10.9
conda activate uie

二、安装paddle框架及paddlenlp

2.1 参考官方文档安装paddle

开始使用_飞桨-源于产业实践的开源深度学习平台

首先查看自己服务器cuda版本,如下我的版本时10.2

(PyTorch-1.8) [ma-user work]$nvidia-smi
Wed Apr 19 23:35:11 2023       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01    Driver Version: 440.33.01    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla P100-PCIE...  Off  | 00000000:00:0E.0 Off |                    0 |
| N/A   39C    P0    28W / 250W |      0MiB / 16280MiB |      0%      Default |
+-------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

在Paddle官网直接复制命令即可。

2.2  安装paddlenlp 

pip install --upgrade paddlenlp 

2.2.1 问题一 ERROR: Failed building wheel for numpy Failed to build numpy

-x86_64-3.10/numpy/core/src/multiarray/scalartypes.o -MMD -MF build/temp.linux-x86_64-3.10/build/src.linux-x86_64-3.10/numpy/core/src/multiarray/scalartypes.o.d" failed with exit status 1[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.ERROR: Failed building wheel for numpyFailed to build numpyERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error× pip subprocess to install backend dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.note: This error originates from a subprocess, and is likely not a problem with pip

手工安装numpy包,再次执行nlp包安装,还是不行。 

pip install numpy

换另外一种方式成功

python3 -m pip install --upgrade paddlenlp -i https://mirror.baidu.com/pypi/simple

三、下载PaddleNLP源码

$git clone https://github.com/PaddlePaddle/PaddleNLP.git

四、执行训练

4.1、对标注数据进行预处理

python ../PaddleNLP/model_zoo/uie/doccano.py --doccano_file ./data.json --task_type ext --save_dir ./ --splits 0.7 0.2 0.1 --schema_lang ch

4.2、模型精调

$python ../PaddleNLP/model_zoo/uie/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 ./train.txt  --dev_path ./dev.txt   --max_seq_length 512      --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

出现下图及训练成功 

 五、模型应用

from pprint import pprint
from paddlenlp import Taskflow
schema = ['时间', '地区', '指标名']
ie = Taskflow('information_extraction', schema=schema, task_path="./checkpoint/model_best")
pprint(ie("我想查询2022年山东省主营业务收入数据"))


http://www.ppmy.cn/news/48942.html

相关文章

线性表总结

线性表 目录: 文章目录 线性表概念一、线性表的定义二、线性表的基本操作三、线性表的实现方式四、线性表的应用总结 概念 线性表是一种基本的数据结构,由一系列具有相同类型的数据元素构成,这些元素之间具有线性的顺序关系,每个…

【代码调试】《Frustratingly Simple Few-Shot Object Detection》

更多问题可参考: https://blog.csdn.net/qiankendeNMY/article/details/128450196 论文地址:https://arxiv.org/abs/2003.06957 论文代码:https://github.com/ucbdrive/few-shot-object-detection 我的配置: Python &#xff1a…

axf文件、hex文件、bin文件区别

axf文件、hex文件与bin文件都可以运行在stm32,都存储了源代码通过编译器生成的机器码。 axf文件:编译默认生成的文件,包含代码数据和调试信息,在MDK里进行debug调试用的文件。 hex文件:使用十六进制符号表示的代码记…

校招又临近了,怎么在面试中应对设计模式相关问题呢?

夏天开始了,那么夏天结束时的毕业季也不远了。毕业是个伤感、期待而又略带残酷的时节,就像蜜桃无论成熟与否都会在这个时间被采摘,如果毫无准备就踏入社会,就会……马上变成低级社畜。所以说还是要早点为了毕业找工作做点准备&…

ElasticSearch集群搭建

一、ElasticSearch 集群 1.1 搭建集群 Elasticsearch如果做集群的话Master节点至少三台服务器或者三个Master实例加入相同集群,三个Master节点最多只能故障一台Master节点,如果故障两个Master节点,Elasticsearch将无法组成集群.会报错&…

设计模式详解-软件设计(五十六)

原创 真题详解(UML图)-软件设计(五十五)https://blog.csdn.net/ke1ying/article/details/130311994 创建型、结构型、行为型 抽象工厂(Abstruct Factory) 提供一个创建系列相关或相互依赖的接口,无须指定他们具体的类。 适用于&…

垃圾回收概述

什么是垃圾 垃圾收集,不是Java语言的伴生产物。早在1960年,第一门开始使用内存动态分配和垃圾收集技术的Lisp语言诞生。 关于垃圾收集有三个经典问题: 哪些内存需要回收?什么时候回收?如何回收? 垃圾收…

轻松掌握k8s的kubectl使用命令行操作Ingress知识点03

1、Ingress将所有Service统一网关入口 底层也是使用了nginx,所以使用Ingress才是整个项目的统一入口。 官网地址:https://kubernetes.github.io/ingress-nginx/ 1、安装 先下载安装文件 wget https://raw.githubusercontent.com/kubernetes/ingress-…