INF
W
ord-level
S
parse
E
mbedding v2 (INF-WSE-v2)
INF-WSE-v2
is the latest version of the word-level sparse embedding model developed by
INF TECH
.
Compared to
INF-WSE-v1
, INF-WSE-v2 continues to be pretrained on the
Wudao
corpus (from
roformer_chinese_base
) and introduces enhanced token rewriting capabilities. These advancements improve the model's ability to generate more accurate, adaptable, and contextually relevant text embeddings, with a particular focus on Chinese language processing.
Key Features:
Optimized for Retrieval
: INF-WSE-v2 is specifically designed for information retrieval tasks. By leveraging sparse embeddings, the model ensures efficient matching between queries and documents, making it ideal for semantic search, ranking, and other retrieval scenarios where both speed and accuracy are essential.
Token Rewriting Capability
: A new token rewriting feature allows INF-WSE-v2 to dynamically modify tokens during the embedding process. This improves the model’s ability to produce more accurate and contextually relevant representations, especially when dealing with complex linguistic structures and nuances in Chinese text.
Sparse Representation for Efficiency
: Unlike traditional dense embeddings, which have a fixed dimensionality, INF-WSE-v2 uses sparse embeddings where most dimensions are set to zero. This results in embeddings where only the most significant dimensions are non-zero, reducing computational load while maintaining high accuracy for retrieval tasks.
Usage
Transformers
Infer embeddings
import torch
from transformers import AutoTokenizer, AutoModelForMaskedLM
queries = ['电脑一体机由什么构成?', '什么是掌上电脑?']
documents = [
'电脑一体机,是由一台显示器、一个电脑键盘和一个鼠标组成的电脑。',
'掌上电脑是一种运行在嵌入式操作系统和内嵌式应用软件之上的、小巧、轻便、易带、实用、价廉的手持式计算设备。',
]
input_texts = queries + documents
tokenizer = AutoTokenizer.from_pretrained("infly/inf-wse-v2-base-zh", trust_remote_code=True, use_fast=False) # Fast tokenizer has not been supported yet
model = AutoModelForMaskedLM.from_pretrained("infly/inf-wse-v2-base-zh", trust_remote_code=True)
model.eval()
max_length = 512
input_batch = tokenizer(input_texts, padding=True, max_length=max_length, truncation=True, return_tensors="pt")
with torch.no_grad():
embeddings = model(input_batch['input_ids'], input_batch['attention_mask'], return_sparse=False) # if return_sparse=True, return sparse tensor, else return dense tensor
scores = embeddings[:2] @ embeddings[2:].T
print(scores.tolist())
# [[25.137710571289062, 9.891149520874023], [11.703001976013184, 30.97362518310547]]
All results, except for BM25, are measured by building the sparse index via
Qdrant
.
Runs of infly inf-wse-v2-base-zh on huggingface.co
250
Total runs
0
24-hour runs
-40
3-day runs
-40
7-day runs
-335
30-day runs
More Information About inf-wse-v2-base-zh huggingface.co Model
inf-wse-v2-base-zh huggingface.co
inf-wse-v2-base-zh huggingface.co is an AI model on huggingface.co that provides inf-wse-v2-base-zh's model effect (), which can be used instantly with this infly inf-wse-v2-base-zh model. huggingface.co supports a free trial of the inf-wse-v2-base-zh model, and also provides paid use of the inf-wse-v2-base-zh. Support call inf-wse-v2-base-zh model through api, including Node.js, Python, http.
inf-wse-v2-base-zh huggingface.co is an online trial and call api platform, which integrates inf-wse-v2-base-zh's modeling effects, including api services, and provides a free online trial of inf-wse-v2-base-zh, you can try inf-wse-v2-base-zh online for free by clicking the link below.
infly inf-wse-v2-base-zh online free url in huggingface.co:
inf-wse-v2-base-zh is an open source model from GitHub that offers a free installation service, and any user can find inf-wse-v2-base-zh on GitHub to install. At the same time, huggingface.co provides the effect of inf-wse-v2-base-zh install, users can directly use inf-wse-v2-base-zh installed effect in huggingface.co for debugging and trial. It also supports api for free installation.