shibing624 / text2vec-base-multilingual

huggingface.co
Total runs: 196.7K
24-hour runs: 0
7-day runs: 23.2K
30-day runs: 179.4K
Model's Last Updated: July 31 2024
sentence-similarity

Introduction of text2vec-base-multilingual

Model Details of text2vec-base-multilingual

shibing624/text2vec-base-multilingual

This is a CoSENT(Cosine Sentence) model: shibing624/text2vec-base-multilingual.

It maps sentences to a 384 dimensional dense vector space and can be used for tasks like sentence embeddings, text matching or semantic search.

Evaluation

For an automated evaluation of this model, see the Evaluation Benchmark : text2vec

Languages

Available languages are: de, en, es, fr, it, nl, pl, pt, ru, zh

Release Models
  • 本项目release模型的中文匹配评测结果:
Arch BaseModel Model ATEC BQ LCQMC PAWSX STS-B SOHU-dd SOHU-dc Avg QPS
Word2Vec word2vec w2v-light-tencent-chinese 20.00 31.49 59.46 2.57 55.78 55.04 20.70 35.03 23769
SBERT xlm-roberta-base sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 18.42 38.52 63.96 10.14 78.90 63.01 52.28 46.46 3138
Instructor hfl/chinese-roberta-wwm-ext moka-ai/m3e-base 41.27 63.81 74.87 12.20 76.96 75.83 60.55 57.93 2980
CoSENT hfl/chinese-macbert-base shibing624/text2vec-base-chinese 31.93 42.67 70.16 17.21 79.30 70.27 50.42 51.61 3008
CoSENT hfl/chinese-lert-large GanymedeNil/text2vec-large-chinese 32.61 44.59 69.30 14.51 79.44 73.01 59.04 53.12 2092
CoSENT nghuyong/ernie-3.0-base-zh shibing624/text2vec-base-chinese-sentence 43.37 61.43 73.48 38.90 78.25 70.60 53.08 59.87 3089
CoSENT nghuyong/ernie-3.0-base-zh shibing624/text2vec-base-chinese-paraphrase 44.89 63.58 74.24 40.90 78.93 76.70 63.30 63.08 3066
CoSENT sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 shibing624/text2vec-base-multilingual 32.39 50.33 65.64 32.56 74.45 68.88 51.17 53.67 4004

说明:

模型训练实验报告: 实验报告

Usage (text2vec)

Using this model becomes easy when you have text2vec installed:

pip install -U text2vec

Then you can use the model like this:

from text2vec import SentenceModel
sentences = ['如何更换花呗绑定银行卡', 'How to replace the Huabei bundled bank card']

model = SentenceModel('shibing624/text2vec-base-multilingual')
embeddings = model.encode(sentences)
print(embeddings)
Usage (HuggingFace Transformers)

Without text2vec , you can use the model like this:

First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

Install transformers:

pip install transformers

Then load model and predict:

from transformers import AutoTokenizer, AutoModel
import torch

# Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
    token_embeddings = model_output[0]  # First element of model_output contains all token embeddings
    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)

# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('shibing624/text2vec-base-multilingual')
model = AutoModel.from_pretrained('shibing624/text2vec-base-multilingual')
sentences = ['如何更换花呗绑定银行卡', 'How to replace the Huabei bundled bank card']
# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')

# Compute token embeddings
with torch.no_grad():
    model_output = model(**encoded_input)
# Perform pooling. In this case, mean pooling.
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")
print(sentence_embeddings)
Usage (sentence-transformers)

sentence-transformers is a popular library to compute dense vector representations for sentences.

Install sentence-transformers:

pip install -U sentence-transformers

Then load model and predict:

from sentence_transformers import SentenceTransformer

m = SentenceTransformer("shibing624/text2vec-base-multilingual")
sentences = ['如何更换花呗绑定银行卡', 'How to replace the Huabei bundled bank card']

sentence_embeddings = m.encode(sentences)
print("Sentence embeddings:")
print(sentence_embeddings)
Full Model Architecture
CoSENT(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_mean_tokens': True})
)
Intended uses

Our model is intented to be used as a sentence and short paragraph encoder. Given an input text, it ouptuts a vector which captures the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.

By default, input text longer than 256 word pieces is truncated.

Training procedure
Pre-training

We use the pretrained sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 model. 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 cosine similarity from each possible sentence pairs from the batch. We then apply the rank loss by comparing with true pairs and false pairs.

Citing & Authors

This model was trained by text2vec .

If you find this model helpful, feel free to cite:

@software{text2vec,
  author = {Ming Xu},
  title = {text2vec: A Tool for Text to Vector},
  year = {2023},
  url = {https://github.com/shibing624/text2vec},
}

Runs of shibing624 text2vec-base-multilingual on huggingface.co

196.7K
Total runs
0
24-hour runs
10.7K
3-day runs
23.2K
7-day runs
179.4K
30-day runs

More Information About text2vec-base-multilingual huggingface.co Model

More text2vec-base-multilingual license Visit here:

https://choosealicense.com/licenses/apache-2.0

text2vec-base-multilingual huggingface.co

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

text2vec-base-multilingual huggingface.co Url

https://huggingface.co/shibing624/text2vec-base-multilingual

shibing624 text2vec-base-multilingual online free

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

shibing624 text2vec-base-multilingual online free url in huggingface.co:

https://huggingface.co/shibing624/text2vec-base-multilingual

text2vec-base-multilingual install

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

text2vec-base-multilingual install url in huggingface.co:

https://huggingface.co/shibing624/text2vec-base-multilingual

Url of text2vec-base-multilingual

text2vec-base-multilingual huggingface.co Url

Provider of text2vec-base-multilingual huggingface.co

shibing624
ORGANIZATIONS

Other API from shibing624

huggingface.co

Total runs: 60
Run Growth: -24
Growth Rate: -37.50%
Updated: February 19 2024