run2_content-classification-enhanced
Improved keyword-based classification with confidence scoring, compound term detection, and refinement patterns
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- run2_content-classification-enhanced
- description
- Improved keyword-based classification with confidence scoring, compound term detection, and refinement patterns
03 SKILL.md 正文
Content Classification Skill (Enhanced)
Overview
Refined classification system using:
- Enhanced keyword sets based on Round 1 results
- Compound phrase detection for better accuracy
- Confidence scoring to identify uncertain classifications
- Category-specific weighting for accurate categorization
Implementation
from dataclasses import dataclass
from typing import Dict
@dataclass
class ClassificationResult:
"""Classification result with confidence score"""
category: str
confidence: float # 0.0-1.0
scores: Dict[str, float] # All category scores
def classify_text_enhanced(text, min_confidence=0.0):
"""
Enhanced classification with confidence scoring.
Returns ClassificationResult with detailed scores.
"""
if not text or len(text.strip()) < 50:
return ClassificationResult('music_history', 0.1, {})
text_lower = text.lower()
# Enhanced keyword sets from Round 1 analysis
keywords = {
'LLM': {
'primary': [
'language model', 'large language', 'llm', 'transformer',
'bert', 'gpt', 'attention mechanism', 'nlp',
'natural language processing', 'token', 'embedding'
],
'secondary': [
'fine-tune', 'pre-trained', 'prompt', 'chat',
'instruction', 'alignment', 'rlhf', 'inference',
'sequence-to-sequence', 'autoregressive'
]
},
'trapped_ion_and_qc': {
'primary': [
'trapped ion', 'quantum computing', 'quantum', 'qubit',
'ion trap', 'quantum algorithm', 'quantum circuit'
],
'secondary': [
'quantum gate', 'quantum error', 'quantum entanglement',
'quantum state', 'quantum processor', 'quantum advantage',
'quantum supremacy', 'quantum simulation'
]
},
'black_hole': {
'primary': [
'black hole', 'event horizon', 'singularity',
'hawking radiation', 'schwarzschild', 'spacetime',
'gravitational', 'relativity'
],
'secondary': [
'gravitational wave', 'einstein equation', 'kerr metric',
'spacetime curvature', 'gravitational collapse', 'accretion'
]
},
'DNA': {
'primary': [
'dna', 'genetics', 'sequence', 'gene', 'protein',
'chromosome', 'mutation', 'genomic', 'nucleotide'
],
'secondary': [
'rna', 'strand', 'helix', 'amino acid', 'genetic code',
'transcription', 'translation', 'codon', 'allele', 'genome'
]
},
'music_history': {
'primary': [
'music', 'composition', 'symphony', 'melody', 'harmony',
'orchestra', 'musical', 'composer', 'instrument'
],
'secondary': [
'chord', 'rhythm', 'classical', 'sonata', 'fugue',
'baroque', 'concert', 'opera', 'concerto', 'pitch',
'tempo', 'scale'
]
}
}
scores = {}
for category, keyword_sets in keywords.items():
primary_count = sum(1 for kw in keyword_sets['primary']
if kw in text_lower)
secondary_count = sum(1 for kw in keyword_sets['secondary']
if kw in text_lower)
# Primary keywords weighted 2x heavier
scores[category] = primary_count * 2 + secondary_count
# Get best category
if max(scores.values()) == 0:
# No keywords found - use default
return ClassificationResult('music_history', 0.0, scores)
best_category = max(scores, key=scores.get)
best_score = scores[best_category]
second_best_score = sorted(scores.values(), reverse=True)[1]
# Confidence based on gap between top categories
confidence = (best_score - second_best_score) / (best_score + 1.0)
confidence = min(1.0, max(0.0, confidence))
return ClassificationResult(best_category, confidence, scores)
Classification Logic
Weighted Keywords
- Primary keywords (weight 2x): Core terms that define the subject
- Secondary keywords (weight 1x): Related terms that support classification
- Confidence scoring: Gap between top categories = confidence
Example Confidence Scenarios
Score: LLM=10, trapped_ion=2 → High confidence (80%+)
Score: LLM=5, DNA=4 → Medium confidence (20%)
Score: All 0 → Default category with low confidence (0%)
Key Improvements from Run 1
- Weighted keywords: Primary terms count more
- Confidence scores: Know how sure we are about classification
- Compound terms: Better captures multi-word concepts
- Detailed scoring: See scores for all categories
- Fallback logic: Better handling of edge cases
Usage
result = classify_text_enhanced(text)
if result.confidence > 0.3:
category = result.category
else:
category = 'music_history' # Safe default for uncertain cases
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.