BAAI / LLARA-pretrain

huggingface.co
Total runs: 3
24-hour runs: 0
7-day runs: -9
30-day runs: -167
Model's Last Updated: May 13 2024
sentence-similarity

Introduction of LLARA-pretrain

Model Details of LLARA-pretrain

For more details please refer to our github repo: https://github.com/FlagOpen/FlagEmbedding

LLARA ( paper )

In this project, we introduce LLaRA:

  • EBAE: Embedding-Based Auto-Encoding.
  • EBAR: Embedding-Based Auto-Regression.
Usage
import torch
from transformers import AutoModel, AutoTokenizer, LlamaModel

def get_query_inputs(queries, tokenizer, max_length=512):
    prefix = '"'
    suffix = '", predict the following passage within eight words: <s9><s10><s11><s12><s13><s14><s15><s16>'
    prefix_ids = tokenizer(prefix, return_tensors=None)['input_ids']
    suffix_ids = tokenizer(suffix, return_tensors=None)['input_ids'][1:]
    queries_inputs = []
    for query in queries:
        inputs = tokenizer(query,
                           return_tensors=None,
                           max_length=max_length,
                           truncation=True,
                           add_special_tokens=False)
        inputs['input_ids'] = prefix_ids + inputs['input_ids'] + suffix_ids
        inputs['attention_mask'] = [1] * len(inputs['input_ids'])
        queries_inputs.append(inputs)
    return tokenizer.pad(
            queries_inputs,
            padding=True,
            max_length=max_length,
            pad_to_multiple_of=8,
            return_tensors='pt',
        )

def get_passage_inputs(passages, tokenizer, max_length=512):
    prefix = '"'
    suffix = '", summarize the above passage within eight words: <s1><s2><s3><s4><s5><s6><s7><s8>'
    prefix_ids = tokenizer(prefix, return_tensors=None)['input_ids']
    suffix_ids = tokenizer(suffix, return_tensors=None)['input_ids'][1:]
    passages_inputs = []
    for passage in passages:
        inputs = tokenizer(passage,
                           return_tensors=None,
                           max_length=max_length,
                           truncation=True,
                           add_special_tokens=False)
        inputs['input_ids'] = prefix_ids + inputs['input_ids'] + suffix_ids
        inputs['attention_mask'] = [1] * len(inputs['input_ids'])
        passages_inputs.append(inputs)
    return tokenizer.pad(
            passages_inputs,
            padding=True,
            max_length=max_length,
            pad_to_multiple_of=8,
            return_tensors='pt',
        )

# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained('BAAI/LLARA-pretrain')
model = AutoModel.from_pretrained('BAAI/LLARA-pretrain')

# Define query and passage inputs
query = "What is llama?"
title = "Llama"
passage = "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
query_input = get_query_inputs([query], tokenizer)
passage_input = get_passage_inputs([passage], tokenizer)


with torch.no_grad():
    # compute query embedding
    query_outputs = model(**query_input, return_dict=True, output_hidden_states=True)
    query_embedding = query_outputs.hidden_states[-1][:, -8:, :]
    query_embedding = torch.mean(query_embedding, dim=1)
    query_embedding = torch.nn.functional.normalize(query_embedding, dim=-1)

    # compute passage embedding
    passage_outputs = model(**passage_input, return_dict=True, output_hidden_states=True)
    passage_embeddings = passage_outputs.hidden_states[-1][:, -8:, :]
    passage_embeddings = torch.mean(passage_embeddings, dim=1)
    passage_embeddings = torch.nn.functional.normalize(passage_embeddings, dim=-1)

    # compute similarity score
    score = query_embedding @ passage_embeddings.T
    print(score)
Acknowledgement

Thanks to the authors of open-sourced datasets, including MSMARCO, BEIR, etc. Thanks to the open-sourced libraries like Pyserini .

Citation

If you find this repository useful, please consider giving a star :star: and citation

@misc{li2023making,
      title={Making Large Language Models A Better Foundation For Dense Retrieval}, 
      author={Chaofan Li and Zheng Liu and Shitao Xiao and Yingxia Shao},
      year={2023},
      eprint={2312.15503},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Runs of BAAI LLARA-pretrain on huggingface.co

3
Total runs
0
24-hour runs
-1
3-day runs
-9
7-day runs
-167
30-day runs

More Information About LLARA-pretrain huggingface.co Model

More LLARA-pretrain license Visit here:

https://choosealicense.com/licenses/mit

LLARA-pretrain huggingface.co

LLARA-pretrain huggingface.co is an AI model on huggingface.co that provides LLARA-pretrain's model effect (), which can be used instantly with this BAAI LLARA-pretrain model. huggingface.co supports a free trial of the LLARA-pretrain model, and also provides paid use of the LLARA-pretrain. Support call LLARA-pretrain model through api, including Node.js, Python, http.

LLARA-pretrain huggingface.co Url

https://huggingface.co/BAAI/LLARA-pretrain

BAAI LLARA-pretrain online free

LLARA-pretrain huggingface.co is an online trial and call api platform, which integrates LLARA-pretrain's modeling effects, including api services, and provides a free online trial of LLARA-pretrain, you can try LLARA-pretrain online for free by clicking the link below.

BAAI LLARA-pretrain online free url in huggingface.co:

https://huggingface.co/BAAI/LLARA-pretrain

LLARA-pretrain install

LLARA-pretrain is an open source model from GitHub that offers a free installation service, and any user can find LLARA-pretrain on GitHub to install. At the same time, huggingface.co provides the effect of LLARA-pretrain install, users can directly use LLARA-pretrain installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

LLARA-pretrain install url in huggingface.co:

https://huggingface.co/BAAI/LLARA-pretrain

Url of LLARA-pretrain

LLARA-pretrain huggingface.co Url

Provider of LLARA-pretrain huggingface.co

BAAI
ORGANIZATIONS

Other API from BAAI

huggingface.co

Total runs: 2.1M
Run Growth: -2.2M
Growth Rate: -103.34%
Updated: February 21 2024
huggingface.co

Total runs: 2.1M
Run Growth: -57.7K
Growth Rate: -2.71%
Updated: July 03 2024
huggingface.co

Total runs: 1.6M
Run Growth: -338.7K
Growth Rate: -20.91%
Updated: February 21 2024
huggingface.co

Total runs: 997.2K
Run Growth: -144.0K
Growth Rate: -14.26%
Updated: June 24 2024
huggingface.co

Total runs: 795.3K
Run Growth: 129.1K
Growth Rate: 16.23%
Updated: December 13 2023
huggingface.co

Total runs: 458.5K
Run Growth: 31.9K
Growth Rate: 6.95%
Updated: October 12 2023
huggingface.co

Total runs: 189.9K
Run Growth: 15.1K
Growth Rate: 7.97%
Updated: November 14 2023
huggingface.co

Total runs: 138.9K
Run Growth: 57.2K
Growth Rate: 41.20%
Updated: October 12 2023
huggingface.co

Total runs: 66.6K
Run Growth: -4.7K
Growth Rate: -7.05%
Updated: April 17 2024
huggingface.co

Total runs: 33.4K
Run Growth: 31.9K
Growth Rate: 95.46%
Updated: October 12 2023
huggingface.co

Total runs: 27.9K
Run Growth: 10.9K
Growth Rate: 38.99%
Updated: October 12 2023
huggingface.co

Total runs: 24.1K
Run Growth: -1.9K
Growth Rate: -7.86%
Updated: October 12 2023
huggingface.co

Total runs: 20.7K
Run Growth: -7.5K
Growth Rate: -36.48%
Updated: January 15 2025
huggingface.co

Total runs: 5.8K
Run Growth: 853
Growth Rate: 14.82%
Updated: December 26 2022
huggingface.co

Total runs: 5.1K
Run Growth: 1.2K
Growth Rate: 23.57%
Updated: September 21 2023
huggingface.co

Total runs: 5.0K
Run Growth: 530
Growth Rate: 10.56%
Updated: August 15 2024
huggingface.co

Total runs: 4.4K
Run Growth: -6.6K
Growth Rate: -147.63%
Updated: February 22 2024
huggingface.co

Total runs: 2.6K
Run Growth: 957
Growth Rate: 36.11%
Updated: August 15 2024
huggingface.co

Total runs: 2.6K
Run Growth: -385
Growth Rate: -14.61%
Updated: October 12 2023
huggingface.co

Total runs: 2.4K
Run Growth: 701
Growth Rate: 29.34%
Updated: February 07 2024
huggingface.co

Total runs: 2.3K
Run Growth: -11.8K
Growth Rate: -272.27%
Updated: October 23 2024
huggingface.co

Total runs: 1.9K
Run Growth: 521
Growth Rate: 27.54%
Updated: September 18 2023
huggingface.co

Total runs: 1.8K
Run Growth: -343
Growth Rate: -19.06%
Updated: November 28 2024
huggingface.co

Total runs: 1.4K
Run Growth: -3.5K
Growth Rate: -136.57%
Updated: October 23 2024
huggingface.co

Total runs: 1.3K
Run Growth: -3.0K
Growth Rate: -174.67%
Updated: October 24 2024
huggingface.co

Total runs: 822
Run Growth: 540
Growth Rate: 65.69%
Updated: April 02 2024
huggingface.co

Total runs: 755
Run Growth: -8.9K
Growth Rate: -1185.43%
Updated: March 07 2024
huggingface.co

Total runs: 716
Run Growth: 19
Growth Rate: 2.65%
Updated: June 07 2024
huggingface.co

Total runs: 647
Run Growth: 160
Growth Rate: 24.73%
Updated: October 27 2023
huggingface.co

Total runs: 613
Run Growth: 0
Growth Rate: 0.00%
Updated: January 15 2025
huggingface.co

Total runs: 441
Run Growth: 0
Growth Rate: 0.00%
Updated: January 14 2025
huggingface.co

Total runs: 301
Run Growth: 294
Growth Rate: 97.67%
Updated: April 18 2023
huggingface.co

Total runs: 155
Run Growth: -194
Growth Rate: -125.16%
Updated: August 15 2024
huggingface.co

Total runs: 114
Run Growth: 0
Growth Rate: 0.00%
Updated: January 20 2025
huggingface.co

Total runs: 102
Run Growth: -208
Growth Rate: -203.92%
Updated: June 24 2024
huggingface.co

Total runs: 94
Run Growth: -7
Growth Rate: -7.45%
Updated: December 21 2023
huggingface.co

Total runs: 88
Run Growth: 37
Growth Rate: 42.05%
Updated: August 23 2023
huggingface.co

Total runs: 83
Run Growth: 37
Growth Rate: 44.58%
Updated: August 15 2024
huggingface.co

Total runs: 62
Run Growth: -207
Growth Rate: -333.87%
Updated: June 21 2024
huggingface.co

Total runs: 58
Run Growth: -135
Growth Rate: -232.76%
Updated: April 19 2024
huggingface.co

Total runs: 54
Run Growth: 7
Growth Rate: 12.96%
Updated: August 23 2023
huggingface.co

Total runs: 44
Run Growth: -59
Growth Rate: -134.09%
Updated: December 21 2023
huggingface.co

Total runs: 39
Run Growth: -12
Growth Rate: -30.77%
Updated: August 15 2024
huggingface.co

Total runs: 35
Run Growth: -264
Growth Rate: -754.29%
Updated: June 24 2024
huggingface.co

Total runs: 34
Run Growth: -3
Growth Rate: -8.82%
Updated: August 28 2024
huggingface.co

Total runs: 32
Run Growth: -10.2K
Growth Rate: -31943.75%
Updated: February 07 2024
huggingface.co

Total runs: 29
Run Growth: 0
Growth Rate: 0.00%
Updated: January 01 2025
huggingface.co

Total runs: 26
Run Growth: 12
Growth Rate: 46.15%
Updated: July 24 2023
huggingface.co

Total runs: 21
Run Growth: -52
Growth Rate: -247.62%
Updated: December 31 2022
huggingface.co

Total runs: 17
Run Growth: -109
Growth Rate: -641.18%
Updated: May 13 2024