Eland Entity Sentiment vLLM - Chinese Entity-Level Sentiment Analysis

A merged Qwen3-4B model fine-tuned for Chinese entity-level sentiment analysis, optimized for vLLM deployment.

This is the full merged model (LoRA weights merged into base model) for high-throughput inference with vLLM.

Performance

Metric Score
Accuracy 72.00%
Macro-F1 70.80%

Per-Class Performance

Class Precision Recall F1-Score
正面 (Positive) 86% 78% 82%
負面 (Negative) 94% 62% 74%
中立 (Neutral) 46% 72% 56%

Important: System Prompt Required

vLLM 部署必須提供 System Prompt,否則模型可能無法正確輸出。

與 Ollama 不同,vLLM 不會讀取 Modelfile 中的預設設定,因此必須在每次請求中包含 System Prompt。

標準 System Prompt:

你是一個專業的實體情感分析助手。你的任務是分析文本中對指定實體(品牌、產品、公司、人物)的情感傾向。

規則:
1. 情感只能是:正面、負面、中立
2. 只分析對該指定實體的情感,忽略其他實體
3. 同一文本可能對不同實體有不同情感
4. 判斷真實意圖,注意諷刺和隱含意思
5. 回答格式必須是 JSON

Usage with vLLM

Basic Usage

from vllm import LLM, SamplingParams

# Load model
llm = LLM(model="p988744/eland-entity-sentiment-zh-vllm")

# Define sampling parameters
sampling_params = SamplingParams(
    temperature=0.1,
    top_p=0.9,
    max_tokens=50
)

# Create prompt
entity = "台積電"
text = "台積電營收創新高,市場看好AI需求持續成長。"

prompt = f"""<|im_start|>system
你是一個專業的實體情感分析助手。你的任務是分析文本中對指定實體(品牌、產品、公司、人物)的情感傾向。

規則:
1. 情感只能是:正面、負面、中立
2. 只分析對該指定實體的情感,忽略其他實體
3. 同一文本可能對不同實體有不同情感
4. 判斷真實意圖,注意諷刺和隱含意思
5. 回答格式必須是 JSON<|im_end|>
<|im_start|>user
分析以下文本對「{entity}」的情感傾向。

文本:{text}

請以 JSON 格式回答,包含 entity_sentiment(實體情感)。<|im_end|>
<|im_start|>assistant
"""

# Generate
outputs = llm.generate([prompt], sampling_params)
print(outputs[0].outputs[0].text)  # Expected: {"entity_sentiment": "正面"}

Batch Processing

from vllm import LLM, SamplingParams

llm = LLM(model="p988744/eland-entity-sentiment-zh-vllm")
sampling_params = SamplingParams(temperature=0.1, max_tokens=50)

# Multiple entity-text pairs
samples = [
    {"text": "台積電營收創新高", "entity": "台積電"},
    {"text": "聯電表現不如預期", "entity": "聯電"},
    {"text": "蘋果發布新品,市場觀望", "entity": "蘋果"},
]

system_prompt = """你是一個專業的實體情感分析助手。你的任務是分析文本中對指定實體(品牌、產品、公司、人物)的情感傾向。

規則:
1. 情感只能是:正面、負面、中立
2. 只分析對該指定實體的情感,忽略其他實體
3. 同一文本可能對不同實體有不同情感
4. 判斷真實意圖,注意諷刺和隱含意思
5. 回答格式必須是 JSON"""

prompts = []
for sample in samples:
    prompt = f"""<|im_start|>system
{system_prompt}<|im_end|>
<|im_start|>user
分析以下文本對「{sample['entity']}」的情感傾向。

文本:{sample['text']}

請以 JSON 格式回答,包含 entity_sentiment(實體情感)。<|im_end|>
<|im_start|>assistant
"""
    prompts.append(prompt)

outputs = llm.generate(prompts, sampling_params)
for sample, output in zip(samples, outputs):
    print(f"{sample['entity']} in '{sample['text']}' -> {output.outputs[0].text}")

OpenAI-Compatible Server

# Start vLLM server
vllm serve p988744/eland-entity-sentiment-zh-vllm --port 8000

# Query with curl
curl http://localhost:8000/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "p988744/eland-entity-sentiment-zh-vllm",
    "prompt": "<|im_start|>system\n你是一個專業的實體情感分析助手。你的任務是分析文本中對指定實體的情感傾向。\n\n規則:\n1. 情感只能是:正面、負面、中立\n2. 只分析對該指定實體的情感,忽略其他實體\n3. 同一文本可能對不同實體有不同情感\n4. 判斷真實意圖,注意諷刺和隱含意思\n5. 回答格式必須是 JSON<|im_end|>\n<|im_start|>user\n分析以下文本對「台積電」的情感傾向。\n\n文本:台積電營收創新高\n\n請以 JSON 格式回答,包含 entity_sentiment(實體情感)。<|im_end|>\n<|im_start|>assistant\n",
    "max_tokens": 50,
    "temperature": 0.1
  }'

Prompt Format

System: 你是一個專業的實體情感分析助手。你的任務是分析文本中對指定實體(品牌、產品、公司、人物)的情感傾向。

規則:
1. 情感只能是:正面、負面、中立
2. 只分析對該指定實體的情感,忽略其他實體
3. 同一文本可能對不同實體有不同情感
4. 判斷真實意圖,注意諷刺和隱含意思
5. 回答格式必須是 JSON

User: 分析以下文本對「{entity}」的情感傾向。

文本:{text}

請以 JSON 格式回答,包含 entity_sentiment(實體情感)。

Model Variants

Version Repository Use Case
LoRA Adapter p988744/eland-entity-sentiment-zh HuggingFace + PEFT
GGUF p988744/eland-entity-sentiment-zh-gguf Ollama / llama.cpp
Full Merged p988744/eland-entity-sentiment-zh-vllm vLLM (this repo)

Model Details

Parameter Value
Base Model Qwen/Qwen3-4B
Parameters 4.05B
dtype bfloat16
Model Size ~8GB
Context Length 2048

Training Details

Parameter Value
Method LoRA (merged)
LoRA Rank 32
LoRA Alpha 64
Epochs 8
Learning Rate 1e-5

Dataset

Trained on p988744/eland-entity-sentiment-zh-data:

  • Training: 333 samples
  • Test: 100 samples

Requirements

pip install vllm>=0.4.0

License

Apache 2.0

Downloads last month
2
Safetensors
Model size
4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for p988744/eland-entity-sentiment-zh-vllm

Finetuned
Qwen/Qwen3-4B
Finetuned
(577)
this model