プロジェクト| Huggingface | arxiv |ゼノド
階層を言語モデルに埋め込む。
ニュース(changelog)?
sentence-transformers>=3.4.0.dev0 ( v0.1.0 )。 sentence-transformers<3.0.0で動作するはずです)およびバグ修正。 ( v0.0.3 ) 階層変圧器(HIT)は、トランスエンコーダーベースの言語モデル(LMS)が双曲線空間で階層構造を学習できるようにするフレームワークです。主なアイデアは、LMSの出力埋め込みスペースを直接囲み、双曲線空間の指数関数的拡張を活用してエンティティの埋め込みを階層的に整理するポアンカレボールを構築することです。このフレームワークを提示することに加えて(GitHubのコードを参照)、さまざまなHierachiiesでヒットモデルのトレーニングとリリースに取り組んでいます。モデルとデータセットには、Huggingfaceでアクセスできます。
このリポジトリはsentence-transformers Libraryと同様のレイアウトに従います。メインモデルは、文の変圧器アーキテクチャを直接拡張します。また、 deepontoを利用して、ソースデータから階層を抽出し、階層からデータセットを構築し、双曲線空間の算術のためにgeoopt 。
sentence-transformers=3.3.1の現在のリリースには、評価中にバグが含まれています。これは、GitHub Devバージョンのsentence-transformers=3.4.0.dev0で修正されています。公式3.4.0がリリースされるまで依存関係を手動で更新してください。
# requiring Python>=3.9
pip install hierarchy_transformerspip install git+https://github.com/KRR-Oxford/HierarchyTransformers.gitヒットモデルとデータセットは、Huggingface Hubでリリースされます。
from hierarchy_transformers import HierarchyTransformer
# load the model
model = HierarchyTransformer . from_pretrained ( 'Hierarchy-Transformers/HiT-MiniLM-L12-WordNetNoun' )
# entity names to be encoded.
entity_names = [ "computer" , "personal computer" , "fruit" , "berry" ]
# get the entity embeddings
entity_embeddings = model . encode ( entity_names )エンティティの埋め込みを使用して、それらの間の包含関係を予測します。
# suppose we want to compare "personal computer" and "computer", "berry" and "fruit"
child_entity_embeddings = model . encode ([ "personal computer" , "berry" ], convert_to_tensor = True )
parent_entity_embeddings = model . encode ([ "computer" , "fruit" ], convert_to_tensor = True )
# compute the hyperbolic distances and norms of entity embeddings
dists = model . manifold . dist ( child_entity_embeddings , parent_entity_embeddings )
child_norms = model . manifold . dist0 ( child_entity_embeddings )
parent_norms = model . manifold . dist0 ( parent_entity_embeddings )
# use the empirical function for subsumption prediction proposed in the paper
# `centri_score_weight` and the overall threshold are determined on the validation set
subsumption_scores = - ( dists + centri_score_weight * ( parent_norms - child_norms ))リポジトリのサンプルスクリプトを使用して、既存のモデルを再現し、独自のモデルをトレーニング/評価します。
Copyright 2023 Yuan He.
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at *<http://www.apache.org/licenses/LICENSE-2.0>*
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
このリポジトリまたはリリースされたモデルが有用であることがわかった場合は、私たちの出版物を引用してください。
Yuan He、Zhangdie Yuan、Jiaoyan Chen、Ian Horrocks。階層エンコーダーとしての言語モデル。 Neurips 2024に登場。 /arxiv / /neurips /
@article{he2024language,
title={Language Models as Hierarchy Encoders},
author={He, Yuan and Yuan, Zhangdie and Chen, Jiaoyan and Horrocks, Ian},
journal={arXiv preprint arXiv:2401.11374},
year={2024}
}