webis/tldr-17
Viewer • Updated • 1.33M • 1.35k • 56
How to use NiklasKoch/qwen-discussion-classifier with PEFT:
from peft import PeftModel
from transformers import AutoModelForSequenceClassification
base_model = AutoModelForSequenceClassification.from_pretrained("Qwen/Qwen3-Embedding-0.6B")
model = PeftModel.from_pretrained(base_model, "NiklasKoch/qwen-discussion-classifier")How to use NiklasKoch/qwen-discussion-classifier with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="NiklasKoch/qwen-discussion-classifier") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("NiklasKoch/qwen-discussion-classifier", dtype="auto")A fine-tuned Qwen 3 Embedding model for classifying constructive vs non-constructive conversations from online discussion platforms like Reddit.
This model is a QLoRA (Quantized LoRA) fine-tuned version of Qwen/Qwen3-Embedding-0.6B specifically trained to identify constructive conversations in online discussion threads. The model was trained using self-training techniques on Reddit discussion data.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from peft import PeftModel
import torch
# Load base model and tokenizer
base_model_name = "Qwen/Qwen3-Embedding-0.6B"
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
model = AutoModelForSequenceClassification.from_pretrained(
base_model_name,
num_labels=2
)
# Load the fine-tuned adapters
model = PeftModel.from_pretrained(model, "NiklasKoch/qwen-discussion-classifier")
model.eval()
# Classify text
def classify_text(text):
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
padding=True,
max_length=4096
)
# Move inputs to same device as model (important for GPU usage)
inputs = {k: v.to(next(model.parameters()).device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
# 0 = non-constructive, 1 = constructive
predicted_class = torch.argmax(predictions, dim=-1).item()
confidence = predictions[0][predicted_class].item()
return {
'class': 'constructive' if predicted_class == 1 else 'non-constructive',
'confidence': confidence,
'scores': {
'non-constructive': predictions[0][0].item(),
'constructive': predictions[0][1].item()
}
}
# Example usage
text = "[author0] LEGO: What do you think you're doing?!? [author1] I don't get it did he reveal bionicle reboot or smthn? [author2] Not really, he did announce something but was super vague, seems like a sort of passion project we wants to do with the community, he even said it might not even be bionicle. [author1] So is that image fan made or is it one of his passion projects [author2] Those pictures are real and on his insta, he did a stream talking about it I\u2019m sure you can find somewhere, search up Fabre bionicle stream 2020 or something. [author1] OK thanks"
result = classify_text(text)
print(result)
r: 16lora_alpha: 32lora_dropout: 0.1q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projYNACC:
Accuracy: 0.70
Precision: 0.72
F1-Score: 0.69
IAC:
Accuracy: 0.78
Precision: 0.86
F1-Score: 0.86
Reddit:
Accuracy: 0.64
Precision: 0.76
F1-Score: 0.74
Niklas Koch, Georg August University of Göttingen