Views
No views yet
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.1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2from peft import PeftModel
3import torch
4
5# Load base model and tokenizer
6base_model_name = "Qwen/Qwen3-Embedding-0.6B"
7tokenizer = AutoTokenizer.from_pretrained(base_model_name)
8model = AutoModelForSequenceClassification.from_pretrained(
9 base_model_name,
10 num_labels=2
11)
12
13# Load the fine-tuned adapters
14model = PeftModel.from_pretrained(model, "NiklasKoch/qwen-discussion-classifier")
15model.eval()
16
17# Classify text
18def classify_text(text):
19 inputs = tokenizer(
20 text,
21 return_tensors="pt",
22 truncation=True,
23 padding=True,
24 max_length=4096
25 )
26
27 # Move inputs to same device as model (important for GPU usage)
28 inputs = {k: v.to(next(model.parameters()).device) for k, v in inputs.items()}
29
30 with torch.no_grad():
31 outputs = model(**inputs)
32 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
33
34 # 0 = non-constructive, 1 = constructive
35 predicted_class = torch.argmax(predictions, dim=-1).item()
36 confidence = predictions[0][predicted_class].item()
37
38 return {
39 'class': 'constructive' if predicted_class == 1 else 'non-constructive',
40 'confidence': confidence,
41 'scores': {
42 'non-constructive': predictions[0][0].item(),
43 'constructive': predictions[0][1].item()
44 }
45 }
46
47# Example usage
48text = "[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"
49result = classify_text(text)
50print(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