# 丁戈服务器
## 基本信息
- Slug: `dataeval-dingo`
- Source: modelscope
- Publisher: @DataEval/dingo
- Categories: databases / data-platforms
- Hosted: No
- License: Apache License 2.0
- Source URL: https://www.modelscope.cn/mcp/servers/@DataEval/dingo
## 简介
丁戈 MCP 服务器
## MCP Server 详情

<div align="center" xmlns="http://www.w3.org/1999/html">
<!-- logo -->
<p align="center">
  <img src="docs/assets/dingo-logo.png" width="300px" style="vertical-align:middle;">
</p>

<!-- badges -->
<p align="center">
  <a href="https://github.com/pre-commit/pre-commit"><img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white" alt="pre-commit"></a>
  <a href="https://pypi.org/project/dingo-python/"><img src="https://img.shields.io/pypi/v/dingo-python.svg" alt="PyPI version"></a>
  <a href="https://pypi.org/project/dingo-python/"><img src="https://img.shields.io/pypi/pyversions/dingo-python.svg" alt="Python versions"></a>
  <a href="https://github.com/DataEval/dingo/blob/main/LICENSE"><img src="https://img.shields.io/github/license/DataEval/dingo" alt="License"></a>
  <a href="https://github.com/DataEval/dingo/stargazers"><img src="https://img.shields.io/github/stars/DataEval/dingo" alt="GitHub stars"></a>
  <a href="https://github.com/DataEval/dingo/network/members"><img src="https://img.shields.io/github/forks/DataEval/dingo" alt="GitHub forks"></a>
  <a href="https://github.com/DataEval/dingo/issues"><img src="https://img.shields.io/github/issues/DataEval/dingo" alt="GitHub issues"></a>
</p>

</div>


<div align="center">

[English](README.md) · [简体中文](README_zh-CN.md)

</div>


<div align="center">
  <a href="https://discord.gg/Jhgb2eKWh8" style="text-decoration:none;">
    <img src="https://user-images.githubusercontent.com/25839884/218347213-c080267f-cbb6-443e-8532-8e1ed9a58ea9.png" width="3%" alt="Discord" /></a>
  <a href="https://huggingface.co/spaces/DataEval/dingo" style="text-decoration:none;">
    <img src="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png" width="3%" alt="Hugging Face" /></a>
</div>


# 更新日志

- 2024/12/27: 项目初始化

# 简介

Dingo 是一个数据质量评估工具，可以帮助您自动检测数据集中的数据质量问题。Dingo 提供了多种内置规则和模型评估方法，并且支持自定义评估方法。Dingo 支持常用的文本数据集和多模态数据集，包括预训练数据集、微调数据集和评估数据集。此外，Dingo 支持多种使用方式，包括本地 CLI 和 SDK，使其易于集成到各种评估平台中，例如 [OpenCompass](https://github.com/open-compass/opencompass)。

## 架构图

![Dingo 架构](./docs/assets/architeture.png)

# 快速开始

## 安装

shell
pip install dingo-python


## 示例用例

### 1. 使用评估核心

python
from dingo.config.config import DynamicLLMConfig
from dingo.io.input.MetaData import MetaData
from dingo.model.llm.llm_text_quality_model_base import LLMTextQualityModelBase
from dingo.model.rule.rule_common import RuleEnterAndSpace


def llm():
    data = MetaData(
        data_id=123,
        prompt="hello, introduce the world",
        content="Hello! The world is a vast and diverse place, full of wonders, cultures, and incredible natural beauty."
    )

    LLMTextQualityModelBase.dynamic_config = DynamicLLMConfig(
        key= ,
        api_url= ,
        # model= ,
    )
    res = LLMTextQualityModelBase.eval(data)
    print(res)


def rule():
    data = MetaData(
        data_id=123,
        prompt="hello, introduce the world",
        content="Hello! The world is a vast and diverse place, full of wonders, cultures, and incredible natural beauty."
    )

    res = RuleEnterAndSpace().eval(data)
    print(res)


### 2. 评估本地文本文件（纯文本）

python
from dingo.io import InputArgs
from dingo.exec import Executor

# 评估一个纯文本文件
input_data = {
    "eval_group": "sft",          # SFT 数据的规则集
    "input_path": "data.txt",      # 本地文本文件路径
    "dataset": "local",
    "data_format": "plaintext",    # 格式：纯文本
    "save_data": True              # 保存评估结果
}

input_args = InputArgs(**input_data)
executor = Executor.exec_map["local"](input_args)
result = executor.execute()
print(result)### 3. 评估 Hugging Face 数据集

python
from dingo.io import InputArgs
from dingo.exec import Executor

# 评估来自 Hugging Face 的数据集
input_data = {
    "eval_group": "sft",           # 用于 SFT 数据的规则集
    "input_path": "tatsu-lab/alpaca", # 来自 Hugging Face 的数据集
    "data_format": "plaintext",    # 格式：纯文本
    "save_data": True              # 保存评估结果
}

input_args = InputArgs(**input_data)
executor = Executor.exec_map["local"](input_args)
result = executor.execute()
print(result)


### 4. 评估 JSON/JSONL 格式

python
from dingo.io import InputArgs
from dingo.exec import Executor

# 评估一个 JSON 文件
input_data = {
    "eval_group": "default",       # 默认规则集
    "input_path": "data.json",     # 本地 JSON 文件路径
    "dataset": "local",
    "data_format": "json",         # 格式：json
    "column_content": "text",      # 包含要评估文本的列
    "save_data": True              # 保存评估结果
}

input_args = InputArgs(**input_data)
executor = Executor.exec_map["local"](input_args)
result = executor.execute()
print(result)


### 5. 使用大模型进行评估

python
from dingo.io import InputArgs
from dingo.exec import Executor

# 使用 GPT 模型进行评估
input_data = {
    "input_path": "data.jsonl",    # 本地 JSONL 文件路径
    "dataset": "local",
    "data_format": "jsonl",
    "column_content": "content",
    "custom_config": {
        "prompt_list": ["PromptRepeat"],  # 使用的提示
        "llm_config": {
            "detect_text_quality": {
                "model": "gpt-4o",
                "key": "YOUR_API_KEY",
                "api_url": "https://api.openai.com/v1/chat/completions"
            }
        }
    }
}

input_args = InputArgs(**input_data)
executor = Executor.exec_map["local"](input_args)
result = executor.execute()
print(result)


## 命令行接口

### 使用规则集进行评估

shell
python -m dingo.run.cli --input_path data.txt --dataset local -e sft --data_format plaintext --save_data True


### 使用大模型（例如 GPT-4o）进行评估

shell
python -m dingo.run.cli --input_path data.json --dataset local -e openai --data_format json --column_content text --custom_config config_gpt.json --save_data True


示例 `config_gpt.json`:
json
{
  "llm_config": {
    "openai": {
      "model": "gpt-4o",
      "key": "YOUR_API_KEY",
      "api_url": "https://api.openai.com/v1/chat/completions"
    }
  }
}


## GUI 可视化

在评估后（使用 `save_data=True`），将自动生成一个前端页面。手动启动前端：

shell
python -m dingo.run.vsl --input output_directory


其中 `output_directory` 包含带有 `summary.json` 文件的评估结果。

![GUI …

