---
title: jd_sentiment
canonical_url: "https://www.modelscope.cn/models/BI3CBL/jd_sentiment"
md_url: "https://www.modelscope.cn/models/BI3CBL/jd_sentiment.md"
repository: BI3CBL/jd_sentiment
chinese_name: "京东评论情感分析"
last_updated: 2026-06-17
license: "Apache License 2.0"
pipeline_tag: sentiment-classification
tasks:
  - sentiment-classification
model_type:
  - bert
architectures:
  - BertForSequenceClassification
base_model:
  - google-bert/bert-base-chinese
base_model_relation: finetune
parameters: 102.3M
tensor_type:
  - F32
library_name:
  - pytorch
  - transformer
  - safetensors
frameworks:
  - pytorch
language:
  - en
  - cn
downloads: 46
stars: 1
tags:
  - transformer
---

# jd_sentiment

> jd_sentiment - BI3CBL 在 ModelScope 开源的模型。2. 代码训练逻辑 https://gitcode.com/liuzwei/bertsentimentclassification

BI3CBL/jd_sentiment 是 ModelScope 魔搭社区上的 102.3M 参数sentiment-classification模型，采用 Apache License 2.0 许可，基于 google-bert/bert-base-chinese 构建。

- **Repository**: BI3CBL/jd_sentiment
- **License**: Apache License 2.0
- **Tasks**: sentiment-classification
- **Parameters**: 102.3M
- **Base model**: google-bert/bert-base-chinese
- **Tags**: transformer
- **Downloads**: 46
- **Stars**: 1
- **Last updated**: 2026-06-17

Source: https://www.modelscope.cn/models/BI3CBL/jd_sentiment

---

# 1. 模型数据来源

模型：

```python

#模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('google-bert/bert-base-chinese')

```
数据：

```python

#数据集下载
from modelscope.msdatasets import MsDataset
ds =  MsDataset.load('DAMO_NLP/jd', subset_name='default', split='train')

```

# 2. 代码训练逻辑
https://gitcode.com/liuzwei/bert_sentiment_classification


# 3. 模型使用

```python
#模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('BI3CBL/jd_sentiment', cache_dir="./")

from pathlib import Path
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

# 加载模型
def load_model_and_tokenizer(model_dir: str):
    model_path = Path(model_dir)
    if not model_path.exists():
        raise FileNotFoundError(f"模型目录不存在: {model_path.resolve()}")

    tokenizer = AutoTokenizer.from_pretrained(model_dir)
    model = AutoModelForSequenceClassification.from_pretrained(model_dir)
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    model.to(device)
    model.eval()
    return model, tokenizer, device

model, tokenizer, device = load_model_and_tokenizer("/mnt/workspace/.cache/modelscope/models/BI3CBL/jd_sentiment")

texts = ["这个套餐太难吃了！！", "非常美味,值得推荐,还不错"]
inputs = tokenizer(
        texts,
        truncation=True,
        padding=True,
        max_length=64,
        return_tensors="pt",
    )

outputs = model(**inputs)
probabilities = torch.softmax(outputs.logits, dim=-1)
predictions = torch.argmax(probabilities, dim=-1)

for sentence, pre in zip(texts, predictions):
    print(f"【{sentence}】情感偏向：{'积极' if pre==1 else '消极'}")  

```
