模型简介
模型特点
模型能力
使用案例
base_model: BAAI/bge-m3 datasets: [] language:
- es library_name: sentence-transformers license: apache-2.0 metrics:
- cosine_accuracy@1
- cosine_accuracy@3
- cosine_accuracy@5
- cosine_accuracy@10
- cosine_precision@1
- cosine_precision@3
- cosine_precision@5
- cosine_precision@10
- cosine_recall@1
- cosine_recall@3
- cosine_recall@5
- cosine_recall@10
- cosine_ndcg@10
- cosine_mrr@10
- cosine_map@100 pipeline_tag: sentence-similarity tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:21352
- loss:MatryoshkaLoss
- loss:MultipleNegativesRankingLoss widget:
- source_sentence: 国家超高速网络战略旨在推动固定和移动宽带超高速接入网络的部署,以实现其普及化,并促进公民、企业和政府机构采用,确保社会和领土凝聚力。
sentences:
- 债务豁免的主要目标是什么?
- 什么是入侵物种?
- 国家超高速网络战略的目标是什么?
- source_sentence: 安达卢西亚自治区预算法可更新本规范所载处罚金额。
sentences:
- 哪项法律涉及处罚金额的更新?
- 授予首次占用许可证和许可需要什么条件?
- 成瘾性疾病战略计划的目标是什么?
- source_sentence: 第154条。通过条约将宪法衍生的权力授予国际组织或机构,需事先经议会批准授权组织法,该法将按照本规章对此类法律的规定进行处理。
sentences:
- 用于资助加那利群岛各岛屿定期旅客运输相应需求的金额是多少?
- 最终第三项规定的目的是什么?
- 国际条约签订的程序是什么?
- source_sentence: 最终第三项规定。生效。本皇家法令将在《国家官方公报》发布后的次日生效。
sentences:
- 谁可以签订购买商品或权利的合同?
- 农业工程师官方学院总理事会的资源制度是什么?
- 最终第三项规定的目的是什么?
- source_sentence: 明确终止行政制裁程序的决定的最长解决和通知期限为九个月,自行政制裁程序开始之日起计算,该日期与启动协议日期相对应。
sentences:
- 对于严重或非常严重的违规行为,制裁程序的解决期限是多久?
- 第521/2020号皇家法令规定了什么?
- 西班牙合作在可持续发展中关于性别平等的目标是什么? model-index:
- name: BGE large Legal Spanish
results:
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 1024
type: dim_1024
metrics:
- type: cosine_accuracy@1 value: 0.6257901390644753 name: Cosine Accuracy@1
- type: cosine_accuracy@3 value: 0.7450484618626212 name: Cosine Accuracy@3
- type: cosine_accuracy@5 value: 0.7833965444584914 name: Cosine Accuracy@5
- type: cosine_accuracy@10 value: 0.8314369995785925 name: Cosine Accuracy@10
- type: cosine_precision@1 value: 0.6257901390644753 name: Cosine Precision@1
- type: cosine_precision@3 value: 0.24834948728754036 name: Cosine Precision@3
- type: cosine_precision@5 value: 0.15667930889169826 name: Cosine Precision@5
- type: cosine_precision@10 value: 0.08314369995785924 name: Cosine Precision@10
- type: cosine_recall@1 value: 0.6257901390644753 name: Cosine Recall@1
- type: cosine_recall@3 value: 0.7450484618626212 name: Cosine Recall@3
- type: cosine_recall@5 value: 0.7833965444584914 name: Cosine Recall@5
- type: cosine_recall@10 value: 0.8314369995785925 name: Cosine Recall@10
- type: cosine_ndcg@10 value: 0.7275988588052974 name: Cosine Ndcg@10
- type: cosine_mrr@10 value: 0.6944890935725317 name: Cosine Mrr@10
- type: cosine_map@100 value: 0.69913132313913 name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 768
type: dim_768
metrics:
- type: cosine_accuracy@1 value: 0.6211546565528866 name: Cosine Accuracy@1
- type: cosine_accuracy@3 value: 0.7488411293721028 name: Cosine Accuracy@3
- type: cosine_accuracy@5 value: 0.7855035819637589 name: Cosine Accuracy@5
- type: cosine_accuracy@10 value: 0.8297513695743785 name: Cosine Accuracy@10
- type: cosine_precision@1 value: 0.6211546565528866 name: Cosine Precision@1
- type: cosine_precision@3 value: 0.2496137097907009 name: Cosine Precision@3
- type: cosine_precision@5 value: 0.15710071639275178 name: Cosine Precision@5
- type: cosine_precision@10 value: 0.08297513695743783 name: Cosine Precision@10
- type: cosine_recall@1 value: 0.6211546565528866 name: Cosine Recall@1
- type: cosine_recall@3 value: 0.7488411293721028 name: Cosine Recall@3
- type: cosine_recall@5 value: 0.7855035819637589 name: Cosine Recall@5
- type: cosine_recall@10 value: 0.8297513695743785 name: Cosine Recall@10
- type: cosine_ndcg@10 value: 0.7262608157638797 name: Cosine Ndcg@10
- type: cosine_mrr@10 value: 0.693076709543207 name: Cosine Mrr@10
- type: cosine_map@100 value: 0.6977729019489064 name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 512
type: dim_512
metrics:
- type: cosine_accuracy@1 value: 0.6186262115465655 name: Cosine Accuracy@1
- type: cosine_accuracy@3 value: 0.7416772018541931 name: Cosine Accuracy@3
- type: cosine_accuracy@5 value: 0.7812895069532237 name: Cosine Accuracy@5
- type: cosine_accuracy@10 value: 0.8284871470712178 name: Cosine Accuracy@10
- type: cosine_precision@1 value: 0.6186262115465655 name: Cosine Precision@1
- type: cosine_precision@3 value: 0.24722573395139766 name: Cosine Precision@3
- type: cosine_precision@5 value: 0.15625790139064477 name: Cosine Precision@5
- type: cosine_precision@10 value: 0.08284871470712177 name: Cosine Precision@10
- type: cosine_recall@1 value: 0.6186262115465655 name: Cosine Recall@1
- type: cosine_recall@3 value: 0.7416772018541931 name: Cosine Recall@3
- type: cosine_recall@5 value: 0.7812895069532237 name: Cosine Recall@5
- type: cosine_recall@10 value: 0.8284871470712178 name: Cosine Recall@10
- type: cosine_ndcg@10 value: 0.7230517414838968 name: Cosine Ndcg@10
- type: cosine_mrr@10 value: 0.6894082903564569 name: Cosine Mrr@10
- type: cosine_map@100 value: 0.6938850125806117 name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 256
type: dim_256
metrics:
- type: cosine_accuracy@1 value: 0.6076696165191741 name: Cosine Accuracy@1
- type: cosine_accuracy@3 value: 0.7378845343447114 name: Cosine Accuracy@3
- type: cosine_accuracy@5 value: 0.7741255794353139 name: Cosine Accuracy@5
- type: cosine_accuracy@10 value: 0.8183733670459334 name: Cosine Accuracy@10
- type: cosine_precision@1 value: 0.6076696165191741 name: Cosine Precision@1
- type: cosine_precision@3 value: 0.2459615114482371 name: Cosine Precision@3
- type: cosine_precision@5 value: 0.15482511588706277 name: Cosine Precision@5
- type: cosine_precision@10 value: 0.08183733670459334 name: Cosine Precision@10
- type: cosine_recall@1 value: 0.6076696165191741 name: Cosine Recall@1
- type: cosine_recall@3 value: 0.7378845343447114 name: Cosine Recall@3
- type: cosine_recall@5 value: 0.7741255794353139 name: Cosine Recall@5
- type: cosine_recall@10 value: 0.8183733670459334 name: Cosine Recall@10
- type: cosine_ndcg@10 value: 0.7129994645749397 name: Cosine Ndcg@10
- type: cosine_mrr@10 value: 0.6792476872754997 name: Cosine Mrr@10
- type: cosine_map@100 value: 0.6839884095309201 name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 128
type: dim_128
metrics:
- type: cosine_accuracy@1 value: 0.5920775389801939 name: Cosine Accuracy@1
- type: cosine_accuracy@3 value: 0.7100716392751791 name: Cosine Accuracy@3
- type: cosine_accuracy@5 value: 0.7496839443742098 name: Cosine Accuracy@5
- type: cosine_accuracy@10 value: 0.8019384745048462 name: Cosine Accuracy@10
- type: cosine_precision@1 value: 0.5920775389801939 name: Cosine Precision@1
- type: cosine_precision@3 value: 0.23669054642505968 name: Cosine Precision@3
- type: cosine_precision@5 value: 0.14993678887484196 name: Cosine Precision@5
- type: cosine_precision@10 value: 0.0801938474504846 name: Cosine Precision@10
- type: cosine_recall@1 value: 0.5920775389801939 name: Cosine Recall@1
- type: cosine_recall@3 value: 0.7100716392751791 name: Cosine Recall@3
- type: cosine_recall@5 value: 0.7496839443742098 name: Cosine Recall@5
- type: cosine_recall@10 value: 0.8019384745048462 name: Cosine Recall@10
- type: cosine_ndcg@10 value: 0.6949442438058356 name: Cosine Ndcg@10
- type: cosine_mrr@10 value: 0.6609599395313674 name: Cosine Mrr@10
- type: cosine_map@100 value: 0.6660375960675697 name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 64
type: dim_64
metrics:
- type: cosine_accuracy@1 value: 0.5478297513695743 name: Cosine Accuracy@1
- type: cosine_accuracy@3 value: 0.6696165191740413 name: Cosine Accuracy@3
- type: cosine_accuracy@5 value: 0.7218710493046776 name: Cosine Accuracy@5
- type: cosine_accuracy@10 value: 0.7707543194268858 name: Cosine Accuracy@10
- type: cosine_precision@1 value: 0.5478297513695743 name: Cosine Precision@1
- type: cosine_precision@3 value: 0.2232055063913471 name: Cosine Precision@3
- type: cosine_precision@5 value: 0.14437420986093552 name: Cosine Precision@5
- type: cosine_precision@10 value: 0.07707543194268857 name: Cosine Precision@10
- type: cosine_recall@1 value: 0.5478297513695743 name: Cosine Recall@1
- type: cosine_recall@3 value: 0.6696165191740413 name: Cosine Recall@3
- type: cosine_recall@5 value: 0.7218710493046776 name: Cosine Recall@5
- type: cosine_recall@10 value: 0.7707543194268858 name: Cosine Recall@10
- type: cosine_ndcg@10 value: 0.6562208551738911 name: Cosine Ndcg@10
- type: cosine_mrr@10 value: 0.6198663536210937 name: Cosine Mrr@10
- type: cosine_map@100 value: 0.6253208234320395 name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 1024
type: dim_1024
metrics:
BGE 大型法律西班牙语模型
这是一个基于 BAAI/bge-m3 微调的 sentence-transformers 模型。它将句子和段落映射到1024维的密集向量空间,可用于语义文本相似度、语义搜索、复述挖掘、文本分类、聚类等多种任务。
模型详情
模型描述
- 模型类型: 句子转换器
- 基础模型: BAAI/bge-m3
- 最大序列长度: 8192个标记
- 输出维度: 1024个标记
- 相似度函数: 余弦相似度
- 语言: 西班牙语
- 许可证: apache-2.0
模型来源
- 文档: Sentence Transformers 文档
- 代码库: Sentence Transformers GitHub
- Hugging Face: Sentence Transformers 模型库
完整模型架构
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
(1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Normalize()
)
使用方式
直接使用 (Sentence Transformers)
首先安装 Sentence Transformers 库:
pip install -U sentence-transformers
然后可以加载此模型并运行推理:
from sentence_transformers import SentenceTransformer
# 从 🤗 Hub 下载
model = SentenceTransformer("littlejohn-ai/bge-m3-spanish-boe-qa")
# 运行推理
sentences = [
'明确终止行政制裁程序的决定的最长解决和通知期限为九个月,自行政制裁程序开始之日起计算,该日期与启动协议日期相对应。',
'对于严重或非常严重的违规行为,制裁程序的解决期限是多久?',
'西班牙合作在可持续发展中关于性别平等的目标是什么?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# 获取嵌入向量的相似度分数
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
评估
指标
信息检索
- 数据集:
dim_1024
- 使用
InformationRetrievalEvaluator
评估
指标 | 值 |
---|---|
cosine_accuracy@1 | 0.6258 |
cosine_accuracy@3 | 0.745 |
cosine_accuracy@5 | 0.7834 |
cosine_accuracy@10 | 0.8314 |
cosine_precision@1 | 0.6258 |
cosine_precision@3 | 0.2483 |
cosine_precision@5 | 0.1567 |
cosine_precision@10 | 0.0831 |
cosine_recall@1 | 0.6258 |
cosine_recall@3 | 0.745 |
cosine_recall@5 | 0.7834 |
cosine_recall@10 | 0.8314 |
cosine_ndcg@10 | 0.7276 |
cosine_mrr@10 | 0.6945 |
cosine_map@100 | 0.6991 |
训练详情
训练超参数
非默认超参数
eval_strategy
: epochper_device_train_batch_size
: 16per_device_eval_batch_size
: 16gradient_accumulation_steps
: 16learning_rate
: 2e-05num_train_epochs
: 50lr_scheduler_type
: cosinewarmup_ratio
: 0.1bf16
: Truetf32
: Trueload_best_model_at_end
: Trueoptim
: adamw_torch_fusedgradient_checkpointing
: Truebatch_sampler
: no_duplicates
框架版本
- Python: 3.10.12
- Sentence Transformers: 3.0.1
- Transformers: 4.42.3
- PyTorch: 2.1.0+cu118
- Accelerate: 0.32.1
- Datasets: 2.20.0
- Tokenizers: 0.19.1
引用
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
术语表
简介
我们很高兴地宣布完成了针对信息检索增强生成(RAG)应用优化的BGE-M3模型的微调。此次调整使用了包含23,700个法律问题、答案和上下文的详尽数据集,确保在法律领域生成精确且相关的嵌入向量方面表现卓越。
模型规格
- 基础模型: BGE-M3
- 数据集大小: 23,700个法律问题、答案和上下文
- 领域: 法律
- 数据格式: 结构化文本
微调过程
BGE-M3模型的微调采用了先进的优化技术和超参数调整,重点提升其在法律语境下生成高质量嵌入向量的能力。
方法论
-
数据集准备: 整理和预处理来自多个法律领域的23,700条数据,包括问题、答案和详细上下文。
-
训练: 应用监督学习技术调整模型参数,优化其生成嵌入向量的性能。
-
评估: 实施特定指标评估生成嵌入向量的质量和上下文相关性,确保高精度和上下文一致性。
成果与优势
嵌入向量质量
经过精细调整的BGE-M3模型现在能有效捕捉法律语言和上下文的复杂性,显著提高检索信息的准确性和相关性。
实际应用
-
信息检索系统: 提升法律搜索引擎的准确性,快速获取相关文档和判例。
-
虚拟助手: 优化法律聊天机器人和助手,基于复杂上下文提供精确回答。
-
文档分析: 增强从大量法律文本中分析和提取关键信息的能力。
性能评估
- 嵌入向量准确率: 针对特定法律查询的嵌入向量生成精度提升84%。
- 上下文相关性: 检索信息的连贯性和相关性提高67%。
- 处理时间: 生成和检索相关信息所需时间减少16%。
结论
这一进展使BGE-M3模型成为法律领域信息检索应用的重要工具,便于获取专业知识并提高法律服务效率。我们邀请社区探索并利用这一调整后的模型,以增强其法律应用。
模型获取
为RAG调整的BGE-M3模型可供实施和使用。我们鼓励开发者和法律专业人士将此资源集成到他们的系统中,并与社区分享成果和经验。







