Eland Stance - Chinese Stance Detection LoRA Adapter

LoRA adapter for Chinese stance detection with sarcasm recognition, fine-tuned on Qwen3-4B.

Task Overview

Stance Detection (觀點支持度分析): Determines whether a response supports, opposes, or is neutral toward the main text's viewpoint.

Label Description
支持 (Support) Response genuinely agrees with main text
反對 (Oppose) Response genuinely disagrees with main text
中立 (Neutral) Unclear or balanced position

Performance

Overall Benchmark (368 samples)

Metric Score
Accuracy 82.34%
Macro-F1 81.55%

By Category

Category Accuracy
Standard Samples 85.5%
Sarcasm Detection 90.0%

Quick Start

Installation

pip install transformers peft torch

Load Model

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen3-4B",
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-4B")

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "p988744/eland-stance-zh")

Inference

# System prompt with few-shot examples for best sarcasm detection
system_prompt = """你是一位專業的觀點支持度分析助手,擅長識別諷刺和反話。

## 任務
分析「回應」對「主文觀點」的立場,判斷回應是支持、反對、還是中立於主文觀點。

## 標籤定義
- 支持:回應真正認同主文觀點
- 反對:回應真正反對主文觀點
- 中立:態度不明確

## 範例

### 範例 1(諷刺 → 反對)
主文:這家餐廳的服務非常好
回應:是啊,特別是等了一小時才有人來點餐的時候
分析:回應使用諷刺,字面附和但實際批評服務差
答案:反對

### 範例 2(真正支持)
主文:這個政策有助於經濟發展
回應:確實,從最近的數據來看效果很明顯
分析:回應提供正面證據,真心認同
答案:支持

## 判斷要點
1. 識別諷刺:「字面肯定 + 負面細節」= 諷刺 = 實際反對
2. 諷刺式附和(是啊、沒錯、對啊)+ 批評性內容 = 反對
3. 按真實意圖判斷,不要被字面意思誤導"""

def analyze_stance(main_text: str, response: str) -> str:
    messages = [
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": f"主文:{main_text}\n回應:{response}"}
    ]

    text = tokenizer.apply_chat_template(
        messages,
        tokenize=False,
        add_generation_prompt=True,
        enable_thinking=False  # Important for Qwen3
    )

    inputs = tokenizer(text, return_tensors="pt").to(model.device)
    outputs = model.generate(
        **inputs,
        max_new_tokens=20,
        temperature=0,
        do_sample=False
    )

    result = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
    return result.strip()

# Test examples
print(analyze_stance(
    "這家餐廳的服務非常好",
    "是啊,特別是等了一小時才有人來點餐的時候"
))  # Expected: 反對 (Sarcasm detected)

print(analyze_stance(
    "這個政策有助於經濟發展",
    "確實,從最近的數據來看效果很明顯"
))  # Expected: 支持

Training Configuration

Parameter Value
Base Model Qwen/Qwen3-4B
Method SFT (Supervised Fine-Tuning)
LoRA Rank 32
LoRA Alpha 64
Target Modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Learning Rate 1e-5
Epochs 8
Batch Size 4
Trainable Parameters 66M (1.62%)

Dataset

Trained on p988744/eland-stance-zh-data (520 samples):

Domain Train Test
Financial (金融) 100 30
Product (產品) 100 30
Brand (品牌) 100 30
Social (社群) 100 30
Total 400 120

Challenge types:

  • Implicit stance (隱含立場): Position not directly stated
  • Sarcasm detection (諷刺反諷): Surface meaning opposite to true intent
  • Mixed stance (混合立場): Contains both supporting and opposing elements
  • Emotional separation (情感與立場分離): Emotion doesn't match stance
  • Complex reasoning (複雜推理): Requires multi-step inference

Model Variants

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

Input Format

主文:[main text with viewpoint]
回應:[response to analyze]

Example Inputs & Expected Outputs

Main Text Response Expected Type
這家餐廳的服務非常好 是啊,特別是等了一小時才有人來點餐的時候 反對 Sarcasm
這款手機的電池續航力很強 沒錯,強到每天要充三次電 反對 Sarcasm
這個政策有助於經濟發展 確實,從最近的數據來看效果很明顯 支持 Direct
遠端工作會降低生產力 我不同意,研究顯示遠端工作反而提高效率 反對 Direct
AI 將取代大部分工作 這需要看具體的產業和職位類型 中立 Neutral

Difference from Sentiment Analysis

Task Sentiment Analysis Stance Detection
Question What is the emotional tone? Does response agree with main text?
Labels 正面/負面/中立 支持/反對/中立
Input Single text Main text + Response pair
Focus Emotion polarity Agreement/disagreement

Important: A negative sentiment doesn't always mean opposition. Sarcastic agreement ("是啊,特別是...") expresses opposition despite surface agreement.

License

Apache 2.0

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for p988744/eland-stance-zh

Base model

Qwen/Qwen3-4B-Base
Finetuned
Qwen/Qwen3-4B
Adapter
(155)
this model