/ Модель

Характеристики

Контекст
4 096 токенов
Параметры
137 млн
Лицензия
Apache 2.0
Архитектура
bert · dense
Опубликована
25 авг 2023

lodestone-base-4096-v1

ЭмбеддингиТекст → embedding11 профессий

Англоязычная BERT-модель Hum-Works создаёт 768-мерные эмбеддинги длинных текстов для семантического поиска, сравнения и кластеризации.

191скачиваний за 30 дней12лайковвеса обновлены26 окт 2023

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Эмбеддинги» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки20

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

  • TweetTopicSingleClassification

    main_score

    Результат

    0,2222

    MTEB

    Публичная таблицаревизия совпадает

  • MassiveScenarioClassification

    main_score

    Результат

    0,1394

    Общий результат 0,1679Общий результат 0,1654Общий результат 0,142
    MTEB

    Публичная таблицаревизия совпадает

  • CBD

    main_score

    Результат

    0,4721

    MTEB

    Публичная таблицаревизия совпадает

  • SIB200ClusteringS2S

    main_score

    Результат

    0,0111

    Общий результат 0,0268Общий результат 0,0179Общий результат 0,0176
    MTEB

    Публичная таблицаревизия совпадает

  • XNLI

    main_score

    Результат

    0,5055

    Общий результат 0,5006
    MTEB

    Публичная таблицаревизия совпадает

  • JSICK

    main_score

    Результат

    0,4303

    MTEB

    Публичная таблицаревизия совпадает

  • Tatoeba

    main_score

    Результат

    0,0019

    Общий результат 0,0082Общий результат 0,0048Общий результат 0,0043
    MTEB

    Публичная таблицаревизия совпадает

  • RomaniBibleClustering

    main_score

    Результат

    0,3499

    MTEB

    Публичная таблицаревизия совпадает

  • MassiveIntentClassification

    main_score

    Результат

    0,1253

    Общий результат 0,178Общий результат 0,1355Общий результат 0,1199
    MTEB

    Публичная таблицаревизия совпадает

  • IndicGenBenchFloresBitextMining

    main_score

    Результат

    0

    Общий результат 0,0004Общий результат 0,0001Общий результат 0
    MTEB

    Публичная таблицаревизия совпадает

  • CQADupstackEnglishRetrieval

    main_score

    Результат

    0,3545

    MTEB

    Публичная таблицаревизия не подтверждена

  • MasakhaNEWSClusteringS2S

    main_score

    Результат

    0,0257

    MTEB

    Публичная таблицаревизия совпадает

  • PpcPC

    main_score

    Результат

    0,7019

    MTEB

    Публичная таблицаревизия совпадает

  • CQADupstackStatsRetrieval

    main_score

    Результат

    0,2596

    MTEB

    Публичная таблицаревизия не подтверждена

  • MultiHateClassification

    main_score

    Результат

    0,4903

    MTEB

    Публичная таблицаревизия совпадает

  • TwitterSemEval2015

    main_score

    Результат

    0,6767

    MTEB

    Публичная таблицаревизия не подтверждена

  • CQADupstackMathematicaRetrieval

    main_score

    Результат

    0,2086

    MTEB

    Публичная таблицаревизия не подтверждена

  • SemRel24STS

    main_score

    Результат

    0,3104

    MTEB

    Публичная таблицаревизия совпадает

  • MTOPDomainClassification

    main_score

    Результат

    0,2958

    MTEB

    Публичная таблицаревизия совпадает

  • NusaTranslationBitextMining

    main_score

    Результат

    0,0631

    MTEB

    Публичная таблицаревизия совпадает

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

lodestone-base-4096-v1 — модель эмбеддингов предложений и абзацев от Hum-Works, созданная Griffin McCauley, Will Fortin и Dylan DiGioia в 2023 году. Это дообученная версия mosaic-bert-base-seqlen-2048: архитектура BERT с FlashAttention, ALiBi и GLU, около 136,7 млн параметров. Модель кодирует текст в плотный вектор размерности 768 для поиска по смыслу, сравнения текстов и кластеризации.

Модель рассчитана на длинные предложения и абзацы: поддерживает последовательности до 4096 токенов, хотя при обучении использовалась длина до 2048 токенов. Она обучена контрастивным методом на большом наборе пар текстов и показывает сопоставимые результаты со стандартными моделями эмбеддингов на типовых бенчмарках. Основной язык карточки — английский; среди источников обучения указаны датасеты вопросов и ответов, научных текстов, Reddit и поиска кода.

Лицензия — Apache-2.0. В README отмечены ограниченный размер обучающего батча и недостаток примеров максимально допустимой длины, поэтому качество эмбеддингов для очень длинных текстов может требовать дополнительной настройки. README также предупреждает о возможных смещениях в данных Reddit.

Сценарии применения

  • семантический поиск по длинным документам
  • поиск похожих вопросов и ответов
  • сравнение смысловой близости текстов
  • кластеризация предложений и абзацев
  • поиск кода по текстовому запросу

Ограничения

Хотя модель принимает до 4096 токенов, обучение проводилось на длине до 2048, а обучающие тексты не обязательно достигали максимальной длины; для очень длинных текстов качество может быть ниже. Небольшой размер обучающего батча и возможные смещения в части данных Reddit также могут влиять на результаты.

Для каких профессий подходит11

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

lodestone-base-4096-v1

Hum-Works/lodestone-base-4096-v1. Griffin McCauley, Will Fortin, Dylan DiGioia 2023

This new sentence-transformers model from Hum maps long sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.

Abstract

In the hopes of furthering Hum's overarching mission of increasing the accessibility and interconnectivity of human knowledge, this model was developed as part of a project intending to boost the maximum input sequence length of sentence embedding models by leveraging recent architectural advances in the design of transformer models such as the incorporation of FlashAttention, Attention with Linear Biases (ALiBi), and Gated Linear Units (GLU). These modifications and enhancements were implemented by the team at MosaicML who designed and constructed the pre-trained mosaic-bert-base-seqlen-2048 model, and more information regarding the details of their development and testing specifications can be found on the model card.

While the fine-tuning procedure followed during the course of this project loosely mirrors that of the of the original Flax-sentence-embeddings team responsible for the creation of many other popular sentence-transformers models (e.g. all-mpnet-base-v2, all-distilroberta-v1, and all-MiniLM-L6-v2), our methodology includes novel techniques for data loading, batch sampling, and model checkpointing intended to improve training efficiency with regards to memory allocation and data storage.

Through combining these well-established and proven fine-tuning practices with novel advances in transformer architectural elements, our lodestone-base-4096-v1 model is able to achieve comparable performance metrics on standard text embedding evaluation benchmarks while also supporting a longer and more robust input sequence length of 4096 while retaining a smaller, more manageable size capable of being run on either a GPU or CPU.

Usage

Using this model becomes relatively easy when you have sentence-transformers installed. At the time of publishing, sentence-transformers does not support remote code which is required for flash-attention used by the model. A fork of the sentence-transformers repository that allows remote code execution is provided for convenience. It can be installed using the following command:

pip install git+https://github.com/Hum-Works/sentence-transformers.git
pip install einops

Then you can use the model like this:

from sentence_transformers import SentenceTransformer

model = SentenceTransformer('Hum-Works/lodestone-base-4096-v1', trust_remote_code=True, revision='v1.0.0')
sentences = ["This is an example sentence", "Each sentence is converted"]
embeddings = model.encode(sentences)
print(embeddings)

Note: The model will use the openAI/Triton implementation of FlashAttention if installed. This is more performant than the fallback, torch implementation. Some platforms and GPUs may not be supported by Triton - up to date compatibility can be found on Triton’s github page.


Background

The project aims to train sentence embedding models on very large sentence level datasets using a self-supervised contrastive learning objective. We used the pretrained mosaic-bert-base-seqlen-2048 model and fine-tuned it on a nearly 1.5B sentence pairs dataset. We use a contrastive learning objective: given a sentence from the pair, the model should predict which out of a set of randomly sampled other sentences, was actually paired with it in our dataset.

Intended uses

Our model is intended to be used as a long sentence and paragraph encoder. Given an input text, it outputs a vector containing the semantic information. The sentence vector may be used for information retrieval, clustering, or sentence similarity tasks.

Training procedure

Pre-training

We use the pretrained mosaic-bert-base-seqlen-2048. Please refer to the model card for more detailed information about the pre-training procedure.

Fine-tuning

We fine-tune the model using a contrastive objective. Formally, we compute the dot product of each possible sentence pairing in the batch. We then apply the cross entropy loss by comparing with true pairs.

Hyperparameters

We trained our model on an ml.g5.4xlarge EC2 instance with 1 NVIDIA A10G Tensor Core GPU. We train the model during 1.4 million steps using a batch size of 16. We use a learning rate warm up of 500. The sequence length during training was limited to 2048 tokens. We used the AdamW optimizer with a 2e-5 learning rate and weight decay of 0.01 (i.e. the default parameter values for SentenceTransformer.fit()). The full training script is accessible in this current repository: Training.py.

Model Architecture

By incorporating FlashAttention, Attention with Linear Biases (ALiBi), and Gated Linear Units (GLU), this model is able to handle input sequences of 4096, 8x longer than that supported by most comparable sentence embedding models. The model was trained using a sequence length maximum of 2048, but the final model has a maximum sequence length of 4096. This is accomplished by taking advantage of ALiBi’s positional attention extrapolation which has been shown to allow sequence lengths of 2x the initial trained length.

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 4096, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
  (2): Normalize()
)

Training data

We use the concatenation from multiple datasets to fine-tune our model. The total number of sentence pairs is nearly 1.5 billion sentences. We sampled each dataset given a weighted probability proportional to its relative contribution to the entire dataset. The breakdown of the dataset can be seen below, and the entire dataset can be publicly accessed and uploaded via the Dataloading.ipynb located within this repository.

DatasetPaperNumber of training tuples
Reddit comments (2015-2018)paper726,484,430
S2ORC Citation pairs (Abstracts)paper252,102,397
Reddit posts (Title, Body) pairs-127,445,911
Amazon reviews (2018) (Title, Review) pairs-87,877,725
WikiAnswers Duplicate question pairspaper77,427,422
PAQ (Question, Answer) pairspaper64,371,441
S2ORC Citation pairs (Titles)paper52,603,982
S2ORC (Title, Abstract)paper41,769,185
Stack Exchange (Title, Body) pairs-25,368,423
MS MARCO tripletspaper9,144,553
Stack Exchange (Title, Most Upvoted Answer) pairs-4,784,250
Stack Exchange (Title+Body, Most Upvoted Answer) pairs-4,551,660
GOOAQ: Open Question Answering with Diverse Answer Typespaper3,012,496
Amazon QA-2,507,114
Code Search-1,375,067
Yahoo Answers (Title, Answer)paper1,198,260
[AG News]((Title, Description) pairs of news articles from the AG News dataset)-1,157,745
COCO Image captionspaper828,395
SPECTER citation tripletspaper684,100
Yahoo Answers (Question, Answer)paper681,164
Yahoo Answers (Title, Question)paper659,896
CC News (Title, article) pairs-614,664
NPR (Title, Body) pairs-594,384
SearchQApaper582,261
MS Marco (Query, Answer Passage) pairspaper532,751
Stack Exchange (Title, Body) pairs-364,000
Eli5paper325,475
Flickr 30kpaper317,695
CNN & DailyMail (highlight sentences, article) pairs-311,971
Stack Exchange Duplicate questions (titles)-304,524
AllNLI (SNLI and MultiNLIpaper SNLI, paper MultiNLI277,230
Stack Exchange Duplicate questions (bodies)-250,518
Stack Exchange Duplicate questions (titles+bodies)-250,459
XSUM (Summary, News Article) pairs-226,711
Stack Exchange (Title+Body, Most Upvoted Answer, Most Downvoted Answer) triplets-216,454
Sentence Compressionpaper180,000
FEVER training data-139,051
Wikihowpaper128,542
SearchQA (Question, Top-Snippet)paper117,384
Altlexpaper112,696
Quora Question Duplicates-103,663
Quora Question Triplets-103,663
Simple Wikipediapaper102,225
Natural Questions (NQ)paper100,231
SQuAD2.0paper87,599
TriviaQA-73,346
Total1,492,453,113

Replication

The entire fine-tuning process for this model can be replicated by following the steps outlined in the Replication.txt file within this repository. This document explains how to modify the sentence-transformers library, configure the pre-trained mosaic-bert-base-seqlen-2048 model, load all of the training data, and execute the training script.

Limitations

Due to technical constraints (e.g. limited GPU memory capacity), this model was trained with a smaller batch size of 16, making it so that each step during training was less well-informed than it would have been on a higher performance system. This smaller than ideal hyperparameter value will generally cause the model to be more likely to get stuck in a local minimum and for the parameter configuration to take a longer time to converge to the optimum. In order to counteract this potential risk, we trained the model for a larger number of steps than many of its contemporaries to ensure a greater chance of achieving strong performance, but this is an area which could be improved if further fine-tuning was performed.

It is also worth noting that, while this model is able to handle longer input sequences of up to 4096 word pieces, the training dataset used consists of sentence and paragraph pairs and triplets which do not necessarily reach that maximum sequence length. Since the data was not tailored specifically for this larger input size, further fine-tuning may be required to ensure highly accurate embeddings for longer texts of that magnitude.

Finally, as stated on https://huggingface.co/datasets/sentence-transformers/reddit-title-body, an additional reminder and warning regarding the Reddit posts data is that one should "Be aware that this dataset is not filtered for biases, hate-speech, spam, racial slurs etc. It depicts the content as it is posted on Reddit." Thus, while we believe this has not induced any pathological behaviors in the model's performance due to its relatively low prevalence of records in the whole dataset of nearly 1.5B sentence pairs and the fact that this model was trained to produce semantic embeddings rather than generative text outputs, it is always important to be aware of vulnerabilities to bias.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Можно запустить

Подбираем GPU…

Класс архитектуры
BertModel
Ревизия весов
9bbc2d0

0 моделей