CoolFace
Modelpublic

Frazic/udever-bloom-3b-sentence

sourceHugging Facebigscience-bloom-rail-1.0updated 3y agoView on Hugging Face
0likes27downloads
Model Card

Model Card for udever-bloom

<!-- Provide a quick summary of what the model is/does. -->

udever-bloom-3b is finetuned from bigscience/bloom-3b via BitFit on MS MARCO Passage Ranking, SNLI and MultiNLI data. It is a universal embedding model across tasks, natural and programming languages. (From the technical view, udever is merely with some minor improvements to sgpt-bloom)

<div align=center><img width="338" height="259" src="https://user-images.githubusercontent.com/26690193/277643721-cdb7f227-cae5-40e1-b6e1-a201bde00339.png" /></div>

Model Details

Model Description

  • Developed by: Alibaba Group
  • Model type: Transformer-based Language Model (decoder-only)
  • Language(s) (NLP): Multiple; see bloom training data
  • Finetuned from model : bigscience/bloom-3b

Model Sources

<!-- Provide the basic links for the model. -->

How to Get Started with the Model

Use the code below to get started with the model.

python
import torch
from transformers import AutoTokenizer, BloomModel

tokenizer = AutoTokenizer.from_pretrained('izhx/udever-bloom-3b')
model = BloomModel.from_pretrained('izhx/udever-bloom-3b')

boq, eoq, bod, eod = '[BOQ]', '[EOQ]', '[BOD]', '[EOD]'
eoq_id, eod_id = tokenizer.convert_tokens_to_ids([eoq, eod])

if tokenizer.padding_side != 'left':
    print('!!!', tokenizer.padding_side)
    tokenizer.padding_side = 'left'


def encode(texts: list, is_query: bool = True, max_length=300):
    bos = boq if is_query else bod
    eos_id = eoq_id if is_query else eod_id
    texts = [bos + t for t in texts]
    encoding = tokenizer(
        texts, truncation=True, max_length=max_length - 1, padding=True
    )
    for ids, mask in zip(encoding['input_ids'], encoding['attention_mask']):
        ids.append(eos_id)
        mask.append(1)
    inputs = tokenizer.pad(encoding, return_tensors='pt')
    with torch.inference_mode():
        outputs = model(**inputs)
        embeds = outputs.last_hidden_state[:, -1]
    return embeds

encode(['I am Bert', 'You are Elmo'])

Training Details

Training Data

<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

  • MS MARCO Passage Ranking, retrieved by (https://github.com/UKPLab/sentence-transformers/blob/master/examples/training/msmarco/trainbi-encoder_mnrl.py#L86)
  • SNLI and MultiNLI (https://sbert.net/datasets/AllNLI.tsv.gz)

Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

Preprocessing

MS MARCO hard negatives provided by (https://github.com/UKPLab/sentence-transformers/blob/master/examples/training/msmarco/trainbi-encoder_mnrl.py#L86). Negatives for SNLI and MultiNLI are randomly sampled.

Training Hyperparameters
  • Training regime: tf32, BitFit
  • Batch size: 1024
  • Epochs: 3
  • Optimizer: AdamW
  • Learning rate: 1e-4
  • Scheduler: constant with warmup.
  • Warmup: 0.25 epoch

Evaluation

Table 1: Massive Text Embedding Benchmark MTEB

MTEBAvg.Class.Clust.PairClass.Rerank.Retr.STSSumm.
#Datasets ➡️5612113415101
bge-large-en-v1.564.2375.9746.0887.1260.0354.2983.1131.61
bge-base-en-v1.563.5575.5345.7786.5558.8653.2582.431.07
gte-large63.1373.3346.848559.1352.2283.3531.66
gte-base62.3973.0146.284.5758.6151.1482.331.17
e5-large-v262.2575.2444.4986.0356.6150.5682.0530.19
instructor-xl61.7973.1244.7486.6257.2949.2683.0632.32
instructor-large61.5973.8645.2985.8957.5447.5783.1531.84
e5-base-v261.573.8443.885.7355.9150.2981.0530.28
e5-large61.4273.1443.3385.9456.5349.9982.0630.97
text-embedding-ada-002 (OpenAI API)60.9970.9345.984.8956.3249.2580.9730.8
e5-base60.4472.6342.1185.0955.748.7580.9631.01
SGPT-5.8B-msmarco58.9368.1340.348256.5650.2578.131.46
sgpt-bloom-7b1-msmarco57.5966.1938.9381.955.6548.2277.7433.6
Udever-bloom-560m55.8068.0436.8981.0552.6041.1979.9332.06
Udever-bloom-1b158.2870.1839.1183.1154.2845.2781.5231.10
Udever-bloom-3b59.8671.9140.7484.0654.9047.6782.3730.62
Udever-bloom-7b160.6372.1340.8185.4055.9149.3483.0130.97

Table 2: CodeSearchNet

CodeSearchNetGoRubyPythonJavaJSPHPAvg.
CodeBERT69.370.684.086.874.870.676.0
GraphCodeBERT84.173.287.975.771.172.577.4
cpt-code S97.786.399.894.086.096.793.4
cpt-code M97.585.599.994.486.597.293.5
sgpt-bloom-7b1-msmarco76.7969.2595.6877.9370.3573.4577.24
Udever-bloom-560m75.3866.6796.2378.9969.3973.6976.73
Udever-bloom-1b178.7672.8597.6782.7774.3878.9780.90
Udever-bloom-3b80.6375.4098.0283.8876.1879.6782.29
Udever-bloom-7b179.3776.5998.3884.6877.4980.0382.76

Table 3: Chinese multi-domain retrieval Multi-cpr

E-commerceEntertainment videoMedical
ModelTrainBackboneMRR@10Recall@1kMRR@10Recall@1kMRR@10Recall@1k
BM25--0.2250.8150.2250.7800.1870.482
Doc2Query--0.2390.8260.2380.7940.2100.505
DPR-1In-DomainBERT0.2700.9210.2540.9340.3270.747
DPR-2In-DomainBERT-CT0.2890.9260.2630.9350.3390.769
text-embedding-ada-002GeneralGPT0.1830.8250.1590.7860.2450.593
sgpt-bloom-7b1-msmarcoGeneralBLOOM0.2420.8400.2270.8290.3110.675
Udever-bloom-560mGeneralBLOOM0.1560.8020.1490.7490.2450.571
Udever-bloom-1b1GeneralBLOOM0.2440.8630.2080.8150.2410.557
Udever-bloom-3bGeneralBLOOM0.2670.8710.2280.8360.2880.619
Udever-bloom-7b1GeneralBLOOM0.2960.8890.2670.9070.3430.705
More results refer to paper section 3.

Technical Specifications

Model Architecture and Objective

Compute Infrastructure

  • Nvidia A100 SXM4 80GB.
  • torch 2.0.0, transformers 4.29.2.

Citation

BibTeX:

BibTeX
@article{zhang2023language,
  title={Language Models are Universal Embedders},
  author={Zhang, Xin and Li, Zehan and Zhang, Yanzhao and Long, Dingkun and Xie, Pengjun and Zhang, Meishan and Zhang, Min},
  journal={arXiv preprint arXiv:2310.08232},
  year={2023}
}