当前位置:   article > 正文

LLM大语言模型(八):ChatGLM3-6B使用的tokenizer模型BAAI/bge-large-zh-v1.5

LLM大语言模型(八):ChatGLM3-6B使用的tokenizer模型BAAI/bge-large-zh-v1.5

背景

BGE embedding系列模型是由智源研究院研发的中文版文本表示模型。

可将任意文本映射为低维稠密向量,以用于检索、分类、聚类或语义匹配等任务,并可支持为大模型调用外部知识。

BAAI/BGE embedding系列模型

模型列表

ModelLanguageDescriptionquery instruction for retrieval [1]
BAAI/bge-m3Multilingual推理 微调多功能(向量检索,稀疏检索,多表征检索)、多语言、多粒度(最大长度8192)
LM-CocktailEnglish微调的Llama和BGE模型,可以用来复现LM-Cocktail论文的结果
BAAI/llm-embedderEnglish推理 微调专为大语言模型各种检索增强任务设计的向量模型详见 README
BAAI/bge-reranker-largeChinese and English推理 微调交叉编码器模型,精度比向量模型更高但推理效率较低 [2]
BAAI/bge-reranker-baseChinese and English推理 微调交叉编码器模型,精度比向量模型更高但推理效率较低 [2]
BAAI/bge-large-en-v1.5English推理 微调1.5版本,相似度分布更加合理Represent this sentence for searching relevant passages:
BAAI/bge-base-en-v1.5English推理 微调1.5版本,相似度分布更加合理Represent this sentence for searching relevant passages:
BAAI/bge-small-en-v1.5English推理 微调1.5版本,相似度分布更加合理Represent this sentence for searching relevant passages:
BAAI/bge-large-zh-v1.5Chinese推理 微调1.5版本,相似度分布更加合理为这个句子生成表示以用于检索相关文章:
BAAI/bge-base-zh-v1.5Chinese推理 微调1.5版本,相似度分布更加合理为这个句子生成表示以用于检索相关文章:
BAAI/bge-small-zh-v1.5Chinese推理 微调1.5版本,相似度分布更加合理为这个句子生成表示以用于检索相关文章:
BAAI/bge-large-enEnglish推理 微调向量模型,将文本转换为向量Represent this sentence for searching relevant passages:
BAAI/bge-base-enEnglish推理 微调base-scale 向量模型Represent this sentence for searching relevant passages:
BAAI/bge-small-enEnglish推理 微调small-scale 向量模型Represent this sentence for searching relevant passages:
BAAI/bge-large-zhChinese推理 微调向量模型,将文本转换为向量为这个句子生成表示以用于检索相关文章:
BAAI/bge-base-zhChinese推理 微调base-scale 向量模型为这个句子生成表示以用于检索相关文章:
BAAI/bge-small-zhChinese推理 微调small-scale 向量模型为这个句子生成表示以用于检索相关文章:

C_MTEB榜单:Embedding

目前看榜单的话BAAI/bge-large-zh-v1.5是居于榜首的。(这里仅就刷榜而言)

ModelEmbedding dimensionAvgRetrievalSTSPairClassificationClassificationRerankingClustering
BAAI/bge-large-zh-v1.5102464.5370.4656.2581.669.1365.8448.99
BAAI/bge-base-zh-v1.576863.1369.4953.7279.7568.0765.3947.53
BAAI/bge-small-zh-v1.551257.8261.7749.1170.4163.9660.9244.18
BAAI/bge-large-zh102464.2071.5354.9878.9468.3265.1148.39
BAAI/bge-large-zh-noinstruct102463.5370.555376.7768.5864.9150.01
BAAI/bge-base-zh76862.9669.5354.1277.567.0764.9147.63
multilingual-e5-large102458.7963.6648.4469.8967.3456.0048.23
BAAI/bge-small-zh51258.2763.0749.4570.3563.6461.4845.09
m3e-base76857.1056.9150.4763.9967.5259.3447.68
m3e-large102457.0554.7550.4264.368.259.6648.88
multilingual-e5-base76855.4861.6346.4967.0765.3554.3540.68
multilingual-e5-small38455.3859.9545.2766.4565.8553.8645.26
text-embedding-ada-002(OpenAI)153653.0252.043.3569.5664.3154.2845.68
luotuo102449.3744.442.7866.626149.2544.39
text2vec-base76847.6338.7943.4167.4162.1949.4537.66
text2vec-large102447.3641.9444.9770.8660.6649.1630.02

bge-large-zh-v1.5

发布bge-*-v1.5向量模型,缓解相似度分布问题,提升无指令情况下的检索能力(但检索任务仍建议使用指令)

使用示例:

  1. from FlagEmbedding import FlagModel
  2. sentences_1 = ["样例数据-1", "样例数据-2"]
  3. sentences_2 = ["样例数据-3", "样例数据-4"]
  4. model = FlagModel('BAAI/bge-large-zh-v1.5',
  5. query_instruction_for_retrieval="为这个句子生成表示以用于检索相关文章:",
  6. use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
  7. embeddings_1 = model.encode(sentences_1)
  8. embeddings_2 = model.encode(sentences_2)
  9. similarity = embeddings_1 @ embeddings_2.T
  10. print(similarity)
  11. # for s2p(short query to long passage) retrieval task, suggest to use encode_queries() which will automatically add the instruction to each query
  12. # corpus in retrieval task can still use encode() or encode_corpus(), since they don't need instruction
  13. queries = ['query_1', 'query_2']
  14. passages = ["样例文档-1", "样例文档-2"]
  15. q_embeddings = model.encode_queries(queries)
  16. p_embeddings = model.encode(passages)
  17. scores = q_embeddings @ p_embeddings.T

使用示例2:

在上篇文章LLM大语言模型(七):部署ChatGLM3-6B并提供HTTP server能力_failed to parse tool call, maybe the response is n-CSDN博客

中部署ChatGLM3-6B并提供HTTP server能力时,也是显示的用了 bge-large-zh-v1.5 embedding,可以让用户测试输入对应的embedding。(LLM实际使用的是tokenizer,默认包含了分词和embedding等)

  1. @app.post("/v1/embeddings", response_model=EmbeddingResponse)
  2. async def get_embeddings(request: EmbeddingRequest):
  3. embeddings = [embedding_model.encode(text) for text in request.input]
  4. embeddings = [embedding.tolist() for embedding in embeddings]

 参考

  1. LLM大语言模型(七):部署ChatGLM3-6B并提供HTTP server能力
  2. LLM大语言模型(四):在ChatGLM3-6B中使用langchain_chatglm3-6b langchain-CSDN博客
  3. LLM大语言模型(一):ChatGLM3-6B本地部署-CSDN博客

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/362672
推荐阅读
相关标签
  

闽ICP备14008679号