bge base en v1.5 course recommender v5

提供商datasocietyco
分类sentence-similarity
许可证Apache-2.0
下载量3.7M
星标0

简介

这是一个基于 BGE-base-en-v1.5 微调的特定领域向量模型,专门针对课程推荐场景进行了优化。它属于句子相似度模型,能够将课程描述或用户需求转化为高维向量,通过计算余弦相似度实现精准的课程匹配。相比通用 embedding 模型,它在学术或培训内容的语义检索上更具针对性。对于开发者而言,该模型上手简单,可直接集成到 RAG(检索增强生成)流水线中,作为向量数据库的索引模型,提升课程搜索的召回率。

核心亮点

  • 基于 BGE v1.5 底座,语义表征能力强
  • 专为课程推荐优化,提升匹配精准度
  • 适用于 RAG 架构中的知识检索环节
  • Apache-2.0 协议,商业部署无压力

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("datasocietyco/bge-base-en-v1.5-course-recommender-v5")
tokenizer = AutoTokenizer.from_pretrained("datasocietyco/bge-base-en-v1.5-course-recommender-v5")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download datasocietyco/bge-base-en-v1.5-course-recommender-v5

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download datasocietyco/bge-base-en-v1.5-course-recommender-v5 config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('datasocietyco/bge-base-en-v1.5-course-recommender-v5')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/datasocietyco/bge-base-en-v1.5-course-recommender-v5

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/datasocietyco/bge-base-en-v1.5-course-recommender-v5

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('datasocietyco/bge-base-en-v1.5-course-recommender-v5')
tokenizer = AutoTokenizer.from_pretrained('datasocietyco/bge-base-en-v1.5-course-recommender-v5')

完整文档

来源: HuggingFace

---
tags:

  • sentence-transformers

  • sentence-similarity

  • feature-extraction

  • generated_from_trainer

  • dataset_size:45

  • loss:MultipleNegativesRankingLoss

base_model: BAAI/bge-base-en-v1.5
pipeline_tag: sentence-similarity
library_name: sentence-transformers
---

SentenceTransformer based on BAAI/bge-base-en-v1.5

This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 tokens
  • Similarity Function: Cosine Similarity
<!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

code
SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
  (2): Normalize()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

Download from the 🤗 Hub

model = SentenceTransformer("datasocietyco/bge-base-en-v1.5-course-recommender-v5")

Run inference

sentences = [ 'The weather is lovely today.', "It's so sunny outside!", 'He drove to the stadium.', ] embeddings = model.encode(sentences) print(embeddings.shape)

[3, 768]

Get the similarity scores for the embeddings

similarities = model.similarity(embeddings, embeddings) print(similarities.shape)

[3, 3]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details>
-->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details>
-->

<!--

Out-of-Scope Use

*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->

<!--

Bias, Risks and Limitations

*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->

<!--

Recommendations

*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->

Training Details

Training Dataset

#### Unnamed Dataset

  • Size: 45 training samples
  • Columns: <code>anchor</code> and <code>positive</code>
  • Approximate statistics based on the first 45 samples:
| | anchor | positive | |:--------|:--------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 143 tokens</li><li>mean: 178.76 tokens</li><li>max: 258 tokens</li></ul> | <ul><li>min: 141 tokens</li><li>mean: 176.76 tokens</li><li>max: 256 tokens</li></ul> |
  • Samples:
| anchor | positive | |:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------