PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.17k stars 2.94k forks source link

[Question]: 打印模型信息 #5975

Open DeqianBai opened 1 year ago

DeqianBai commented 1 year ago

请提出你的问题

如题,paddlenlp 能不能像抱抱脸那样打印模型信息,如何打印呢,我查了文档没找到方法

我找了找也在群里问了一下,有人说用paddle.summary(),然后我就测试了一下: `tokenizer = AutoTokenizer.from_pretrained("uie-base") model = UIE.from_pretrained("uie-base")

text = "你的输入文本" inputs = tokenizer(text, return_tensors='np') print(inputs) input_ids = inputs['input_ids'] token_type_ids = inputs['token_type_ids'] paddle.summary(model, (input_ids, token_type_ids))`

但是报错了,我主要想打印一下ERNIE 3.0和uie的模型信息,可否提供一个可以运行的示例,谢谢~

w5688414 commented 6 months ago

请参考下面的例子:

from paddlenlp.transformers import UIE, AutoTokenizer
import paddle
tokenizer = AutoTokenizer.from_pretrained("uie-base")
model = UIE.from_pretrained("uie-base")
paddle.summary(model, (1,128),dtypes=['int64'])