🚀 camembert-base-lleqa
このモデルはsentence-transformersを使用しており、文章や段落を768次元の密ベクトル空間にマッピングします。クラスタリングや意味検索などのタスクに使用できます。このモデルは、フランス語の法的情報検索のためにLLeQAデータセットで学習されています。
🚀 クイックスタート
このモデルは、文章や段落を768次元の密ベクトル空間にマッピングし、クラスタリングや意味検索などのタスクに使用できます。
✨ 主な機能
- 文章や段落を768次元の密ベクトル空間にマッピングする。
- クラスタリングや意味検索などのタスクに使用できる。
- フランス語の法的情報検索のために学習されている。
📦 インストール
Sentence-Transformers
sentence-transformersをインストールすると、このモデルを簡単に使用できます。
pip install -U sentence-transformers
💻 使用例
基本的な使用法
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('maastrichtlawtech/camembert-base-lleqa')
embeddings = model.encode(sentences)
print(embeddings)
高度な使用法
sentence-transformersを使用せずに、このモデルを使用することもできます。まず、入力をTransformerモデルに通し、その後、文脈化された単語埋め込みの上に適切なプーリング操作を適用する必要があります。
from transformers import AutoTokenizer, AutoModel
import torch
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0]
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
sentences = ['This is an example sentence', 'Each sentence is converted']
tokenizer = AutoTokenizer.from_pretrained('maastrichtlawtech/camembert-base-lleqa')
model = AutoModel.from_pretrained('maastrichtlawtech/camembert-base-lleqa')
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
with torch.no_grad():
model_output = model(**encoded_input)
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print(sentence_embeddings)
📚 ドキュメント
評価
このモデルは、LLeQAのテストセットで評価されています。このセットは、27.9Kの候補記事の知識コーパスを持つ195の法的質問で構成されています。平均逆順位(MRR)、正規化割引累積ゲイン(NDCG)、平均平均精度(MAP)、およびさまざまなカットオフでの再現率(R@k)を報告しています。
MRR@10 |
NDCG@10 |
MAP@10 |
R@10 |
R@100 |
R@500 |
36.55 |
39.27 |
30.64 |
58.27 |
82.43 |
92.41 |
学習
背景
このモデルは、camembert-baseモデルを利用し、9.3Kのフランス語の質問-記事ペアで微調整されています。対照学習の目的で使用されており、与えられた短い法的質問に対して、サンプリングされた法的記事のセットの中から、実際にデータセットでペアになっている記事を予測する必要があります。正式には、バッチ内のすべての可能なペアからコサイン類似度を計算します。その後、真のペアと比較して温度0.05の交差エントロピー損失を適用します。
ハイパーパラメータ
このモデルは、32GBのメモリを持つ単一のTesla V100 GPUで20エポック(すなわち5.4kステップ)、バッチサイズ32で学習されました。AdamWオプティマイザを使用し、初期学習率は2e-05、重み減衰は0.01、最初の50ステップで学習率をウォームアップし、学習率を線形減衰させました。シーケンス長は384トークンに制限されています。
データ
このモデルは、Long-form Legal Question Answering (LLeQA)データセットを使用して微調整されています。LLeQAは、法的情報検索と質問応答を研究するためのフランス語のネイティブデータセットです。ベルギーの法律から収集された27,941の法定記事の知識コーパスと、ベルギーの市民によって提起され、経験豊富な法学者によってコーパスからの関連記事に根ざした包括的な回答でラベル付けされた1,868の法的質問で構成されています。
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。
🔧 技術詳細
属性 |
详情 |
パイプラインタグ |
文章の類似度 |
言語 |
フランス語 |
ライセンス |
Apache-2.0 |
データセット |
maastrichtlawtech/lleqa |
評価指標 |
再現率 |
タグ |
特徴抽出、文章の類似度 |
ライブラリ名 |
sentence-transformers |
推論 |
有効 |
📚 引用
@article{louis2023interpretable,
author = {Louis, Antoine and van Dijck, Gijs and Spanakis, Gerasimos},
title = {Interpretable Long-Form Legal Question Answering with Retrieval-Augmented Large Language Models},
journal = {CoRR},
volume = {abs/2309.17050},
year = {2023},
url = {https://arxiv.org/abs/2309.17050},
eprinttype = {arXiv},
eprint = {2309.17050},
}