ضبط عتبات الكشف
تحدّد عتبات الكشف مستوى الثقة الذي عنده يضع Discuse علامة على المحتوى، مما يوازن بين الإيجابيات الكاذبة والسلبيات الكاذبة. في Discuse، تُعد هذه العتبات إعدادات للمشروع يتم ضبطها من لوحة التحكم (أو عبر API الإعدادات)، بينما لا يقوم طلب API إلا بتحديد الفحوصات التي سيتم تشغيلها — ولا يحمل أي عتبات رقمية. يشرح هذا الدليل كيفية عمل هذه المفاضلة وكيفية اختيار القيم المناسبة لمنصتك.
كيف تعمل عتبات Discuse
يعيد كل فحص درجة ثقة من 0.0 إلى 1.0 وعلامة hit. يتم تعيين hit عندما تبلغ الدرجة العتبة التي ضبطتها لتلك الفئة في مشروعك أو تتجاوزها. العتبات القابلة للضبط هي:
| العتبة (إعداد المشروع) | تنطبق على |
|---|---|
threshold_sentiment |
حدّ المشاعر السلبية العامة |
threshold_toxicity |
النص المسيء |
threshold_profanity |
الألفاظ النابية |
threshold_threat |
التهديدات |
threshold_insult |
الإهانات |
threshold_spam |
درجة ثقة مصنّف الرسائل المزعجة |
threshold_images |
الصور الصريحة (إجمالًا) |
threshold_images_porn |
الصور الإباحية |
threshold_images_sexual |
الصور ذات الإيحاءات الجنسية |
هذه هي الأسماء التي تعرضها API إعدادات المشروع؛ أما كائن settings الخاص بكل طلب فلا يحتوي إلا على مفاتيح تشغيل/إيقاف check_* بالإضافة إلى expected_language. يمكنك تغيير العتبات من لوحة التحكم، وليس لكل طلب على حدة.
المفاضلة
Lower Threshold = More Strict
├── More content flagged
├── Higher false positive rate
├── Fewer harmful posts slip through
└── More user friction
Higher Threshold = More Permissive
├── Less content flagged
├── Lower false positive rate
├── More harmful posts may slip through
└── Better user experience
تصور المفاضلة
False Positives ─────────────────────────►
Few Many
┌─────────────────────────────────────────┐
False Few │ ◄─── Ideal Zone │
Negatives │ (High threshold, │
│ low false rates) │
│ │ │
│ │ Your platform's │
│ │ optimal point → ● │
▼ │ │
Many │ Too permissive ──►│
└─────────────────────────────────────────┘
Threshold: 0.3 0.5 0.7 0.9
ما الحدود المناسبة لكل منصة؟
القيم أدناه هي نقاط بداية مُعبَّر عنها بأسماء الحدود في Discuse (threshold_toxicity وthreshold_images_porn وما إلى ذلك). تعامل معها كخط أساس تضبطه وفق بياناتك الخاصة عن النتائج الإيجابية الخاطئة، لا كأرقام مضمونة الصحة. كلما انخفض الحد، أصبح الرصد أكثر صرامة.
منصات التواصل الاجتماعي
تحتاج منصات التواصل العامة إلى إشراف متوازن:
const SOCIAL_MEDIA_THRESHOLDS = {
threshold_toxicity: 0.7,
threshold_profanity: 0.6,
threshold_threat: 0.5, // Lower (stricter) for threats
threshold_insult: 0.7,
threshold_spam: 0.75,
threshold_images_porn: 0.6,
threshold_images_sexual: 0.8 // More permissive for suggestive content
};
المنصات المهنية / التجارية
تتطلب السياقات التجارية عادةً إشرافًا أكثر صرامة:
const PROFESSIONAL_THRESHOLDS = {
threshold_toxicity: 0.5,
threshold_profanity: 0.4,
threshold_threat: 0.3,
threshold_insult: 0.5,
threshold_spam: 0.6,
threshold_images_porn: 0.3,
threshold_images_sexual: 0.5
};
مجتمعات الألعاب
قد تتسامح منصات الألعاب مع قدر أكبر من المزاح، مع الحفاظ على الصرامة تجاه التهديدات الحقيقية:
const GAMING_THRESHOLDS = {
threshold_toxicity: 0.8,
threshold_profanity: 0.85, // Banter allowed
threshold_threat: 0.5, // Still strict on real threats
threshold_insult: 0.8,
threshold_spam: 0.8,
threshold_images_porn: 0.6,
threshold_images_sexual: 0.9
};
منصات الأطفال
تتطلب المنصات المخصصة للقُصَّر أكثر الإعدادات صرامة:
const CHILDRENS_THRESHOLDS = {
threshold_toxicity: 0.3,
threshold_profanity: 0.2,
threshold_threat: 0.2,
threshold_insult: 0.3,
threshold_spam: 0.5,
threshold_images_porn: 0.1, // Maximum strictness
threshold_images_sexual: 0.2
};
هل يمكنني تغيير العتبات ديناميكيًا؟
يخزّن Discuse مجموعة واحدة من العتبات لكل مشروع، لذا فإن التغيير بحسب المستخدم أو السياق يكون ضمن تطبيقك. تحسب الأنماط أدناه عتبةً فعليةً من جانبك؛ ثم يمكنك إما التوجيه إلى مشاريع مختلفة (لكل منها عتباته المضبوطة) أو إجراء المقارنة بنفسك مقابل الدرجات التي يعيدها Discuse.
مستويات ثقة المستخدم
اضبط العتبات الفعلية بناءً على سمعة المستخدم:
function getThresholds(user) {
const baseThresholds = PLATFORM_THRESHOLDS;
const trustMultipliers = {
new_user: 0.8, // Stricter (lower effective threshold)
basic_user: 1.0, // Standard
verified_user: 1.15, // Slightly more permissive
trusted_user: 1.3, // More permissive
moderator: 1.5 // Most permissive
};
const multiplier = trustMultipliers[user.trustLevel] || 1.0;
return Object.fromEntries(
Object.entries(baseThresholds).map(([key, value]) => [
key,
typeof value === 'number'
? Math.min(value * multiplier, 0.95)
: adjustNestedThresholds(value, multiplier)
])
);
}
العتبات المعتمدة على السياق
قد تحتاج أنواع المحتوى المختلفة إلى عتبات مختلفة:
const CONTEXT_THRESHOLDS = {
// Public posts visible to everyone
public_post: {
toxic: 0.6,
profanity: 0.5
},
// Direct messages between users
direct_message: {
toxic: 0.7, // Slightly more permissive
profanity: 0.6
},
// Comments on public content
comment: {
toxic: 0.55, // Stricter than posts
profanity: 0.5
},
// Profile information
profile: {
toxic: 0.5, // Strict for public-facing content
profanity: 0.4
}
};
function getContextThresholds(contentType) {
return CONTEXT_THRESHOLDS[contentType] || CONTEXT_THRESHOLDS.public_post;
}
تعديلات حسب الوقت
اضبط العتبات خلال الفترات عالية المخاطر:
function getTimeAdjustedThresholds(baseThresholds) {
const hour = new Date().getHours();
const dayOfWeek = new Date().getDay();
// Stricter during off-hours when fewer moderators available
const isOffHours = hour < 6 || hour > 22;
const isWeekend = dayOfWeek === 0 || dayOfWeek === 6;
let multiplier = 1.0;
if (isOffHours) multiplier *= 0.85;
if (isWeekend) multiplier *= 0.9;
return adjustThresholds(baseThresholds, multiplier);
}
تنفيذ إعدادات الحدود
إعدادات مركزية
// config/moderation.js — mirrors your Discuse project thresholds so app-side
// routing stays in sync with the values configured in the dashboard.
export const ModerationConfig = {
thresholds: {
threshold_toxicity: parseFloat(process.env.THRESHOLD_TOXICITY || '0.7'),
threshold_profanity: parseFloat(process.env.THRESHOLD_PROFANITY || '0.6'),
threshold_threat: parseFloat(process.env.THRESHOLD_THREAT || '0.5'),
threshold_insult: parseFloat(process.env.THRESHOLD_INSULT || '0.7'),
threshold_spam: parseFloat(process.env.THRESHOLD_SPAM || '0.75'),
threshold_images_porn: parseFloat(process.env.THRESHOLD_IMAGES_PORN || '0.6'),
threshold_images_sexual: parseFloat(process.env.THRESHOLD_IMAGES_SEXUAL || '0.8')
},
actions: {
high_confidence: 'auto_block', // score > 0.95
medium_confidence: 'human_review', // 0.7 - 0.95
low_confidence: 'allow_with_flag' // threshold - 0.7
}
};
تحديث الحدود أثناء التشغيل
اسمح بتعديل الحدود دون إعادة النشر:
class ModerationService {
constructor() {
this.thresholds = defaultThresholds;
this.loadRemoteConfig();
}
async loadRemoteConfig() {
try {
const config = await fetch('/api/admin/moderation-config');
const data = await config.json();
this.thresholds = data.thresholds;
console.log('Loaded remote moderation config');
} catch (error) {
console.warn('Using default thresholds:', error);
}
}
async checkContent(content, context) {
const result = await callModerationAPI(content);
const thresholds = this.getThresholdsForContext(context);
return this.applyThresholds(result, thresholds);
}
}
قياس فعالية العتبات
المقاييس الأساسية
const MODERATION_METRICS = {
// Accuracy
precision: 'True positives / (True positives + False positives)',
recall: 'True positives / (True positives + False negatives)',
f1_score: 'Harmonic mean of precision and recall',
// User impact
block_rate: 'Content blocked / Total content',
appeal_rate: 'Appeals filed / Content blocked',
appeal_success: 'Appeals won / Appeals filed',
// Operational
review_queue_size: 'Items waiting for human review',
review_time: 'Average time to human decision'
};
عتبات اختبار A/B
اختبر تغييرات العتبات على مجموعة فرعية من الزيارات:
async function moderateWithExperiment(content, userId) {
const experiment = getExperiment(userId, 'threshold_test');
const thresholds = experiment === 'control'
? CURRENT_THRESHOLDS
: EXPERIMENTAL_THRESHOLDS;
const result = await checkContent(content);
const decision = applyThresholds(result, thresholds);
// Log for analysis
await logExperiment({
experiment: 'threshold_test',
variant: experiment,
content_id: content.id,
scores: result,
decision: decision,
timestamp: Date.now()
});
return decision;
}
تحليل النتائج
-- Calculate precision and recall for each threshold variant
SELECT
variant,
COUNT(*) as total_decisions,
SUM(CASE WHEN blocked AND actually_harmful THEN 1 ELSE 0 END) as true_positives,
SUM(CASE WHEN blocked AND NOT actually_harmful THEN 1 ELSE 0 END) as false_positives,
SUM(CASE WHEN NOT blocked AND actually_harmful THEN 1 ELSE 0 END) as false_negatives,
SUM(CASE WHEN blocked AND actually_harmful THEN 1 ELSE 0 END) * 1.0 /
NULLIF(SUM(CASE WHEN blocked THEN 1 ELSE 0 END), 0) as precision,
SUM(CASE WHEN blocked AND actually_harmful THEN 1 ELSE 0 END) * 1.0 /
NULLIF(SUM(CASE WHEN actually_harmful THEN 1 ELSE 0 END), 0) as recall
FROM moderation_decisions
WHERE experiment = 'threshold_test'
GROUP BY variant;
سير عمل ضبط العتبات
الخطوة 1: إنشاء خط أساس
// Start with conservative thresholds
const INITIAL_THRESHOLDS = {
threshold_toxicity: 0.5,
threshold_profanity: 0.5,
threshold_spam: 0.6
};
الخطوة 2: جمع البيانات
async function logModerationDecision(content, result, decision) {
await db.insert('moderation_log', {
content_id: content.id,
content_hash: hashContent(content.text),
scores: result.results,
thresholds_used: currentThresholds,
decision: decision,
user_trust_level: content.author.trustLevel,
created_at: Date.now()
});
}
الخطوة 3: تحليل معدلات الأخطاء
راجع المحتوى المحظور واعتراضات المستخدمين لتحديد:
- الإيجابيات الخاطئة: محتوى آمن حُظر عن طريق الخطأ
- السلبيات الخاطئة: محتوى ضار لم يتم رصده
الخطوة 4: التعديل والتكرار
// Based on analysis, raise thresholds that fire too often
const ADJUSTED_THRESHOLDS = {
threshold_toxicity: 0.65, // Raised after false positives
threshold_profanity: 0.55,
threshold_spam: 0.7
};
الخطوة 5: المراقبة المستمرة
أعِدّ تنبيهات لقياس فعالية العتبات:
async function checkModerationHealth() {
const stats = await getModerationStats(last24Hours);
// Alert if false positive rate too high
if (stats.appealSuccessRate > 0.3) {
alert('High appeal success rate - thresholds may be too strict');
}
// Alert if harmful content is getting through
if (stats.reportedAfterApproval > threshold) {
alert('Increase in reported content - thresholds may be too permissive');
}
}
ملخص أفضل الممارسات
- ابدأ بتحفّظ: ابدأ بعتبات أكثر صرامة، ثم خفّفها بناءً على البيانات.
- استخدم السياق: تتطلّب المساحات المختلفة (المنشورات العامة، الرسائل المباشرة، الملفات الشخصية) عتبات مختلفة.
- مستويات الثقة مهمة: عدّل العتبة الفعلية وفقًا لسمعة المستخدم في تطبيقك.
- قِس كل شيء: تتبّع الدقة، والاستدعاء، وتأثير ذلك على المستخدمين.
- واصِل التحسين باستمرار: الإشراف لا يكون "منتهيًا" أبدًا.
- وثّق القرارات: احتفظ بسجلات توضّح سبب تغيير العتبات.
- وفّر خيارات احتياطية: وجّه الحالات الحدّية إلى المراجعة البشرية.
تذكّر: في Discuse، تُعد هذه العتبات إعدادات خاصة بالمشروع. يمكنك تغييرها من لوحة التحكم أو عبر settings API؛ أما كائن settings في كل طلب، فيقتصر دوره على تبديل عمليات check_* التي يتم تشغيلها.
الخطوات التالية
- دليل الإشراف على المحتوى باستخدام AI - فهم الإشراف باستخدام AI
- توسيع نطاق الإشراف على المحتوى - تنفيذ مناسب للأحجام الكبيرة
- تحليل النصوص - تفاصيل الإشراف الخاصة بالنصوص