[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tool-codelion--adaptive-classifier":3,"similar-codelion--adaptive-classifier":201},{"id":4,"github_repo":5,"name":6,"description_en":7,"description_zh":8,"ai_summary_zh":8,"readme_en":9,"readme_zh":10,"quickstart_zh":11,"use_case_zh":12,"hero_image_url":13,"owner_login":14,"owner_name":15,"owner_avatar_url":16,"owner_bio":17,"owner_company":18,"owner_location":19,"owner_email":20,"owner_twitter":21,"owner_website":22,"owner_url":23,"languages":24,"stars":29,"forks":30,"last_commit_at":31,"license":32,"difficulty_score":33,"env_os":34,"env_gpu":35,"env_ram":34,"env_deps":36,"category_tags":43,"github_topics":46,"view_count":65,"oss_zip_url":20,"oss_zip_packed_at":20,"status":66,"created_at":67,"updated_at":68,"faqs":69,"releases":100},9976,"codelion\u002Fadaptive-classifier","adaptive-classifier","A flexible, adaptive classification system for dynamic text classification","adaptive-classifier 是一个基于 PyTorch 构建的灵活文本分类系统，专为应对动态变化的业务场景而设计。它解决了传统模型在面对新类别时需重新训练、易遗忘旧知识以及难以抵御对抗性攻击等痛点，实现了在生产环境中零停机更新模型和动态添加新类别的能力。\n\n该工具特别适合需要构建高鲁棒性分类系统的开发者、研究人员及企业技术团队，尤其是在内容风控、智能客服或大模型路由优化等场景中。其核心技术亮点包括：支持持续学习以避免“灾难性遗忘”，利用 FAISS 加速原型记忆检索，并引入博弈论策略来防御恶意输入，显著提升模型在对抗环境下的稳定性。此外，它兼容所有 HuggingFace  трансформер模型，并内置 ONNX 运行时将 CPU 推理速度提升 2 至 4 倍。无论是处理突发新增的分类标签，还是防范精心构造的对抗样本，adaptive-classifier 都能提供企业级的可靠表现，让文本分类更加智能且自适应。","\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_3dfe2b8f69d9.webp\" alt=\"Adaptive Classifier Logo\" width=\"300\"\u002F>\n  \n  \u003Ch1>Adaptive Classifier\u003C\u002Fh1>\n  \u003Cp>\u003Cstrong>🚀 Dynamic text classification with continuous learning, strategic defense, and zero-downtime adaptation\u003C\u002Fstrong>\u003C\u002Fp>\n  \n  [![PyPI - Version](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fadaptive-classifier)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fadaptive-classifier\u002F)\n  [![PyPI - Downloads](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fdm\u002Fadaptive-classifier)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fadaptive-classifier\u002F)\n  [![GitHub Stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fcodelion\u002Fadaptive-classifier)](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fstargazers)\n  [![License: Apache 2.0](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache%202.0-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FApache-2.0)\n  [![GitHub Discussions](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fdiscussions\u002Fcodelion\u002Fadaptive-classifier)](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fdiscussions)\n\n\u003C\u002Fdiv>\n\n---\n\n## 🔗 Quick Links\n\n- 📚 **[HuggingFace Organization](https:\u002F\u002Fhuggingface.co\u002Fadaptive-classifier)** - Pre-trained models and datasets\n- 📖 **Articles & Tutorials:**\n  - [Adaptive Classifier: Dynamic Text Classification](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fcodelion\u002Fadaptive-classifier)\n  - [AutoThink: Advanced Reasoning Techniques](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fcodelion\u002Fautothink)\n  - [Enterprise-Ready Classifiers](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fcodelion\u002Fenterprise-ready-classifiers)\n\n---\n\nAdaptive Classifier is a PyTorch-based machine learning library that revolutionizes text classification with **continuous learning**, **dynamic class addition**, and **strategic defense against adversarial inputs**. Built on HuggingFace transformers, it enables zero-downtime model updates and enterprise-grade robustness.\n\n## ✨ Key Features\n\n### 🎯 **Core Capabilities**\n- **🚀 Universal Compatibility** - Works with any HuggingFace transformer model\n- **⚡ Optimized Inference** - Built-in ONNX Runtime for 2-4x faster CPU predictions\n- **📈 Continuous Learning** - Add new examples without catastrophic forgetting\n- **🔄 Dynamic Classes** - Add new classes at runtime without retraining\n- **⏱️ Zero Downtime** - Update models in production without service interruption\n\n### 🛡️ **Advanced Defense**\n- **🎮 Strategic Classification** - Game-theoretic defense against adversarial manipulation\n- **🔒 Anti-Gaming Protection** - Robust predictions under strategic behavior\n- **⚖️ Multiple Prediction Modes** - Regular, strategic, and robust inference options\n\n### 🧠 **Intelligent Architecture** \n- **💾 Prototype Memory** - FAISS-powered efficient similarity search\n- **🔬 Adaptive Neural Layer** - Trainable classification head with EWC protection\n- **🎯 Hybrid Predictions** - Combines prototype similarity and neural network outputs\n- **📊 HuggingFace Integration** - Push\u002Fpull models directly from the Hub\n\n---\n\n## 📊 Performance & Benchmarks\n\n### 🛡️ Strategic Classification Defense\nTested on adversarial examples from AI-Secure\u002Fadv_glue dataset:\n\n| Metric | Regular Classifier | Strategic Classifier | **Improvement** |\n|--------|-------------------|---------------------|----------------|\n| Clean Data Accuracy | 80.00% | **82.22%** | **+2.22%** |\n| Adversarial Data Accuracy | 60.00% | **82.22%** | **+22.22%** |\n| Robustness (vs attack) | -20.00% drop | **0.00% drop** | **Perfect** |\n\n### 🔍 Hallucination Detection\nEvaluated on RAGTruth benchmark across multiple task types:\n\n| Task Type | Precision | Recall | **F1 Score** |\n|-----------|-----------|--------|-------------|\n| QA | 35.50% | 45.11% | 39.74% |\n| Summarization | 22.18% | **96.91%** | 36.09% |\n| Data-to-Text | **65.00%** | **100.0%** | **78.79%** |\n| **Overall** | **40.89%** | **80.68%** | **51.54%** |\n\n### 🚦 LLM Router Optimization\nTested on arena-hard-auto-v0.1 dataset (500 queries):\n\n| Metric | Without Adaptation | With Adaptation | **Improvement** |\n|--------|-------------------|----------------|----------------|\n| Cost Savings | 25.60% | **32.40%** | **+6.80%** |\n| Efficiency Ratio | 1.00x | **1.27x** | **+27%** |\n| Resource Utilization | Standard | **Optimized** | **Better** |\n\n> **Key Insight**: Adaptive classification maintains quality while significantly improving cost efficiency and robustness across all tested scenarios.\n\n---\n\n## Try Now\n\n| Use Case | Demonstrates | Link |\n|----------|----------|-------|\n| Basic Example (Cat or Dog)  | Continuous learning | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1Zmvtb3XUFtUImEmYdKpkuqmxKVlRxzt9?usp=sharing) |\n| Support Ticket Classification| Realistic examples | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1yeVCi_Cdx2jtM7HI0gbU6VlZDJsg_m8u?usp=sharing) |\n| Query Classification  | Different configurations | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1b2q303CLDRQAkC65Rtwcoj09ovR0mGwz?usp=sharing) |\n| Multilingual Sentiment Analysis | Ensemble of classifiers | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F14tfRi_DtL-QgjBMgVRrsLwcov-zqbKBl?usp=sharing) |\n| Product Category Classification | Batch processing | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1VyxVubB8LXXES6qElEYJL241emkV_Wxc?usp=sharing) |\n| Multi-label Classification | Extensibility | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1MDL_45QWvGoM2N8NRfUQSy2J7HKmmTsv?usp=sharing) |\n\n## 🚀 Installation\n\n### Quick Install\n```bash\npip install adaptive-classifier\n```\n\n**Includes:** ONNX Runtime for 2-4x faster CPU inference out-of-the-box\n\n### 🛠️ Development Setup\n```bash\n# Clone the repository\ngit clone https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier.git\ncd adaptive-classifier\n\n# Install in development mode\npip install -e .\n\n# Install test dependencies (optional)\npip install pytest pytest-cov pytest-randomly\n```\n\n---\n\n## ⚡ Quick Start\n\n### 30-Second Setup\nGet started with adaptive classification in under 30 seconds:\n\n```python\nfrom adaptive_classifier import AdaptiveClassifier\n\n# 🎯 Step 1: Initialize with any HuggingFace model\nclassifier = AdaptiveClassifier(\"bert-base-uncased\")\n\n# 📝 Step 2: Add training examples\ntexts = [\"The product works great!\", \"Terrible experience\", \"Neutral about this purchase\"]\nlabels = [\"positive\", \"negative\", \"neutral\"]\nclassifier.add_examples(texts, labels)\n\n# 🔮 Step 3: Make predictions\npredictions = classifier.predict(\"This is amazing!\")\nprint(predictions)  \n# Output: [('positive', 0.85), ('neutral', 0.12), ('negative', 0.03)]\n```\n\n### 🏷️ Multi-Label Classification\n\nClassify texts into multiple categories simultaneously with automatic threshold adaptation:\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# Initialize multi-label classifier\nclassifier = MultiLabelAdaptiveClassifier(\n    \"bert-base-uncased\",\n    min_predictions=1,    # Ensure at least 1 prediction\n    max_predictions=5     # Limit to top 5 predictions\n)\n\n# Multi-label training data (each text can have multiple labels)\ntexts = [\n    \"AI researchers study climate change using machine learning\",\n    \"Tech startup develops healthcare solutions\"\n]\nlabels = [\n    [\"technology\", \"science\", \"climate\", \"ai\"],\n    [\"technology\", \"business\", \"healthcare\"]\n]\n\nclassifier.add_examples(texts, labels)\n\n# Make multi-label predictions\npredictions = classifier.predict_multilabel(\"Medical AI breakthrough announced\")\n# Output: [('healthcare', 0.72), ('technology', 0.68), ('ai', 0.45)]\n```\n\n### 💾 Save & Load Models\n\n```python\n# Save locally\nclassifier.save(\".\u002Fmy_classifier\")\nloaded_classifier = AdaptiveClassifier.load(\".\u002Fmy_classifier\")\n\n# 🤗 HuggingFace Hub Integration\nclassifier.push_to_hub(\"adaptive-classifier\u002Fmy-model\")\nhub_classifier = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fmy-model\")\n```\n\n### 🎮 Strategic Defense (Anti-Gaming)\n\n```python\n# Enable strategic classification for adversarial robustness\nconfig = {'enable_strategic_mode': True}\nstrategic_classifier = AdaptiveClassifier(\"bert-base-uncased\", config=config)\n\n# Robust predictions against manipulation\npredictions = strategic_classifier.predict(\"This product has amazing quality features!\")\n# Returns predictions that consider potential gaming attempts\n```\n\n### ⚡ Optimized CPU Inference with ONNX\n\nAdaptive Classifier includes **built-in ONNX Runtime support** for **2-4x faster CPU inference** with zero code changes required.\n\n#### Automatic Optimization (Default)\n\nONNX Runtime is automatically used on CPU for optimal performance:\n\n```python\n# Automatically uses ONNX on CPU, PyTorch on GPU\nclassifier = AdaptiveClassifier(\"bert-base-uncased\")\n\n# That's it! Predictions are 2-4x faster on CPU\npredictions = classifier.predict(\"Fast inference!\")\n```\n\n#### Performance Comparison\n\n| Configuration | Speed | Use Case |\n|--------------|-------|----------|\n| PyTorch (GPU) | Fastest | GPU servers |\n| **ONNX (CPU)** | **2-4x faster** | **Production CPU deployments** |\n| PyTorch (CPU) | Baseline | Development, training |\n\n#### Save & Deploy with ONNX\n\n```python\n# Save with ONNX export (both quantized & unquantized versions)\nclassifier.save(\".\u002Fmodel\")\n\n# Push to Hub with ONNX (both versions included by default)\nclassifier.push_to_hub(\"username\u002Fmodel\")\n\n# Load automatically uses quantized ONNX on CPU (fastest, 4x smaller)\nfast_classifier = AdaptiveClassifier.load(\".\u002Fmodel\")\n\n# Choose unquantized ONNX for maximum accuracy\naccurate_classifier = AdaptiveClassifier.load(\".\u002Fmodel\", prefer_quantized=False)\n\n# Force PyTorch (no ONNX)\npytorch_classifier = AdaptiveClassifier.load(\".\u002Fmodel\", use_onnx=False)\n\n# Opt-out of ONNX export when saving\nclassifier.save(\".\u002Fmodel\", include_onnx=False)\n```\n\n**ONNX Model Versions:**\n- **Quantized (default)**: INT8 quantized, 4x smaller, ~1.14x faster on ARM, 2-4x faster on x86\n- **Unquantized**: Full precision, maximum accuracy, larger file size\n\nBy default, models are saved with both versions, and the quantized version is automatically loaded for best performance. Use `prefer_quantized=False` if you need maximum accuracy.\n\n#### Benchmark Your Model\n\n```bash\n# Compare PyTorch vs ONNX performance\npython scripts\u002Fbenchmark_onnx.py --model bert-base-uncased --runs 100\n```\n\n**Example Results:**\n```\nModel: bert-base-uncased (CPU)\nPyTorch:  8.3ms\u002Fquery  (baseline)\nONNX:     2.1ms\u002Fquery  (4.0x faster) ✓\n```\n\n> **Note:** ONNX optimization is included by default. For GPU inference, PyTorch is automatically used for best performance.\n\n## Advanced Usage\n\n### Adding New Classes Dynamically\n\n```python\n# Add a completely new class\nnew_texts = [\n    \"Error code 404 appeared\",\n    \"System crashed after update\"\n]\nnew_labels = [\"technical\"] * 2\n\nclassifier.add_examples(new_texts, new_labels)\n```\n\n### Continuous Learning\n\n```python\n# Add more examples to existing classes\nmore_examples = [\n    \"Best purchase ever!\",\n    \"Highly recommend this\"\n]\nmore_labels = [\"positive\"] * 2\n\nclassifier.add_examples(more_examples, more_labels)\n```\n\n### Multi-Label Classification with Advanced Configuration\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# Configure advanced multi-label settings\nclassifier = MultiLabelAdaptiveClassifier(\n    \"bert-base-uncased\",\n    default_threshold=0.5,      # Base threshold for predictions\n    min_predictions=1,          # Minimum labels to return\n    max_predictions=10          # Maximum labels to return\n)\n\n# Training with diverse multi-label examples\ntexts = [\n    \"Scientists develop AI for medical diagnosis and climate research\",\n    \"Tech company launches sustainable energy and healthcare products\",\n    \"Olympic athletes use sports science and nutrition technology\"\n]\nlabels = [\n    [\"science\", \"ai\", \"healthcare\", \"research\"],\n    [\"technology\", \"business\", \"environment\", \"healthcare\"],\n    [\"sports\", \"science\", \"health\", \"technology\"]\n]\n\nclassifier.add_examples(texts, labels)\n\n# Advanced prediction options\npredictions = classifier.predict_multilabel(\n    \"New research on AI applications in environmental science\",\n    threshold=0.3,     # Custom threshold\n    max_labels=5       # Limit results\n)\n\n# Get detailed statistics\nstats = classifier.get_label_statistics()\nprint(f\"Adaptive threshold: {stats['adaptive_threshold']}\")\nprint(f\"Label-specific thresholds: {stats['label_thresholds']}\")\n```\n\n### Strategic Classification (Anti-Gaming)\n\n```python\n# Enable strategic mode to defend against adversarial inputs\nconfig = {\n    'enable_strategic_mode': True,\n    'cost_function_type': 'linear',\n    'cost_coefficients': {\n        'sentiment_words': 0.5,    # Cost to change sentiment-bearing words\n        'length_change': 0.1,      # Cost to modify text length\n        'word_substitution': 0.3   # Cost to substitute words\n    },\n    'strategic_blend_regular_weight': 0.6,   # Weight for regular predictions\n    'strategic_blend_strategic_weight': 0.4  # Weight for strategic predictions\n}\n\nclassifier = AdaptiveClassifier(\"bert-base-uncased\", config=config)\nclassifier.add_examples(texts, labels)\n\n# Robust predictions that consider potential manipulation\ntext = \"This product has amazing quality features!\"\n\n# Dual prediction (automatic blend of regular + strategic)\npredictions = classifier.predict(text)\n\n# Pure strategic prediction (simulates adversarial manipulation)\nstrategic_preds = classifier.predict_strategic(text)\n\n# Robust prediction (assumes input may already be manipulated)\nrobust_preds = classifier.predict_robust(text)\n\nprint(f\"Dual: {predictions}\")\nprint(f\"Strategic: {strategic_preds}\")\nprint(f\"Robust: {robust_preds}\")\n```\n\n## 🏷️ Multi-Label Classification\n\nThe `MultiLabelAdaptiveClassifier` extends adaptive classification to handle scenarios where each text can belong to multiple categories simultaneously. It automatically handles threshold adaptation for scenarios with many labels.\n\n### Key Features\n\n- **🎯 Automatic Threshold Adaptation**: Dynamically adjusts thresholds based on the number of labels to prevent empty predictions\n- **📊 Sigmoid Activation**: Uses proper multi-label architecture with BCE loss instead of softmax\n- **⚙️ Configurable Limits**: Set minimum and maximum number of predictions per input\n- **📈 Label-Specific Thresholds**: Automatically adjusts thresholds based on label frequency\n- **🔄 Incremental Learning**: Add new labels and examples without retraining from scratch\n\n### Usage\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# Initialize with configuration\nclassifier = MultiLabelAdaptiveClassifier(\n    \"distilbert\u002Fdistilbert-base-cased\",\n    default_threshold=0.5,\n    min_predictions=1,\n    max_predictions=5\n)\n\n# Multi-label training data\ntexts = [\n    \"Breaking: Scientists discover AI can help predict climate change patterns\",\n    \"Tech giant announces breakthrough in quantum computing for healthcare\",\n    \"Olympic committee adopts new sports technology for athlete performance\"\n]\n\nlabels = [\n    [\"science\", \"technology\", \"climate\", \"news\"],\n    [\"technology\", \"healthcare\", \"quantum\", \"business\"],\n    [\"sports\", \"technology\", \"performance\", \"news\"]\n]\n\n# Train the classifier\nclassifier.add_examples(texts, labels)\n\n# Make predictions\npredictions = classifier.predict_multilabel(\n    \"Revolutionary medical AI system launched by tech startup\"\n)\n\n# Results: [('technology', 0.85), ('healthcare', 0.72), ('business', 0.45)]\n```\n\n### Adaptive Thresholds\n\nThe classifier automatically adjusts prediction thresholds based on the number of labels:\n\n| Number of Labels | Threshold | Benefit |\n|-----------------|-----------|---------|\n| 2-4 labels | 0.5 (default) | Standard precision |\n| 5-9 labels | 0.4 (20% lower) | Balanced recall |\n| 10-19 labels | 0.3 (40% lower) | Better coverage |\n| 20-29 labels | 0.2 (60% lower) | Prevents empty results |\n| 30+ labels | 0.1 (80% lower) | Ensures predictions |\n\nThis solves the common \"No labels met the threshold criteria\" issue when dealing with many-label scenarios.\n\n---\n\n## 🏢 Enterprise Use Cases\n\n### 🔍 Hallucination Detection\nDetect when LLMs generate information not supported by provided context (51.54% F1, 80.68% recall):\n\n```python\ndetector = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fllm-hallucination-detector\")\ncontext = \"France is in Western Europe. Capital: Paris. Population: ~67 million.\"\nresponse = \"Paris is the capital. Population is 70 million.\"  # Contains hallucination\n\nprediction = detector.predict(f\"Context: {context}\\nAnswer: {response}\")\n# Returns: [('HALLUCINATED', 0.72), ('NOT_HALLUCINATED', 0.28)]\n```\n\n### 🚦 Intelligent LLM Routing\nOptimize costs by routing queries to appropriate model tiers (32.40% cost savings):\n\n```python\nrouter = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fllm-router\")\nquery = \"Write a function to calculate Fibonacci sequence\"\n\npredictions = router.predict(query)\n# Returns: [('HIGH', 0.92), ('LOW', 0.08)]\n# Route to GPT-4 for complex tasks, GPT-3.5 for simple ones\n```\n\n### ⚙️ Configuration Optimization\nAutomatically predict optimal LLM settings (temperature, top_p) for different query types:\n\n```python\nconfig_optimizer = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fllm-config-optimizer\")\nquery = \"Explain quantum physics concepts\"\n\npredictions = config_optimizer.predict(query)\n# Returns: [('BALANCED', 0.85), ('CREATIVE', 0.10), ...]\n# Automatically suggests temperature range: 0.6-1.0 for balanced responses\n```\n\n### 🛡️ Content Moderation\nDeploy enterprise-ready classifiers for various moderation tasks:\n\n```python\n# Available pre-trained enterprise classifiers:\nclassifiers = [\n    \"adaptive-classifier\u002Fcontent-moderation\",      # Content safety\n    \"adaptive-classifier\u002Fbusiness-sentiment\",      # Business communications\n    \"adaptive-classifier\u002Fpii-detection\",           # Privacy protection\n    \"adaptive-classifier\u002Ffraud-detection\",         # Financial security\n    \"adaptive-classifier\u002Femail-priority\",          # Email routing\n    \"adaptive-classifier\u002Fcompliance-classification\" # Regulatory compliance\n]\n\n# Easy deployment\nmoderator = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fcontent-moderation\")\nresult = moderator.predict(\"User generated content here...\")\n```\n\n> **💡 Pro Tip**: All enterprise models support continuous adaptation - add your domain-specific examples to improve performance over time.\n\n---\n\n## Architecture Overview\n\nThe Adaptive Classifier combines four key components in a unified architecture:\n\n![Adaptive Classifier Architecture](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_6e9ae24cd3a3.png)\n\n1. **Transformer Embeddings**: Uses state-of-the-art language models for text representation\n\n2. **Prototype Memory**: Maintains class prototypes for quick adaptation to new examples\n\n3. **Adaptive Neural Layer**: Learns refined decision boundaries through continuous training\n\n4. **Strategic Classification**: Defends against adversarial manipulation using game-theoretic principles. When strategic mode is enabled, the system:\n   - Models potential strategic behavior of users trying to game the classifier\n   - Uses cost functions to represent the difficulty of manipulating different features\n   - Combines regular predictions with strategic-aware predictions for robustness\n   - Provides multiple prediction modes: dual (blended), strategic (simulates manipulation), and robust (anti-manipulation)\n\n## Why Adaptive Classification?\n\nTraditional classification approaches face significant limitations when dealing with evolving requirements and adversarial environments:\n\n![Traditional vs Adaptive Classification](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_582473f468c9.png)\n\nThe Adaptive Classifier overcomes these limitations through:\n- **Dynamic class addition** without full retraining\n- **Strategic robustness** against adversarial manipulation\n- **Memory-efficient prototypes** with FAISS optimization\n- **Zero downtime updates** for production systems\n- **Game-theoretic defense** mechanisms\n\n## Continuous Learning Process\n\nThe system evolves through distinct phases, each building upon previous knowledge without catastrophic forgetting:\n\n![Continuous Learning Workflow](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_69203e7a2d12.png)\n\nThe learning process includes:\n- **Initial Training**: Bootstrap with basic classes\n- **Dynamic Addition**: Seamlessly add new classes as they emerge\n- **Continuous Learning**: Refine decision boundaries with EWC protection\n- **Strategic Enhancement**: Develop robustness against manipulation\n- **Production Deployment**: Full capability with ongoing adaptation\n\n## Order Dependency in Online Learning\n\nWhen using the adaptive classifier for true online learning (adding examples incrementally), be aware that the order in which examples are added can affect predictions. This is inherent to incremental neural network training.\n\n### The Challenge\n\n```python\n# These two scenarios may produce slightly different models:\n\n# Scenario 1\nclassifier.add_examples([\"fish example\"], [\"aquatic\"])\nclassifier.add_examples([\"bird example\"], [\"aerial\"])\n\n# Scenario 2  \nclassifier.add_examples([\"bird example\"], [\"aerial\"])\nclassifier.add_examples([\"fish example\"], [\"aquatic\"])\n```\n\nWhile we've implemented sorted label ID assignment to minimize this effect, the neural network component still learns incrementally, which can lead to order-dependent behavior.\n\n### Solution: Prototype-Only Predictions\n\nFor applications requiring strict order independence, you can configure the classifier to rely solely on prototype-based predictions:\n\n```python\n# Configure to use only prototypes (order-independent)\nconfig = {\n    'prototype_weight': 1.0,  # Use only prototypes\n    'neural_weight': 0.0      # Disable neural network contribution\n}\n\nclassifier = AdaptiveClassifier(\"bert-base-uncased\", config=config)\n```\n\nWith this configuration:\n- Predictions are based solely on similarity to class prototypes (mean embeddings)\n- Results are completely order-independent\n- Trade-off: May have slightly lower accuracy than the hybrid approach\n\n### Best Practices\n\n1. **For maximum consistency**: Use prototype-only configuration\n2. **For maximum accuracy**: Accept some order dependency with the default hybrid approach\n3. **For production systems**: Consider batching updates and retraining periodically if strict consistency is required\n4. **Model selection matters**: Some models (e.g., `google-bert\u002Fbert-large-cased`) may produce poor embeddings for single words. For better results with short inputs, consider:\n   - `bert-base-uncased`\n   - `sentence-transformers\u002Fall-MiniLM-L6-v2`\n   - Or any model specifically trained for semantic similarity\n\n---\n\n## 🔗 Related Projects\n\n- **[OpenEvolve](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fopenevolve)** - Open-source evolutionary coding agent for algorithm discovery\n- **[OptiLLM](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Foptillm)** - Optimizing inference proxy with 20+ techniques for 2-10x accuracy improvements\n\n## 🤝 Community & Contributing\n\n- **🐛 Issues & Bug Reports**: [GitHub Issues](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues)\n- **💬 Discussions**: [GitHub Discussions](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fdiscussions)\n- **📖 Documentation**: [API Reference](docs\u002FAPI.md)\n- **🛠️ Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md)\n\n## 📚 References\n\n- [Strategic Classification](https:\u002F\u002Farxiv.org\u002Fabs\u002F1506.06980)\n- [RouteLLM: Learning to Route LLMs with Preference Data](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.18665)\n- [Transformer^2: Self-adaptive LLMs](https:\u002F\u002Farxiv.org\u002Fabs\u002F2501.06252)\n- [Lamini Classifier Agent Toolkit](https:\u002F\u002Fwww.lamini.ai\u002Fblog\u002Fclassifier-agent-toolkit)\n- [Protoformer: Embedding Prototypes for Transformers](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.12710)\n- [Overcoming catastrophic forgetting in neural networks](https:\u002F\u002Farxiv.org\u002Fabs\u002F1612.00796)\n- [RAGTruth: A Hallucination Corpus for Developing Trustworthy Retrieval-Augmented Language Models](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.00396)\n- [LettuceDetect: A Hallucination Detection Framework for RAG Applications](https:\u002F\u002Farxiv.org\u002Fabs\u002F2502.17125)\n\n## 📜 Citation\n\nIf you use this library in your research, please cite:\n\n```bibtex\n@software{adaptive-classifier,\n  title = {Adaptive Classifier: Dynamic Text Classification with Continuous Learning},\n  author = {Asankhaya Sharma},\n  year = {2025},\n  publisher = {GitHub},\n  url = {https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier}\n}\n```\n\n---\n\n\u003Cdiv align=\"center\">\n  \u003Cp>\u003Cstrong>Made with ❤️ by \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fadaptive-classifier\">Adaptive Classifier Team\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>\n  \u003Cp>\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\">⭐ Star us on GitHub\u003C\u002Fa> •\n    \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fadaptive-classifier\">🤗 Follow on HuggingFace\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n","\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_3dfe2b8f69d9.webp\" alt=\"Adaptive Classifier Logo\" width=\"300\"\u002F>\n  \n  \u003Ch1>自适应分类器\u003C\u002Fh1>\n  \u003Cp>\u003Cstrong>🚀 基于持续学习、战略防御和零停机自适应的动态文本分类\u003C\u002Fstrong>\u003C\u002Fp>\n  \n  [![PyPI - 版本](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fadaptive-classifier)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fadaptive-classifier\u002F)\n  [![PyPI - 下载量](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fdm\u002Fadaptive-classifier)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fadaptive-classifier\u002F)\n  [![GitHub 星标](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fcodelion\u002Fadaptive-classifier)](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fstargazers)\n  [![许可证：Apache 2.0](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache%202.0-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FApache-2.0)\n  [![GitHub 讨论](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fdiscussions\u002Fcodelion\u002Fadaptive-classifier)](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fdiscussions)\n\n\u003C\u002Fdiv>\n\n---\n\n## 🔗 快速链接\n\n- 📚 **[HuggingFace 组织](https:\u002F\u002Fhuggingface.co\u002Fadaptive-classifier)** - 预训练模型和数据集\n- 📖 **文章与教程：**\n  - [自适应分类器：动态文本分类](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fcodelion\u002Fadaptive-classifier)\n  - [AutoThink：高级推理技术](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fcodelion\u002Fautothink)\n  - [企业级就绪分类器](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fcodelion\u002Fenterprise-ready-classifiers)\n\n---\n\n自适应分类器是一个基于 PyTorch 的机器学习库，通过**持续学习**、**动态添加类别**以及**针对对抗性输入的战略防御**，彻底革新了文本分类。它构建在 HuggingFace 转换器之上，实现了零停机的模型更新和企业级的鲁棒性。\n\n## ✨ 核心特性\n\n### 🎯 **核心能力**\n- **🚀 通用兼容性** - 适用于任何 HuggingFace 转换器模型\n- **⚡ 优化推理** - 内置 ONNX Runtime，使 CPU 预测速度提升 2–4 倍\n- **📈 持续学习** - 可以添加新样本而不会发生灾难性遗忘\n- **🔄 动态类别** - 运行时可添加新类别，无需重新训练\n- **⏱️ 零停机** - 在生产环境中更新模型而不中断服务\n\n### 🛡️ **高级防御**\n- **🎮 战略分类** - 基于博弈论的防御机制，抵御对抗性操纵\n- **🔒 抗游戏化保护** - 在策略性行为下仍能保持稳健的预测\n- **⚖️ 多种预测模式** - 提供常规、战略和鲁棒推理选项\n\n### 🧠 **智能架构**\n- **💾 原型记忆** - 基于 FAISS 的高效相似度搜索\n- **🔬 自适应神经层** - 可训练的分类头，并配备 EWC 保护\n- **🎯 混合预测** - 结合原型相似性和神经网络输出\n- **📊 HuggingFace 集成** - 可直接从 Hub 推送\u002F拉取模型\n\n---\n\n## 📊 性能与基准测试\n\n### 🛡️ 战略分类防御\n在 AI-Secure\u002Fadv_glue 数据集上的对抗性示例测试：\n\n| 指标 | 常规分类器 | 战略分类器 | **提升** |\n|--------|-------------------|---------------------|----------------|\n| 干净数据准确率 | 80.00% | **82.22%** | **+2.22%** |\n| 对抗性数据准确率 | 60.00% | **82.22%** | **+22.22%** |\n| 鲁棒性（对抗攻击） | 下降 20.00% | **无下降** | **完美** |\n\n### 🔍 幻觉检测\n在 RAGTruth 基准测试中，针对多种任务类型进行评估：\n\n| 任务类型 | 精确率 | 召回率 | **F1 分数** |\n|-----------|-----------|--------|-------------|\n| QA | 35.50% | 45.11% | 39.74% |\n| 摘要生成 | 22.18% | **96.91%** | 36.09% |\n| 数据转文本 | **65.00%** | **100.0%** | **78.79%** |\n| **总体** | **40.89%** | **80.68%** | **51.54%** |\n\n### 🚦 LLM 路由优化\n在 arena-hard-auto-v0.1 数据集（500 个查询）上测试：\n\n| 指标 | 未采用自适应 | 采用自适应 | **提升** |\n|--------|-------------------|----------------|----------------|\n| 成本节约 | 25.60% | **32.40%** | **+6.80%** |\n| 效率比 | 1.00x | **1.27x** | **+27%** |\n| 资源利用率 | 标准 | **优化** | **更好** |\n\n> **关键洞察**：自适应分类在所有测试场景中均保持了高质量，同时显著提升了成本效益和鲁棒性。\n\n---\n\n## 立即体验\n\n| 使用场景 | 展示内容 | 链接 |\n|----------|----------|-------|\n| 基础示例（猫或狗）  | 持续学习 | [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1Zmvtb3XUFtUImEmYdKpkuqmxKVlRxzt9?usp=sharing) |\n| 支持工单分类| 真实案例 | [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1yeVCi_Cdx2jtM7HI0gbU6VlZDJsg_m8u?usp=sharing) |\n| 查询分类  | 不同配置 | [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1b2q303CLDRQAkC65Rtwcoj09ovR0mGwz?usp=sharing) |\n| 多语言情感分析 | 分类器集成 | [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F14tfRi_DtL-QgjBMgVRrsLwcov-zqbKBl?usp=sharing) |\n| 产品类别分类 | 批量处理 | [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1VyxVubB8LXXES6qElEYJL241emkV_Wxc?usp=sharing) |\n| 多标签分类 | 可扩展性 | [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1MDL_45QWvGoM2N8NRfUQSy2J7HKmmTsv?usp=sharing) |\n\n## 🚀 安装\n\n### 快速安装\n```bash\npip install adaptive-classifier\n```\n\n**包含：** ONNX Runtime，开箱即用即可实现 2–4 倍的 CPU 推理速度提升\n\n### 🛠️ 开发环境搭建\n```bash\n# 克隆仓库\ngit clone https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier.git\ncd adaptive-classifier\n\n# 以开发模式安装\npip install -e .\n\n# 安装测试依赖（可选）\npip install pytest pytest-cov pytest-randomly\n```\n\n---\n\n## ⚡ 快速入门\n\n### 30 秒设置\n在不到 30 秒内即可开始使用自适应分类：\n\n```python\nfrom adaptive_classifier import AdaptiveClassifier\n\n# 🎯 第一步：使用任意 HuggingFace 模型初始化\nclassifier = AdaptiveClassifier(\"bert-base-uncased\")\n\n# 📝 第二步：添加训练样本\ntexts = [\"这个产品非常好用！\", \"糟糕的体验\", \"对这次购买没什么感觉\"]\nlabels = [\"正面\", \"负面\", \"中性\"]\nclassifier.add_examples(texts, labels)\n\n# 🔮 第三步：进行预测\npredictions = classifier.predict(\"这太棒了！\")\nprint(predictions)  \n# 输出: [('正面', 0.85), ('中性', 0.12), ('负面', 0.03)]\n```\n\n### 🏷️ 多标签分类\n\n同时将文本分类到多个类别，并自动调整阈值：\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# 初始化多标签分类器\nclassifier = MultiLabelAdaptiveClassifier(\n    \"bert-base-uncased\",\n    min_predictions=1,    # 确保至少有1个预测结果\n    max_predictions=5     # 限制为前5个预测结果\n)\n\n# 多标签训练数据（每条文本可以有多个标签）\ntexts = [\n    \"AI研究人员利用机器学习研究气候变化\",\n    \"科技初创公司开发医疗健康解决方案\"\n]\nlabels = [\n    [\"科技\", \"科学\", \"气候\", \"AI\"],\n    [\"科技\", \"商业\", \"医疗\"]\n]\n\nclassifier.add_examples(texts, labels)\n\n# 进行多标签预测\npredictions = classifier.predict_multilabel(\"宣布了医疗AI领域的突破\")\n# 输出: [('医疗', 0.72), ('科技', 0.68), ('AI', 0.45)]\n```\n\n### 💾 保存与加载模型\n\n```python\n# 本地保存\nclassifier.save(\".\u002Fmy_classifier\")\nloaded_classifier = AdaptiveClassifier.load(\".\u002Fmy_classifier\")\n\n# 🤗 Hugging Face Hub 集成\nclassifier.push_to_hub(\"adaptive-classifier\u002Fmy-model\")\nhub_classifier = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fmy-model\")\n```\n\n### 🎮 战略防御（防操纵）\n\n```python\n# 启用战略分类模式以提高对抗鲁棒性\nconfig = {'enable_strategic_mode': True}\nstrategic_classifier = AdaptiveClassifier(\"bert-base-uncased\", config=config)\n\n# 对抗操纵的稳健预测\npredictions = strategic_classifier.predict(\"这款产品具有惊人的优质特性！\")\n# 返回考虑潜在操纵尝试的预测结果\n```\n\n### ⚡ 使用 ONNX 优化 CPU 推理\n\nAdaptive Classifier 内置了 **ONNX Runtime 支持**，可在无需任何代码修改的情况下实现 **CPU 推理速度提升 2–4 倍**。\n\n#### 自动优化（默认）\n\nONNX Runtime 会自动在 CPU 上使用以获得最佳性能：\n\n```python\n# 自动在 CPU 上使用 ONNX，在 GPU 上使用 PyTorch\nclassifier = AdaptiveClassifier(\"bert-base-uncased\")\n\n# 就这样！CPU 上的预测速度提升了 2–4 倍\npredictions = classifier.predict(\"快速推理！\")\n```\n\n#### 性能对比\n\n| 配置               | 速度       | 使用场景                     |\n|--------------------|------------|------------------------------|\n| PyTorch (GPU)      | 最快       | GPU 服务器                   |\n| **ONNX (CPU)**     | **2–4 倍更快** | **生产环境中的 CPU 部署**   |\n| PyTorch (CPU)      | 基线       | 开发、训练                   |\n\n#### 使用 ONNX 保存与部署\n\n```python\n# 保存时导出 ONNX（包含量化与非量化的版本）\nclassifier.save(\".\u002Fmodel\")\n\n# 推送到 Hub 时包含 ONNX（默认同时包含两种版本）\nclassifier.push_to_hub(\"username\u002Fmodel\")\n\n# 加载时会自动选择 CPU 上最快的量化 ONNX（体积小 4 倍）\nfast_classifier = AdaptiveClassifier.load(\".\u002Fmodel\")\n\n# 如果需要最高精度，可以选择非量化的 ONNX\naccurate_classifier = AdaptiveClassifier.load(\".\u002Fmodel\", prefer_quantized=False)\n\n# 强制使用 PyTorch（不使用 ONNX）\npytorch_classifier = AdaptiveClassifier.load(\".\u002Fmodel\", use_onnx=False)\n\n# 在保存时选择不导出 ONNX\nclassifier.save(\".\u002Fmodel\", include_onnx=False)\n```\n\n**ONNX 模型版本：**\n- **量化版（默认）**：INT8 量化，体积缩小 4 倍，ARM 上约快 1.14 倍，x86 上快 2–4 倍。\n- **非量化版**：全精度，精度最高，但文件较大。\n\n默认情况下，模型会同时保存这两种版本，并自动加载量化版本以获得最佳性能。如果需要最高精度，请将 `prefer_quantized` 设置为 `False`。\n\n#### 基准测试你的模型\n\n```bash\n# 比较 PyTorch 与 ONNX 的性能\npython scripts\u002Fbenchmark_onnx.py --model bert-base-uncased --runs 100\n```\n\n**示例结果：**\n```\n模型：bert-base-uncased（CPU）\nPyTorch：8.3ms\u002F查询（基线）\nONNX：2.1ms\u002F查询（快 4.0 倍）✓\n```\n\n> **注意**：ONNX 优化默认已启用。对于 GPU 推理，系统会自动使用 PyTorch 以获得最佳性能。\n\n## 高级用法\n\n### 动态添加新类别\n\n```python\n# 添加一个全新的类别\nnew_texts = [\n    \"出现了错误代码 404\",\n    \"更新后系统崩溃了\"\n]\nnew_labels = [\"技术\"] * 2\n\nclassifier.add_examples(new_texts, new_labels)\n```\n\n### 持续学习\n\n```python\n# 为现有类别添加更多示例\nmore_examples = [\n    \"史上最棒的购买！\",\n    \"强烈推荐这个\"\n]\nmore_labels = [\"正面\"] * 2\n\nclassifier.add_examples(more_examples, more_labels)\n```\n\n### 带高级配置的多标签分类\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# 配置高级多标签设置\nclassifier = MultiLabelAdaptiveClassifier(\n    \"bert-base-uncased\",\n    default_threshold=0.5,      # 预测的基础阈值\n    min_predictions=1,          # 至少返回的标签数量\n    max_predictions=10          # 最多返回的标签数量\n)\n\n# 使用多样化的多标签示例进行训练\ntexts = [\n    \"科学家开发用于医学诊断和气候研究的 AI\",\n    \"科技公司推出可持续能源和医疗健康产品\",\n    \"奥运选手运用运动科学和营养技术\"\n]\nlabels = [\n    [\"科学\", \"AI\", \"医疗\", \"研究\"],\n    [\"科技\", \"商业\", \"环境\", \"医疗\"],\n    [\"体育\", \"科学\", \"健康\", \"科技\"]\n]\n\nclassifier.add_examples(texts, labels)\n\n# 高级预测选项\npredictions = classifier.predict_multilabel(\n    \"关于 AI 在环境科学中应用的新研究\",\n    threshold=0.3,     # 自定义阈值\n    max_labels=5       # 限制结果数量\n)\n\n# 获取详细统计信息\nstats = classifier.get_label_statistics()\nprint(f\"自适应阈值：{stats['adaptive_threshold']}\")\nprint(f\"各标签的特定阈值：{stats['label_thresholds']}\")\n```\n\n### 战略分类（防操纵）\n\n```python\n# 启用战略模式以防御对抗性输入\nconfig = {\n    'enable_strategic_mode': True,\n    'cost_function_type': 'linear',\n    'cost_coefficients': {\n        'sentiment_words': 0.5,    # 改变带有情感色彩的词语的成本\n        'length_change': 0.1,      # 修改文本长度的成本\n        'word_substitution': 0.3   # 替换词语的成本\n    },\n    'strategic_blend_regular_weight': 0.6,   # 普通预测的权重\n    'strategic_blend_strategic_weight': 0.4  # 战略预测的权重\n}\n\nclassifier = AdaptiveClassifier(\"bert-base-uncased\", config=config)\nclassifier.add_examples(texts, labels)\n\n# 考虑潜在操纵的稳健预测\ntext = \"这款产品具有惊人的优质特性！\"\n\n# 双重预测（普通预测与战略预测的自动混合）\npredictions = classifier.predict(text)\n\n# 纯战略预测（模拟对抗性操纵）\nstrategic_preds = classifier.predict_strategic(text)\n\n# 稳健预测（假设输入可能已被操纵）\nrobust_preds = classifier.predict_robust(text)\n\nprint(f\"双重：{predictions}\")\nprint(f\"战略：{strategic_preds}\")\nprint(f\"稳健：{robust_preds}\")\n```\n\n## 🏷️ 多标签分类\n\n`MultiLabelAdaptiveClassifier` 将自适应分类扩展到处理每个文本可以同时属于多个类别的情形。它会自动为多标签场景调整阈值。\n\n### 核心特性\n\n- **🎯 自动阈值调整**：根据标签数量动态调整阈值，防止出现空预测\n- **📊 Sigmoid 激活函数**：采用正确的多标签架构，并使用 BCE 损失而非 softmax\n- **⚙️ 可配置限制**：设置每条输入的最小和最大预测数量\n- **📈 标签特异性阈值**：根据标签频率自动调整阈值\n- **🔄 增量学习**：无需从头训练即可添加新标签和示例\n\n### 使用方法\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# 初始化并配置\nclassifier = MultiLabelAdaptiveClassifier(\n    \"distilbert\u002Fdistilbert-base-cased\",\n    default_threshold=0.5,\n    min_predictions=1,\n    max_predictions=5\n)\n\n# 多标签训练数据\ntexts = [\n    \"快讯：科学家发现人工智能可帮助预测气候变化模式\",\n    \"科技巨头宣布在医疗健康领域的量子计算取得突破\",\n    \"奥委会采用新型体育技术提升运动员表现\"\n]\n\nlabels = [\n    [\"科学\", \"技术\", \"气候\", \"新闻\"],\n    [\"技术\", \"医疗\", \"量子\", \"商业\"],\n    [\"体育\", \"技术\", \"表现\", \"新闻\"]\n]\n\n# 训练分类器\nclassifier.add_examples(texts, labels)\n\n# 进行预测\npredictions = classifier.predict_multilabel(\n    \"一家科技初创公司推出革命性医疗人工智能系统\"\n)\n\n# 结果：[('技术', 0.85), ('医疗', 0.72), ('商业', 0.45)]\n```\n\n### 自适应阈值\n\n分类器会根据标签数量自动调整预测阈值：\n\n| 标签数量 | 阈值 | 优势 |\n|----------|------|------|\n| 2–4 个标签 | 0.5（默认） | 标准精度 |\n| 5–9 个标签 | 0.4（降低 20%） | 平衡召回率 |\n| 10–19 个标签 | 0.3（降低 40%） | 更好的覆盖范围 |\n| 20–29 个标签 | 0.2（降低 60%） | 防止空结果 |\n| 30 个及以上标签 | 0.1（降低 80%） | 确保有预测结果 |\n\n这解决了在多标签场景中常见的“没有标签达到阈值标准”的问题。\n\n---\n\n## 🏢 企业级应用场景\n\n### 🔍 幻觉检测\n检测大型语言模型生成的信息是否超出给定上下文支持范围（F1 分数 51.54%，召回率 80.68%）：\n\n```python\ndetector = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fllm-hallucination-detector\")\ncontext = \"法国位于西欧。首都：巴黎。人口约 6700 万。\"\nresponse = \"巴黎是首都。人口为 7000 万。\"  # 包含幻觉信息\n\nprediction = detector.predict(f\"上下文：{context}\\n回答：{response}\")\n# 返回：[('HALLUCINATED', 0.72), ('NOT_HALLUCINATED', 0.28)]\n```\n\n### 🚦 智能 LLM 路由\n通过将查询路由到合适的模型层级来优化成本（节省 32.40% 的成本）：\n\n```python\nrouter = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fllm-router\")\nquery = \"编写一个计算斐波那契数列的函数\"\n\npredictions = router.predict(query)\n# 返回：[('HIGH', 0.92), ('LOW', 0.08)]\n# 复杂任务路由至 GPT-4，简单任务路由至 GPT-3.5\n```\n\n### ⚙️ 配置优化\n自动预测不同查询类型的最优 LLM 设置（温度、top_p）：\n\n```python\nconfig_optimizer = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fllm-config-optimizer\")\nquery = \"解释量子物理概念\"\n\npredictions = config_optimizer.predict(query)\n# 返回：[('BALANCED', 0.85), ('CREATIVE', 0.10), ...]\n# 自动建议平衡响应的温度范围：0.6–1.0\n```\n\n### 🛡️ 内容审核\n部署适用于各类审核任务的企业级分类器：\n\n```python\n# 可用的预训练企业级分类器：\nclassifiers = [\n    \"adaptive-classifier\u002Fcontent-moderation\",      # 内容安全\n    \"adaptive-classifier\u002Fbusiness-sentiment\",      # 商务沟通\n    \"adaptive-classifier\u002Fpii-detection\",           # 隐私保护\n    \"adaptive-classifier\u002Ffraud-detection\",         # 金融安全\n    \"adaptive-classifier\u002Femail-priority\",          # 邮件路由\n    \"adaptive-classifier\u002Fcompliance-classification\" # 法规遵从\n]\n\n# 轻松部署\nmoderator = AdaptiveClassifier.from_pretrained(\"adaptive-classifier\u002Fcontent-moderation\")\nresult = moderator.predict(\"用户生成的内容在此...\")\n```\n\n> **💡 小贴士**：所有企业级模型都支持持续自适应——添加您领域的特定示例，以随时间不断提升性能。\n\n---\n\n## 架构概览\n\n自适应分类器将四个关键组件整合到统一的架构中：\n\n![自适应分类器架构](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_6e9ae24cd3a3.png)\n\n1. **Transformer 嵌入**：使用最先进的语言模型进行文本表示\n2. **原型记忆**：维护类别原型，以便快速适应新示例\n3. **自适应神经层**：通过持续训练学习精细化的决策边界\n4. **战略分类**：利用博弈论原理防御对抗性操纵。启用战略模式后，系统会：\n   - 对试图操纵分类器的用户行为建模\n   - 使用代价函数表示操纵不同特征的难度\n   - 将常规预测与战略感知预测相结合，以提高鲁棒性\n   - 提供多种预测模式：双重（混合）、战略（模拟操纵）和稳健（抗操纵）\n\n## 为什么选择自适应分类？\n\n传统分类方法在应对不断变化的需求和对抗性环境时存在显著局限性：\n\n![传统 vs 自适应分类](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_582473f468c9.png)\n\n自适应分类器通过以下方式克服这些局限性：\n- **动态添加类别**，无需完全重新训练\n- **战略鲁棒性**，抵御对抗性操纵\n- **内存高效的原型存储**，结合 FAISS 优化\n- **零停机更新**，适用于生产系统\n- **博弈论防御**机制\n\n## 持续学习流程\n\n系统通过不同的阶段逐步演进，每个阶段都在前一阶段的基础上构建知识，且不会发生灾难性遗忘：\n\n![持续学习工作流](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_readme_69203e7a2d12.png)\n\n学习过程包括：\n- **初始训练**：基于基础类别进行初始化\n- **动态添加**：无缝添加新类别\n- **持续学习**：借助 EWC 保护机制细化决策边界\n- **战略增强**：提升对操纵的鲁棒性\n- **生产部署**：具备完整功能并持续自适应\n\n## 在线学习中的顺序依赖性\n\n在使用自适应分类器进行真正的在线学习（逐步添加示例）时，请注意，示例添加的顺序可能会影响预测结果。这是增量式神经网络训练固有的特性。\n\n### 挑战\n\n```python\n# 这两种场景可能会产生略有不同的模型：\n\n# 场景 1\nclassifier.add_examples([\"鱼的例子\"], [\"水生\"])\nclassifier.add_examples([\"鸟的例子\"], [\"空中\"])\n\n# 场景 2  \nclassifier.add_examples([\"鸟的例子\"], [\"空中\"])\nclassifier.add_examples([\"鱼的例子\"], [\"水生\"])\n```\n\n尽管我们已经实现了排序后的标签 ID 分配以尽量减少这种影响，但神经网络组件仍然会以增量方式学习，这可能导致与顺序相关的行为。\n\n### 解决方案：仅基于原型的预测\n\n对于需要严格顺序无关性的应用，您可以将分类器配置为仅依赖于基于原型的预测：\n\n```python\n# 配置为仅使用原型（顺序无关）\nconfig = {\n    'prototype_weight': 1.0,  # 仅使用原型\n    'neural_weight': 0.0      # 禁用神经网络的贡献\n}\n\nclassifier = AdaptiveClassifier(\"bert-base-uncased\", config=config)\n```\n\n采用此配置后：\n- 预测仅基于与类原型（平均嵌入）的相似性\n- 结果完全与顺序无关\n- 缺点是准确率可能会略低于混合方法\n\n### 最佳实践\n\n1. **追求最大一致性**：使用仅基于原型的配置\n2. **追求最大准确率**：接受默认混合方法带来的一定顺序依赖性\n3. **用于生产系统**：如果需要严格的顺序一致性，可以考虑分批更新并定期重新训练\n4. **模型选择很重要**：某些模型（例如 `google-bert\u002Fbert-large-cased`）可能对单个词生成较差的嵌入。为了在短文本输入上获得更好的效果，建议考虑：\n   - `bert-base-uncased`\n   - `sentence-transformers\u002Fall-MiniLM-L6-v2`\n   - 或任何专门针对语义相似度训练的模型\n\n---\n\n## 🔗 相关项目\n\n- **[OpenEvolve](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fopenevolve)** - 开源进化编码智能体，用于算法发现\n- **[OptiLLM](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Foptillm)** - 使用 20 多种技术优化推理代理，可提升 2–10 倍的准确率\n\n## 🤝 社区与贡献\n\n- **🐛 问题与错误报告**：[GitHub Issues](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues)\n- **💬 讨论**：[GitHub Discussions](https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fdiscussions)\n- **📖 文档**：[API 参考](docs\u002FAPI.md)\n- **🛠️ 贡献**：[CONTRIBUTING.md](CONTRIBUTING.md)\n\n## 📚 参考文献\n\n- [战略分类](https:\u002F\u002Farxiv.org\u002Fabs\u002F1506.06980)\n- [RouteLLM：利用偏好数据学习路由 LLM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.18665)\n- [Transformer^2：自适应 LLM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2501.06252)\n- [Lamini 分类器智能体工具包](https:\u002F\u002Fwww.lamini.ai\u002Fblog\u002Fclassifier-agent-toolkit)\n- [Protoformer：面向 Transformer 的嵌入原型](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.12710)\n- [克服神经网络中的灾难性遗忘](https:\u002F\u002Farxiv.org\u002Fabs\u002F1612.00796)\n- [RAGTruth：用于开发可信检索增强型语言模型的幻觉语料库](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.00396)\n- [LettuceDetect：用于 RAG 应用的幻觉检测框架](https:\u002F\u002Farxiv.org\u002Fabs\u002F2502.17125)\n\n## 📜 引用\n\n如果您在研究中使用本库，请引用以下内容：\n\n```bibtex\n@software{adaptive-classifier,\n  title = {Adaptive Classifier：具有持续学习能力的动态文本分类},\n  author = {Asankhaya Sharma},\n  year = {2025},\n  publisher = {GitHub},\n  url = {https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier}\n}\n```\n\n---\n\n\u003Cdiv align=\"center\">\n  \u003Cp>\u003Cstrong>由 \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fadaptive-classifier\">Adaptive Classifier 团队\u003C\u002Fa> 用心打造 ❤️\u003C\u002Fstrong>\u003C\u002Fp>\n  \u003Cp>\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\">⭐ 在 GitHub 上为我们点赞\u003C\u002Fa> •\n    \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fadaptive-classifier\">🤗 关注 HuggingFace\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>","# Adaptive Classifier 快速上手指南\n\nAdaptive Classifier 是一个基于 PyTorch 的机器学习库，专为文本分类设计。它支持**持续学习**、**动态添加新类别**以及**对抗性输入的防御策略**，并内置 ONNX Runtime 以实现更快的 CPU 推理速度。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux, macOS, 或 Windows\n*   **Python 版本**: 3.8 或更高版本\n*   **前置依赖**: \n    *   `pip` (包管理工具)\n    *   `git` (用于克隆仓库，可选)\n*   **硬件建议**: \n    *   **CPU**: 支持 AVX2 指令集以获得最佳 ONNX 性能\n    *   **GPU**: 可选，若需加速训练或推理，请确保已安装对应的 CUDA 驱动和 PyTorch GPU 版本\n\n> **国内加速提示**: 推荐使用清华或阿里镜像源加速 Python 包下载。\n> ```bash\n> pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple \u003Cpackage_name>\n> ```\n\n## 安装步骤\n\n### 方式一：快速安装（推荐）\n\n通过 pip 直接安装，默认包含 ONNX Runtime 支持，可实现 2-4 倍的 CPU 推理加速。\n\n```bash\npip install adaptive-classifier\n```\n\n**国内用户加速安装命令：**\n```bash\npip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple adaptive-classifier\n```\n\n### 方式二：开发模式安装\n\n如果您需要修改源码或贡献代码，请克隆仓库并进行开发安装：\n\n```bash\n# 克隆仓库\ngit clone https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier.git\ncd adaptive-classifier\n\n# 开发模式安装\npip install -e .\n\n# (可选) 安装测试依赖\npip install pytest pytest-cov pytest-randomly\n```\n\n## 基本使用\n\n只需三步即可在 30 秒内完成自适应分类器的初始化和预测。\n\n### 1. 初始化与训练\n\n导入库，选择任意 HuggingFace 模型进行初始化，并添加训练样本。\n\n```python\nfrom adaptive_classifier import AdaptiveClassifier\n\n# 🎯 步骤 1: 初始化 (支持任意 HuggingFace 模型)\nclassifier = AdaptiveClassifier(\"bert-base-uncased\")\n\n# 📝 步骤 2: 添加训练样本\ntexts = [\"The product works great!\", \"Terrible experience\", \"Neutral about this purchase\"]\nlabels = [\"positive\", \"negative\", \"neutral\"]\nclassifier.add_examples(texts, labels)\n```\n\n### 2. 执行预测\n\n直接对文本进行预测，系统将返回带有置信度的标签列表。\n\n```python\n# 🔮 步骤 3: 进行预测\npredictions = classifier.predict(\"This is amazing!\")\nprint(predictions)  \n# 输出示例: [('positive', 0.85), ('neutral', 0.12), ('negative', 0.03)]\n```\n\n### 3. 多标签分类（可选）\n\n如果需要将文本同时归类到多个类别，可以使用 `MultiLabelAdaptiveClassifier`。\n\n```python\nfrom adaptive_classifier import MultiLabelAdaptiveClassifier\n\n# 初始化多标签分类器\nclassifier = MultiLabelAdaptiveClassifier(\n    \"bert-base-uncased\",\n    min_predictions=1,    # 确保至少返回 1 个标签\n    max_predictions=5     # 限制最多返回 5 个标签\n)\n\n# 添加多标签训练数据\ntexts = [\"AI researchers study climate change using machine learning\"]\nlabels = [[\"technology\", \"science\", \"climate\", \"ai\"]]\n\nclassifier.add_examples(texts, labels)\n\n# 执行多标签预测\npredictions = classifier.predict_multilabel(\"Medical AI breakthrough announced\")\n# 输出示例: [('healthcare', 0.72), ('technology', 0.68), ('ai', 0.45)]\n```\n\n### 4. 模型保存与加载\n\n支持本地保存或直接推送到 HuggingFace Hub。\n\n```python\n# 保存到本地\nclassifier.save(\".\u002Fmy_classifier\")\n\n# 从本地加载\nloaded_classifier = AdaptiveClassifier.load(\".\u002Fmy_classifier\")\n\n# 推送到 HuggingFace Hub\n# classifier.push_to_hub(\"your-username\u002Fmy-model\")\n```\n\n> **注意**: 默认情况下，保存的模型会自动包含量化版和未量化版的 ONNX 模型。在 CPU 上加载时，会自动使用量化版以获得最快推理速度（约 4 倍于原始 PyTorch CPU 速度）。","某大型电商平台的智能客服团队需要实时处理海量用户咨询，并动态识别突发的新型投诉类别（如“新促销活动规则误解”）。\n\n### 没有 adaptive-classifier 时\n- **响应滞后严重**：每当出现新的投诉类型，数据团队必须重新收集数据、全量训练模型并安排停机维护，导致新类别识别延迟数天。\n- **灾难性遗忘**：在引入新类别训练后，模型往往忘记旧有的分类知识，导致原本能准确识别的“物流延误”或“退款申请”准确率大幅下降。\n- **易受恶意攻击**：面对用户刻意构造的对抗性文本（如故意混淆关键词以绕过自动分派），传统分类器极易误判，造成工单流转混乱。\n- **资源消耗巨大**：为了维持高精度，不得不频繁调用昂贵的云端 GPU 进行推理，且无法在 CPU 环境下高效运行。\n\n### 使用 adaptive-classifier 后\n- **零停机动态扩展**：利用其动态类别添加功能，运营人员可在运行时直接注入新类别样本，系统即刻生效，无需重启服务或重新训练。\n- **持续学习不失忆**：借助 EWC 保护机制和原型记忆模块，模型在学习新知识的同时完美保留旧有分类能力，彻底解决灾难性遗忘问题。\n- **战略防御抗干扰**：内置的博弈论防御机制能精准识别并对抗恶意构造的输入，即使在遭受攻击时，分类准确率仍能保持在 82% 以上。\n- **推理成本大幅降低**：通过内置 ONNX Runtime 优化，在普通 CPU 服务器上即可实现 2-4 倍的推理加速，显著降低了算力成本。\n\nadaptive-classifier 让企业的文本分类系统具备了像生物体一样的进化能力，在确保持续适应业务变化的同时，构筑了坚不可摧的安全防线。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcodelion_adaptive-classifier_3dfe2b8f.webp","codelion","Asankhaya Sharma","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fcodelion_e00bb776.jpg","Creator of OptiLLM, OpenEvolve, Adaptive Classifier, and Ellora. Pioneering a new category in AI infrastructure: inference-time compute for LLMs.","CTO @patched-codes","Singapore",null,"asankhaya","patched.codes","https:\u002F\u002Fgithub.com\u002Fcodelion",[25],{"name":26,"color":27,"percentage":28},"Python","#3572A5",100,548,39,"2026-04-19T15:53:01","Apache-2.0",1,"未说明","非必需。支持 CPU（默认使用 ONNX Runtime 加速）和 GPU（自动使用 PyTorch）。未指定具体显卡型号、显存大小或 CUDA 版本要求。",{"notes":37,"python":34,"dependencies":38},"该工具基于 PyTorch 和 HuggingFace Transformers 构建。默认包含 ONNX Runtime，可在 CPU 上实现比纯 PyTorch 快 2-4 倍的推理速度。支持动态添加新类别和持续学习而无需重新训练整个模型。模型保存时默认包含量化（INT8）和非量化两个版本的 ONNX 模型，加载时会自动选择最优版本。",[39,40,41,42,6],"torch","transformers","onnxruntime","faiss",[44,45],"语言模型","开发框架",[47,48,49,50,51,52,53,42,54,55,56,57,58,59,60,61,40,62,63,64],"adaptive-learning","bert","classifier","continous-learning","distilbert","elastic-weight-consolidation","embeddings","large-language-models","llms","multi-class-classification","multi-label-classification","neural-networks","online-learning","roberta","text-classification","machine-learning","neural-layers","adaptive-neural-network",2,"ready","2026-03-27T02:49:30.150509","2026-04-20T12:53:01.585738",[70,75,80,85,90,95],{"id":71,"question_zh":72,"answer_zh":73,"source_url":74},44801,"如何绕过或设置 `trust_remote_code=True` 以加载包含自定义代码的模型？","如果父模型需要信任远程代码，可以在 Docker 环境中设置环境变量，并在 Python 代码中读取该变量。具体步骤如下：\n1. 在 Dockerfile 中添加：\n```dockerfile\nENV TRANSFORMERS_TRUST_REMOTE_CODE=1\n```\n或在 docker-compose.yml 中配置：\n```yaml\nservices:\n  app:\n    environment:\n      - TRANSFORMERS_TRUST_REMOTE_CODE=1\n```\n2. 在 Python 代码中通过环境变量加载模型：\n```python\nimport os\ntrust_remote_code = os.environ['TRANSFORMERS_TRUST_REMOTE_CODE'] \nfrom adaptive_classifier import AdaptiveClassifier\nclassifier = AdaptiveClassifier.from_pretrained(\"ua-l\u002Ftopics-classifier-modern-liberta-large\", trust_remote_code=trust_remote_code)\n```","https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues\u002F60",{"id":76,"question_zh":77,"answer_zh":78,"source_url":79},44802,"为什么添加新标签后，模型在旧数据上的准确率会显著下降？","这通常与类别数量过多有关。对于 BERT 风格的编码器模型，通常在 20-30 个类别内表现最佳。如果类别数量达到 40 个以上（如 41 类），性能可能会受到影响。建议尝试直接对模型进行微调（不使用 adaptive classifier 的增量学习功能）来对比性能，或者减少类别数量进行测试。维护者曾针对此问题发布过修复补丁，请确保升级到最新版本。","https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues\u002F53",{"id":81,"question_zh":82,"answer_zh":83,"source_url":84},44803,"训练数据的输入顺序是否会影响模型的预测结果和偏差？","是的，由于支持在线学习和主动学习，神经网络的学习过程确实存在一定的顺序依赖性。此外，底层模型的选择至关重要。某些模型（如 `google-bert\u002Fbert-large-cased`）可能无法正确映射概念相似度，导致偏差；而 `sentence-transformers\u002Fall-MiniLM-L6-v2` 等模型在此类任务中表现更好。建议在初始化分类器时显式指定更合适的模型：\n```python\nclassifier = AdaptiveClassifier(\"sentence-transformers\u002Fall-MiniLM-L6-v2\")\n```","https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues\u002F45",{"id":86,"question_zh":87,"answer_zh":88,"source_url":89},44804,"加载已保存的分类器后，如何向其中添加包含新类别的训练数据？","加载现有分类器后，可以直接调用 `add_examples` 方法添加新类别的数据。需确保输入格式正确：\n1. `training_texts` 和 `training_labels` 必须是非空列表且长度一致。\n2. 所有文本和标签必须是字符串类型。\n示例代码：\n```python\nclassifier = AdaptiveClassifier.load(\".\u002Ftrained_classifier\")\ntraining_texts = [\"这是示例文本 1\", \"这是示例文本 2\"]\ntraining_labels = [\"new_class\", \"new_class\"]\nclassifier.add_examples(training_texts, training_labels)\n```","https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues\u002F24",{"id":91,"question_zh":92,"answer_zh":93,"source_url":94},44805,"为什么使用较长的训练数据输入时，模型的置信度会发生剧烈反转（从正确变为错误）？","这通常是因为底层预训练模型未能按预期提供语义相似度计算。解决方法是更换为更适合语义相似度任务的模型，例如 `sentence-transformers\u002Fall-MiniLM-L6-v2`。修改初始化代码如下：\n```python\nclassifier = AdaptiveClassifier(\"sentence-transformers\u002Fall-MiniLM-L6-v2\")\n```\n更换模型后，即使输入较长的训练数据，模型也能保持正确的预测方向和合理的置信度。","https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues\u002F46",{"id":96,"question_zh":97,"answer_zh":98,"source_url":99},44806,"为什么加载保存后的模型，其预测置信度会比保存前低？","这种现象可能与模型序列化过程中的状态保留或底层模型的数值精度有关。虽然 Issue 详情被截断，但根据相关问题的解决方案，通常建议检查是否使用了推荐的语义模型（如 `sentence-transformers\u002Fall-MiniLM-L6-v2`），并确保在保存和加载过程中没有丢失关键的归一化参数。如果问题持续，建议升级到最新版本（如 v0.0.15 及以上），因为维护者已在近期版本中修复了多个影响置信度计算的底层问题。","https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fissues\u002F44",[101,106,111,116,121,126,131,136,141,146,151,156,161,166,171,176,181,186,191,196],{"id":102,"version":103,"summary_zh":104,"released_at":105},352688,"v0.1.2","## 变更内容\n* 功能：通过 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F62 中启用了远程信任功能\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.1.1...v0.1.2","2025-10-07T03:12:53",{"id":107,"version":108,"summary_zh":109,"released_at":110},352689,"v0.1.1","## 变更内容\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F61 中更新了 classifier.py\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.1.0...v0.1.1","2025-10-07T01:56:09",{"id":112,"version":113,"summary_zh":114,"released_at":115},352690,"v0.1.0","## 变更内容\n* 功能：@codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F59 中添加了 ONNX 支持\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.19...v0.1.0","2025-10-06T15:21:49",{"id":117,"version":118,"summary_zh":119,"released_at":120},352691,"v0.0.19","## 变更内容\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F58 中修复了 GitHub Actions\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.18...v0.0.19","2025-09-24T07:37:28",{"id":122,"version":123,"summary_zh":124,"released_at":125},352692,"v0.0.18","## 变更内容\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F55 中添加了测试\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F57 中添加了多标签分类器\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.17...v0.0.18","2025-09-24T06:41:54",{"id":127,"version":128,"summary_zh":129,"released_at":130},352693,"v0.0.17","## 变更内容\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F51 中修复了 README 文件\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F52 中更新了 README.md 文件\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F54 中修复了多分类学习问题\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.16...v0.0.17","2025-09-20T12:12:11",{"id":132,"version":133,"summary_zh":134,"released_at":135},352694,"v0.0.16","## 变更内容\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F48 中更新了 README.md\n* 由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F50 中修复了 EWC 最后一个批次训练的 bug\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.15...v0.0.16","2025-08-09T15:51:29",{"id":137,"version":138,"summary_zh":139,"released_at":140},352695,"v0.0.15","## 变更内容\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F39 中更新了 README，添加了架构图和工作流图\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F40 中更新了文档\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F41 中更新了 README.md\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F42 中更新了文档\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F43 中更新了文档\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F47 中实现了按类别跟踪并持久化训练历史的功能\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.14...v0.0.15","2025-07-24T06:32:13",{"id":142,"version":143,"summary_zh":144,"released_at":145},352696,"v0.0.14","## 变更内容\n* @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F38 中实现了战略分类器的初始版本\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.13...v0.0.14","2025-06-20T07:26:39",{"id":147,"version":148,"summary_zh":149,"released_at":150},352697,"v0.0.13","## 变更内容\n* 在保存时使用 num_representative_examples 配置，由 @MischaU8 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F36 中实现\n* 更新 setup.py 文件，由 @codelion 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F37 中完成\n\n## 新贡献者\n* @MischaU8 在 https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F36 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.12...v0.0.13","2025-06-08T15:09:31",{"id":152,"version":153,"summary_zh":154,"released_at":155},352698,"v0.0.12","## What's Changed\r\n* Fix load local by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F32\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.11...v0.0.12","2025-05-07T03:43:01",{"id":157,"version":158,"summary_zh":159,"released_at":160},352699,"v0.0.11","## What's Changed\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F30\r\n* Fix hf integration by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F31\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.10...v0.0.11","2025-05-07T03:30:22",{"id":162,"version":163,"summary_zh":164,"released_at":165},352700,"v0.0.10","## What's Changed\r\n* Feat hallucination detector by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F28\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.9...v0.0.10","2025-03-07T11:38:52",{"id":167,"version":168,"summary_zh":169,"released_at":170},352701,"v0.0.9","## What's Changed\r\n* Update setup.py by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F26\r\n* Update setup.py by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F27\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.8...v0.0.9","2025-02-27T03:08:45",{"id":172,"version":173,"summary_zh":174,"released_at":175},352702,"v0.0.8","## What's Changed\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F23\r\n* Update setup.py by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F25\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.7...v0.0.8","2025-02-27T02:57:25",{"id":177,"version":178,"summary_zh":179,"released_at":180},352703,"v0.0.7","## What's Changed\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F18\r\n* Feat add llm config optimizer by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F19\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.6...v0.0.7","2025-02-03T11:23:36",{"id":182,"version":183,"summary_zh":184,"released_at":185},352704,"v0.0.6","## What's Changed\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F13\r\n* Fix model card by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F14\r\n* Update setup.py by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F15\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.5...v0.0.6","2025-01-21T07:41:55",{"id":187,"version":188,"summary_zh":189,"released_at":190},352705,"v0.0.5","## What's Changed\r\n* Feat add hf hub integration by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F12\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.4...v0.0.5","2025-01-21T07:07:10",{"id":192,"version":193,"summary_zh":194,"released_at":195},352706,"v0.0.4","## What's Changed\r\n* Create API.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F3\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F4\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F5\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F6\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F7\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F8\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F9\r\n* Update README.md by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F10\r\n* Fix dim issue in training by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F11\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.3...v0.0.4","2025-01-21T02:50:55",{"id":197,"version":198,"summary_zh":199,"released_at":200},352707,"v0.0.3","## What's Changed\r\n* Update publish.yml by @codelion in https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fpull\u002F2\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fcodelion\u002Fadaptive-classifier\u002Fcompare\u002Fv0.0.2...v0.0.3","2025-01-13T05:15:51",[202,214,223,231,239,247],{"id":203,"name":204,"github_repo":205,"description_zh":206,"stars":207,"difficulty_score":208,"last_commit_at":209,"category_tags":210,"status":66},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[211,45,212,213],"Agent","图像","数据工具",{"id":215,"name":216,"github_repo":217,"description_zh":218,"stars":219,"difficulty_score":65,"last_commit_at":220,"category_tags":221,"status":66},9989,"n8n","n8n-io\u002Fn8n","n8n 是一款面向技术团队的公平代码（fair-code）工作流自动化平台，旨在让用户在享受低代码快速构建便利的同时，保留编写自定义代码的灵活性。它主要解决了传统自动化工具要么过于封闭难以扩展、要么完全依赖手写代码效率低下的痛点，帮助用户轻松连接 400 多种应用与服务，实现复杂业务流程的自动化。\n\nn8n 特别适合开发者、工程师以及具备一定技术背景的业务人员使用。其核心亮点在于“按需编码”：既可以通过直观的可视化界面拖拽节点搭建流程，也能随时插入 JavaScript 或 Python 代码、调用 npm 包来处理复杂逻辑。此外，n8n 原生集成了基于 LangChain 的 AI 能力，支持用户利用自有数据和模型构建智能体工作流。在部署方面，n8n 提供极高的自由度，支持完全自托管以保障数据隐私和控制权，也提供云端服务选项。凭借活跃的社区生态和数百个现成模板，n8n 让构建强大且可控的自动化系统变得简单高效。",184740,"2026-04-19T23:22:26",[213,45,211,212,222],"插件",{"id":224,"name":225,"github_repo":226,"description_zh":227,"stars":228,"difficulty_score":208,"last_commit_at":229,"category_tags":230,"status":66},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[45,212,211],{"id":232,"name":233,"github_repo":234,"description_zh":235,"stars":236,"difficulty_score":65,"last_commit_at":237,"category_tags":238,"status":66},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",161147,"2026-04-19T23:31:47",[45,211,44],{"id":240,"name":241,"github_repo":242,"description_zh":243,"stars":244,"difficulty_score":65,"last_commit_at":245,"category_tags":246,"status":66},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[45,212,211],{"id":248,"name":249,"github_repo":250,"description_zh":251,"stars":252,"difficulty_score":253,"last_commit_at":254,"category_tags":255,"status":66},10072,"DeepSeek-V3","deepseek-ai\u002FDeepSeek-V3","DeepSeek-V3 是一款由深度求索推出的开源混合专家（MoE）大语言模型，旨在以极高的效率提供媲美顶尖闭源模型的智能服务。它拥有 6710 亿总参数，但在处理每个 token 时仅激活 370 亿参数，这种设计巧妙解决了大规模模型推理成本高、速度慢的难题，让高性能 AI 更易于部署和应用。\n\n这款模型特别适合开发者、研究人员以及需要构建复杂 AI 应用的企业团队使用。无论是进行代码生成、逻辑推理还是多轮对话开发，DeepSeek-V3 都能提供强大的支持。其独特之处在于采用了无辅助损失的负载均衡策略和多令牌预测训练目标，前者在提升计算效率的同时避免了性能损耗，后者则显著增强了模型表现并加速了推理过程。此外，模型在 14.8 万亿高质量令牌上完成预训练，且整个训练过程异常稳定，未出现不可恢复的损失尖峰。凭借仅需 278.8 万 H800 GPU 小时即可完成训练的高效特性，DeepSeek-V3 为开源社区树立了一个兼顾性能与成本效益的新标杆。",102693,5,"2026-04-20T03:58:04",[44]]