diff --git a/PaddleNLP/paddlenlp/embeddings/README.md b/PaddleNLP/paddlenlp/embeddings/README.md index 4f92ab3b704bab3eedc35f5cf67a811744924b67..5234bfb68fd1dba9a6d2896d2d7184acbce781fc 100644 --- a/PaddleNLP/paddlenlp/embeddings/README.md +++ b/PaddleNLP/paddlenlp/embeddings/README.md @@ -56,6 +56,30 @@ print(test_token_embedding) 0.123634 0.282932 0.140399 -0.076253 -0.087103 0.07262 ]] ``` +## 可视化embedding结果 +使用深度学习可视化工具[VisualDL](https://github.com/PaddlePaddle/VisualDL)的High Dimensional组件可以对embedding结果进行可视化展示,便于对其直观分析,步骤如下: +```python +labels = ["中国", "美国", "俄罗斯", "男人", "女人", "猫", "狗", "猪", "蓝色", "黄色"] +test_token_embedding = token_embedding.search(labels) + +# 引入VisualDL的LogWriter记录日志 +from visualdl import LogWriter + +with LogWriter(logdir='./visualize') as writer: + writer.add_embeddings("test_embedding", labels, test_token_embedding) +``` +执行完毕后会在当前路径下生成一个visualize目录,并将日志存放在其中,我们在命令行启动VisualDL即可进行查看,启动命令为: +```shell +visualdl logdir ./visualize +``` +启动后打开浏览器即可看到可视化结果 + +
+
+