Files
Qwen3-8B-UnBias-Plus-SFT-In…/README.md
ModelHub XC fb23672715 初始化项目,由ModelHub XC社区提供模型
Model: ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct-4bit
Source: Original Platform
2026-10-04 20:50:11 +08:00

167 lines
5.6 KiB
Markdown

---
license: apache-2.0
base_model: vector-institute/Qwen3-8B-UnBias-Plus-SFT-Instruct
language:
- en
tags:
- qwen3
- bias-detection
- news-debiasing
- fine-tuned
- 4-bit
- quantized
- sft
- conversational
pipeline_tag: text-generation
---
# Qwen3-8B-UnBias-Plus-SFT-Instruct (4-bit)
A **4-bit pre-quantized** version of [ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct](https://huggingface.co/ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct), itself a retrained derivative of [vector-institute/Qwen3-8B-UnBias-Plus-SFT-Instruct](https://huggingface.co/vector-institute/Qwen3-8B-UnBias-Plus-SFT-Instruct).
This version exists for **accessibility** — it runs on any GPU with ~6GB VRAM, removing the need for high-end hardware to use the model.
Given a news article, the model identifies biased language segments, classifies their bias type and severity, provides neutral replacements, and returns a fully rewritten unbiased version — all in a single structured JSON response.
## Relationship to the Original
| | Original (Vector Institute) | 16-bit (this lineage) | **4-bit (this model)** |
|---|---|---|---|
| Model | `vector-institute/Qwen3-8B-UnBias-Plus-SFT-Instruct` | `ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct` | `ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct-4bit` |
| VRAM | ~16GB | ~16GB | **~6GB** |
| Quantization | bf16 | bf16 | 4-bit |
| Training | Same recipe | Same recipe | Same recipe |
The 16-bit and 4-bit versions were retrained using the exact same setup as the Vector Institute original (same dataset, LoRA config, hyperparameters) on the same A100 hardware. The only difference is the 4-bit version is pre-quantized at export time for accessibility.
## Model Details
| Property | Value |
|---|---|
| Base model | Qwen/Qwen3-8B |
| Fine-tuning method | SFT with LoRA |
| Training precision | bf16 (no quantization during training) |
| LoRA rank | 16, alpha 32, rSLoRA |
| Training framework | Unsloth + TRL |
| Context length | 8192 tokens |
| Thinking mode | Disabled (enable_thinking=False) |
| Output format | Structured JSON |
| Quantization | 4-bit (post-training) |
## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch, json
model_id = "ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct-4bit"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
load_in_4bit=True,
device_map="auto",
)
model.eval()
SYSTEM_PROMPT = """You are an expert linguist and bias detection specialist.
Your task is to carefully read a news article, detect ALL biased language,
and return a structured JSON response. Return ONLY valid JSON, no extra text."""
article = "Your news article here..."
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"Analyze the following article for bias and return the result in the required JSON format.\n\nARTICLE:\n{article}"},
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
enable_thinking=False,
return_tensors="pt",
return_dict=True,
truncation=True,
max_length=8192,
)
with torch.no_grad():
outputs = model.generate(
input_ids=inputs["input_ids"].to(model.device),
attention_mask=inputs["attention_mask"].to(model.device),
max_new_tokens=4096,
do_sample=False,
temperature=None,
top_p=None,
pad_token_id=tokenizer.eos_token_id,
)
new_tokens = outputs[0][inputs["input_ids"].shape[1]:]
response = tokenizer.decode(new_tokens, skip_special_tokens=True)
result = json.loads(response)
```
## Using with the UnBias-Plus toolkit
```python
from unbias_plus import UnBiasPlus
pipe = UnBiasPlus(
model_name_or_path="ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct-4bit",
load_in_4bit=True,
)
result = pipe.analyze("Your article text here...")
print(result.binary_label)
print(result.severity)
print(result.unbiased_text)
```
## Output Schema
```json
{
"binary_label": "biased" | "unbiased",
"severity": 0 | 2 | 3 | 4,
"bias_found": true | false,
"biased_segments": [
{
"original": "exact substring from input article",
"replacement": "neutral alternative phrase",
"severity": "high" | "medium" | "low",
"bias_type": "loaded language | dehumanizing framing | false generalizations | framing bias | euphemism/dysphemism | politically charged terminology | sensationalism",
"reasoning": "1-2 sentence explanation"
}
],
"unbiased_text": "Full rewritten neutral article"
}
```
## Severity Scale
| Value | Meaning |
|---|---|
| 0 | Neutral — no bias detected |
| 2 | Recurring biased framing |
| 3 | Strong persuasive tone |
| 4 | Inflammatory rhetoric |
## Training Data
Fine-tuned on [vector-institute/Unbias-plus](https://huggingface.co/datasets/vector-institute/Unbias-plus), a curated dataset of news articles with expert-annotated bias labels, segment-level annotations, and neutral rewrites.
## Limitations
- Trained primarily on English-language news articles
- Best performance on articles under 5000 characters
- Outputs should be reviewed by a human before use in production
## Links
- 🔗 Project: [UnBias-Plus on GitHub](https://github.com/VectorInstitute/unbias-plus)
- 📊 Dataset: [vector-institute/Unbias-plus](https://huggingface.co/datasets/vector-institute/Unbias-plus)
- 🏛️ Organization: [Vector Institute](https://vectorinstitute.ai)
- 🤖 16-bit version: [ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct](https://huggingface.co/ahelkadyy/Qwen3-8B-UnBias-Plus-SFT-Instruct)
- 🤖 Original model: [vector-institute/Qwen3-8B-UnBias-Plus-SFT-Instruct](https://huggingface.co/vector-institute/Qwen3-8B-UnBias-Plus-SFT-Instruct)