Comments (4)
您是指的微调训练吗?微调可以取cls位置的向量作为句子级别的向量
from paddlenlp.
您是指的微调训练吗?微调可以取cls位置的向量作为句子级别的向量
您好,我没有微调训练,是直接用你们训练好的模型的,模型名称为“ernie-health-chinese”。代码如下:
from paddlenlp.transformers import * tokenizer = AutoTokenizer.from_pretrained('ernie-health-chinese') ernie = AutoModel.from_pretrained('ernie-health-chinese') text = tokenizer('心跳加速') emb = ernie(input_ids=paddle.to_tensor([text['input_ids']])) print(emb.shape)
运行结果如下:
D:\Anaconda3\envs\OHCDoctorKnowledge\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") [2024-05-03 09:47:46,101] [ INFO] - We are using <class 'paddlenlp.transformers.electra.tokenizer.ElectraTokenizer'> to load 'ernie-health-chinese'. [2024-05-03 09:47:46,101] [ INFO] - Already cached C:\Users\Evans\.paddlenlp\models\ernie-health-chinese\vocab.txt [2024-05-03 09:47:46,116] [ INFO] - tokenizer config file saved in C:\Users\Evans\.paddlenlp\models\ernie-health-chinese\tokenizer_config.json [2024-05-03 09:47:46,116] [ INFO] - Special tokens file saved in C:\Users\Evans\.paddlenlp\models\ernie-health-chinese\special_tokens_map.json [2024-05-03 09:47:46,116] [ INFO] - We are using <class 'paddlenlp.transformers.electra.modeling.ElectraModel'> to load 'ernie-health-chinese'. [2024-05-03 09:47:46,116] [ INFO] - Already cached C:\Users\Evans\.paddlenlp\models\ernie-health-chinese\ernie-health-chinese.pdparams W0503 09:47:46.116991 23592 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 12.0, Runtime API Version: 11.7 W0503 09:47:46.116991 23592 gpu_resources.cc:91] device: 0, cuDNN Version: 8.5. [1, 6, 768]
可以发现,输出的形状是按照字输出的,如果直接用你们训练好的这个模型,也可以用最后一个字的输出作为整个句子的语义表示吗?另外,我试了一下"ernie-3.0-medium-zh"模型,这个输出是两个tensor,第一个是按字的sequence_output输出[1,字数+2,768],另一个是[1,768]的pooled_output整句输出,按字的输出最后一个字的向量和pooled_output是不一样的。我是深度学习小白,给您添麻烦了,感谢!
from paddlenlp.
最后一个一般是sep的token向量,不建议作为句子向量,建议还是cls位置,或者使用polled_output也行,polled_output一般是在token后面接入了linear层才输出的。
from paddlenlp.
最后一个一般是sep的token向量,不建议作为句子向量,建议还是cls位置,或者使用polled_output也行,polled_output一般是在token后面接入了linear层才输出的。
好的好的,十分感谢您!
from paddlenlp.
Related Issues (20)
- [Bug]: paddle的nansum不支持empty的求和
- [Bug]: Taskflow("document_intelligence"): Illegal instruction (core dumped) HOT 7
- [Bug]: AutoModel加载本地路径模型报错 HOT 2
- UTC做多标签零样本训练,测试出现过拟合怎么办?
- [Question]: 语义检索Pipelines,召回速度 HOT 1
- [Bug]:UIE-X-base模型微调报错 HOT 2
- taskflow和fastdeploy放在一起会产生中断,是怎么回事呢? HOT 4
- [Question]: PaddleOCR detection and recognition models for PaddleNLP UIE HOT 1
- [Docs]: PaddleNLP/pipelines/examples /sentiment_analysis 这个例子按照文档就从来没有运行成功过,有运行成功的吗?
- [Bug]: Temperature参数似乎没有生效 HOT 4
- [Question]:如何设置多卡pipline并行推理? HOT 2
- paddlepaddle/paddle:2.6.1-gpu-cuda11.2-cudnn8.2-trt8.0容器太大了多大21G,有什么办法进行瘦身 HOT 1
- [Question]: 自制数据集的问题 HOT 1
- [Bug]: 模型微调遇到问题 HOT 1
- UIE-X训练时候支持自定义OCR HOT 2
- [Question]: [Hint: Expected meta_.is_contiguous() == true, but received meta_.is_contiguous():0 != true:1.] (at /paddle/paddle/phi/core/dense_tensor_impl.cc:283) [operator < reshape2 > error] HOT 1
- [Question]: 在语义检索中使用in batch negative训练 HOT 1
- [Question]: 关于微调和推理时max_seq_len参数的设置问题
- [Question]: 如何设置多卡pipline并行推理? HOT 1
- [Bug]: Chatglm3 相关代码 在设置多卡推理报错 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paddlenlp.