Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/metrics-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Metrics Documentation Auto-Update

on:
push:
branches: [ main, dev ]
paths:
- 'dingo/model/prompt/**'
- 'scripts/generate_metrics.py'
pull_request:
branches: [ main ]
paths:
- 'dingo/model/prompt/**'
- 'scripts/generate_metrics.py'
workflow_dispatch:

jobs:
update-metrics-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .

- name: Generate metrics documentation
run: |
python scripts/generate_metrics.py

- name: Check if documentation changed
id: check_changes
run: |
if git diff --quiet docs/metrics.md; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Commit updated documentation
if: steps.check_changes.outputs.changed == 'true' && github.event_name == 'push'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add docs/metrics.md
git commit -m "📚 Auto-update metrics documentation"
git push
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: 'docs/metrics\.md'
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
hooks:
- id: isort
args: [ "-l", "200", "-m", "0", "-p", "dingo" ]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
Expand Down
75 changes: 10 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,61 +179,19 @@ This video demonstrates step-by-step how to use Dingo MCP server with Cursor.

# Data Quality Metrics

Dingo classifies data quality issues into 7 dimensions of Quality Metrics. Each dimension can be evaluated using both rule-based methods and LLM-based prompts:
Dingo provides comprehensive data quality assessment through both rule-based and prompt-based evaluation metrics. These metrics cover multiple quality dimensions including effectiveness, completeness, similarity, security, and more.

| Quality Metric | Description | Rule Examples | LLM Prompt Examples |
|-------------------|-------------|---------------|---------------------|
| **COMPLETENESS** | Checks if data is incomplete or missing | `RuleColonEnd`, `RuleContentNull` | Evaluates if text abruptly ends with a colon or ellipsis, has mismatched parentheses, or missing critical components |
| **EFFECTIVENESS** | Checks if data is meaningful and properly formatted | `RuleAbnormalChar`, `RuleHtmlEntity`, `RuleSpecialCharacter` | Detects garbled text, words stuck together without spaces, and text lacking proper punctuation |
| **FLUENCY** | Checks if text is grammatically correct and reads naturally | `RuleAbnormalNumber`, `RuleNoPunc`, `RuleWordStuck` | Identifies excessively long words, text fragments without punctuation, or content with chaotic reading order |
| **RELEVANCE** | Detects irrelevant content within the data | `RuleHeadWord` variants for different languages | Examines for irrelevant information like citation details, headers/footers, entity markers, HTML tags |
| **SECURITY** | Identifies sensitive information or value conflicts | `RuleIDCard`, `RuleUnsafeWords` | Checks for personal information, and content related to gambling, pornography, political issues |
| **SIMILARITY** | Detects repetitive or highly similar content | `RuleDocRepeat` | Evaluates text for consecutive repeated content or multiple occurrences of special characters |
| **UNDERSTANDABILITY** | Assesses how easily data can be interpreted | `RuleCapitalWords` | Ensures LaTeX formulas and Markdown are correctly formatted, with proper segmentation and line breaks |
📊 **[View Complete Metrics Documentation →](docs/metrics.md)**

## LLM Quality Assessment
Our evaluation system includes:
- **Text Quality Assessment Metrics**: Pre-training data quality evaluation using DataMan methodology and enhanced multi-dimensional assessment
- **SFT Data Assessment Metrics**: Honest, Helpful, Harmless evaluation for supervised fine-tuning data
- **Classification Metrics**: Topic categorization and content classification
- **Multimodality Assessment Metrics**: Image classification and relevance evaluation
- **Rule-Based Quality Metrics**: Automated quality checks using heuristic rules for effectiveness and similarity detection
- etc

Dingo provides several LLM-based assessment methods defined by prompts in the `dingo/model/prompt` directory. These prompts are registered using the `prompt_register` decorator and can be combined with LLM models for quality evaluation:

### Text Quality Assessment Prompts

| Prompt Type | Metric | Description |
|-------------|--------|-------------|
| `TEXT_QUALITY_V2`, `TEXT_QUALITY_V3` | Various quality dimensions | Comprehensive text quality evaluation covering effectiveness, relevance, completeness, understandability, similarity, fluency, and security |
| `QUALITY_BAD_EFFECTIVENESS` | Effectiveness | Detects garbled text and anti-crawling content |
| `QUALITY_BAD_SIMILARITY` | Similarity | Identifies text repetition issues |
| `WORD_STICK` | Fluency | Checks for words stuck together without proper spacing |
| `CODE_LIST_ISSUE` | Completeness | Evaluates code blocks and list formatting issues |
| `UNREAD_ISSUE` | Effectiveness | Detects unreadable characters due to encoding issues |

### 3H Assessment Prompts (Honest, Helpful, Harmless)

| Prompt Type | Metric | Description |
|-------------|--------|-------------|
| `QUALITY_HONEST` | Honesty | Evaluates if responses provide accurate information without fabrication or deception |
| `QUALITY_HELPFUL` | Helpfulness | Assesses if responses address questions directly and follow instructions appropriately |
| `QUALITY_HARMLESS` | Harmlessness | Checks if responses avoid harmful content, discriminatory language, and dangerous assistance |

### Domain-Specific Assessment Prompts

| Prompt Type | Metric | Description |
|-------------|--------|-------------|
| `TEXT_QUALITY_KAOTI` | Exam question quality | Specialized assessment for evaluating the quality of exam questions, focusing on formula rendering, table formatting, paragraph structure, and answer formatting |
| `Html_Abstract` | HTML extraction quality | Compares different methods of extracting Markdown from HTML, evaluating completeness, formatting accuracy, and semantic coherence |
| `DATAMAN_ASSESSMENT` | Data Quality & Domain | Evaluates pre-training data quality using the DataMan methodology (14 standards, 15 domains). Assigns a score (0/1), domain type, quality status, and reason. |

### Classification Prompts

| Prompt Type | Metric | Description |
|-------------|--------|-------------|
| `CLASSIFY_TOPIC` | Topic Categorization | Classifies text into categories like language processing, writing, code, mathematics, role-play, or knowledge Q&A |
| `CLASSIFY_QR` | Image Classification | Identifies images as CAPTCHA, QR code, or normal images |

### Image Assessment Prompts

| Prompt Type | Metric | Description |
|-------------|--------|-------------|
| `IMAGE_RELEVANCE` | Image Relevance | Evaluates if an image matches reference image in terms of face count, feature details, and visual elements |
Most metrics are backed by academic sources to ensure objectivity and scientific rigor.

### Using LLM Assessment in Evaluation

Expand Down Expand Up @@ -417,19 +375,6 @@ Example summary:
}
```


# Research & Publications

## Research Powered by Dingo
- **WanJuanSiLu**: [A High-Quality Open-Source Webtext Dataset for Low-Resource Languages](https://arxiv.org/pdf/2501.14506)
*Uses Dingo for comprehensive data quality assessment of multilingual web data*

## Methodologies Implemented in Dingo
- **DataMan Methodology**: [DataMan: Data Manager for Pre-training Large Language Models](https://openreview.net/pdf?id=eNbA8Fqir4)
*Dingo implements the DataMan methodology for pre-training data quality assessment*
- **RedPajama-Data-v2**: [RedPajama-Data](https://github.com/togethercomputer/RedPajama-Data)
*Dingo implements parts of the RedPajama-Data-v2 methodology for web text quality assessment and filtering*

# Future Plans

- [ ] Richer graphic and text evaluation indicators
Expand Down
85 changes: 16 additions & 69 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,61 +177,19 @@ https://github.com/user-attachments/assets/aca26f4c-3f2e-445e-9ef9-9331c4d7a37b

# データ品質メトリクス

Dingoはデータ品質問題を7つの品質メトリクス次元に分類します。各次元は、ルールベース手法とLLMベースプロンプトの両方で評価できます:
Dingoはルールベースおよびプロンプトベースの評価メトリクスを通じて包括的なデータ品質評価を提供します。これらのメトリクスは、効果性、完全性、類似性、セキュリティなどの複数の品質次元をカバーしています。

| 品質メトリクス | 説明 | ルール例 | LLMプロンプト例 |
|----------------|------|----------|-----------------|
| **COMPLETENESS** | データが不完全または欠落していないかをチェック | `RuleColonEnd`, `RuleContentNull` | テキストがコロンや省略記号で突然終わっているか、括弧が不一致か、重要な要素が欠落していないかを評価 |
| **EFFECTIVENESS** | データが意味があり適切にフォーマットされているかをチェック | `RuleAbnormalChar`, `RuleHtmlEntity`, `RuleSpecialCharacter` | 文字化けテキスト、スペースなしで結合された単語、適切な句読点のないテキストを検出 |
| **FLUENCY** | テキストが文法的に正しく自然に読めるかをチェック | `RuleAbnormalNumber`, `RuleNoPunc`, `RuleWordStuck` | 過度に長い単語、句読点のないテキスト断片、読み順が混乱したコンテンツを識別 |
| **RELEVANCE** | データ内の無関係なコンテンツを検出 | 異なる言語用の`RuleHeadWord`バリアント | 引用詳細、ヘッダー/フッター、エンティティマーカー、HTMLタグなどの無関係な情報を検査 |
| **SECURITY** | 機密情報や価値観の対立を識別 | `RuleIDCard`, `RuleUnsafeWords` | 個人情報、ギャンブル、ポルノ、政治問題に関連するコンテンツをチェック |
| **SIMILARITY** | 反復的または非常に類似したコンテンツを検出 | `RuleDocRepeat` | 連続した反復コンテンツや特殊文字の複数出現についてテキストを評価 |
| **UNDERSTANDABILITY** | データがどれだけ容易に解釈できるかを評価 | `RuleCapitalWords` | LaTeX数式とMarkdownが正しくフォーマットされ、適切なセグメンテーションと改行があることを確認 |
📊 **[完全なメトリクス文書を表示 →](docs/metrics.md)**

## LLM品質評価
評価システムには以下が含まれます:
- **テキスト品質評価メトリクス**: DataMan手法と拡張された多次元評価を使用した事前学習データの品質評価
- **SFTデータ評価メトリクス**: 教師ありファインチューニングデータの正直、有用、無害評価
- **分類メトリクス**: トピック分類とコンテンツ分類
- **マルチモーダル評価メトリクス**: 画像分類と関連性評価
- **ルールベース品質メトリクス**: ヒューリスティックルールによる効果性と類似性検出を用いた自動品質チェック
- など

Dingoは`dingo/model/prompt`ディレクトリ内のプロンプトで定義された複数のLLMベース評価手法を提供します。これらのプロンプトは`prompt_register`デコレータを使用して登録され、品質評価のためにLLMモデルと組み合わせることができます:

### テキスト品質評価プロンプト

| プロンプトタイプ | メトリクス | 説明 |
|------------------|------------|------|
| `TEXT_QUALITY_V2`, `TEXT_QUALITY_V3` | 様々な品質次元 | 効果性、関連性、完全性、理解しやすさ、類似性、流暢性、セキュリティを含む包括的なテキスト品質評価 |
| `QUALITY_BAD_EFFECTIVENESS` | 効果性 | 文字化けテキストとアンチクローリングコンテンツを検出 |
| `QUALITY_BAD_SIMILARITY` | 類似性 | テキスト反復問題を識別 |
| `WORD_STICK` | 流暢性 | 適切なスペースなしで結合された単語をチェック |
| `CODE_LIST_ISSUE` | 完全性 | コードブロックとリストフォーマット問題を評価 |
| `UNREAD_ISSUE` | 効果性 | エンコーディング問題による読み取り不可能な文字を検出 |

### 3H評価プロンプト(正直、有用、無害)

| プロンプトタイプ | メトリクス | 説明 |
|------------------|------------|------|
| `QUALITY_HONEST` | 正直性 | 捏造や欺瞞なしに正確な情報を提供するかどうかを評価 |
| `QUALITY_HELPFUL` | 有用性 | 質問に直接答え、指示に適切に従うかどうかを評価 |
| `QUALITY_HARMLESS` | 無害性 | 有害なコンテンツ、差別的言語、危険な支援を避けるかどうかをチェック |

### ドメイン固有評価プロンプト

| プロンプトタイプ | メトリクス | 説明 |
|------------------|------------|------|
| `TEXT_QUALITY_KAOTI` | 試験問題品質 | 数式レンダリング、表フォーマット、段落構造、回答フォーマットに焦点を当てた試験問題品質の専門評価 |
| `Html_Abstract` | HTML抽出品質 | HTMLからMarkdownを抽出する異なる手法を比較し、完全性、フォーマット精度、意味的一貫性を評価 |
| `DATAMAN_ASSESSMENT` | データ品質とドメイン | DataMan手法(14基準、15ドメイン)を使用して事前学習データ品質を評価。スコア(0/1)、ドメインタイプ、品質状態、理由を割り当て |

### 分類プロンプト

| プロンプトタイプ | メトリクス | 説明 |
|------------------|------------|------|
| `CLASSIFY_TOPIC` | トピック分類 | 言語処理、執筆、コード、数学、ロールプレイ、知識Q&Aなどのカテゴリにテキストを分類 |
| `CLASSIFY_QR` | 画像分類 | 画像をCAPTCHA、QRコード、または通常の画像として識別 |

### 画像評価プロンプト

| プロンプトタイプ | メトリクス | 説明 |
|------------------|------------|------|
| `IMAGE_RELEVANCE` | 画像関連性 | 顔の数、特徴の詳細、視覚的要素の観点から、画像が参照画像と一致するかを評価 |
大部分のメトリクスは学術的なソースによって支持されており、客観性と科学的厳密性を保証しています。

### 評価でのLLM評価の使用

Expand Down Expand Up @@ -284,10 +242,12 @@ input_data = {

## ルールベース・モデルベース評価

- **組み込みルール**: 20以上の一般的なヒューリスティック評価ルール
- **LLM統合**: OpenAI、Kimi、ローカルモデル(例:Llama3)
- **カスタムルール**: 独自のルールとモデルで簡単に拡張
- **セキュリティ評価**: Perspective API統合
評価システムには以下が含まれます:
- **テキスト品質評価メトリクス**: DataMan手法と拡張された多次元評価を使用した事前学習データの品質評価
- **SFTデータ評価メトリクス**: 教師ありファインチューニングデータの正直、有用、無害評価
- **分類メトリクス**: トピック分類とコンテンツ分類
- **マルチモーダル評価メトリクス**: 画像分類と関連性評価
- **ルールベース品質メトリクス**: ヒューリスティックルールによる効果性と類似性検出を用いた自動品質チェック

## 柔軟な使用方法

Expand Down Expand Up @@ -415,19 +375,6 @@ result = executor.execute()
}
```


# 研究・出版物

## Dingoを活用した研究
- **WanJuanSiLu**: [A High-Quality Open-Source Webtext Dataset for Low-Resource Languages](https://arxiv.org/pdf/2501.14506)
*多言語ウェブデータの包括的なデータ品質評価にDingoを使用*

## Dingoに実装された手法
- **DataMan手法**: [DataMan: Data Manager for Pre-training Large Language Models](https://openreview.net/pdf?id=eNbA8Fqir4)
*Dingoは事前学習データ品質評価のためのDataMan手法を実装*
- **RedPajama-Data-v2**: [RedPajama-Data](https://github.com/togethercomputer/RedPajama-Data)
*Dingoはウェブテキストの品質評価とフィルタリングのためのRedPajama-Data-v2手法の一部を実装*

# 今後の計画

- [ ] より豊富なグラフィックとテキスト評価指標
Expand Down
Loading