ziwang-com / AGM

AGM阿格姆:AI基因图谱模型,从token-weight权重微粒角度,探索AI模型,GPT\LLM大模型的内在运作机制。

Home Page:http://www.m-f.vip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

可视化语言模型权重依赖树

ziwang-com opened this issue · comments

https://github.com/rutrastone/tree_vizzer
快速可视化语言模型注意力权重作为依赖树

快速可视化语言模型注意力权重作为依赖树。

首先,创建一个环境并安装依赖项:

conda create -n viz python=3.7
pip install -r requirements.txt
python -m spacy download xx_ent_wiki_sm
调用示例:

python run.py --sentence "The dog chased the cat from the room" --layer 2 --head 3 --attn_dist "mst"
这将使用 SpaCy 多语言模型来标记句子,使用语言模型表示形式(默认为多语言 BERT)对其进行编码,并使用端口 5000 提供依赖树。可以通过在浏览器中访问来访问可视化。在三种方法(、 和 )中,(自然)在返回有效树时效果最好。两者都对分数矩阵没有树限制,因此可以产生不稳定的图形 - 通常节点附加到自己。http://0.0.0.0:5000/mstmaxjsmstmaxjs