Language quality evaluation tool.
Project description
English | 简体中文
Introduction
Dingo is a data quality assessment tool that helps you automatically detect data quality issues in your datasets. Dingo provides a variety of built-in detection rules and model methods, and also supports custom detection methods. It supports commonly used NLP datasets and multimodal datasets, including pre-training datasets, fine-tuning datasets, and evaluation datasets. In addition, Dingo supports various interface usage methods, including local CLI, SDK, and RESTFul API, making it easy to integrate into various environments. The large model evaluation platform of OpenCompass has integrated Dingo for subjective evaluation of language model generated content.
Architecture of Dingo
QuickStart
Install dingo
.
pip install dingo
Try the following demo code.
from dingo.model import Model
from dingo.io import RawInputModel
from dingo.exec import Executor
input_data = {
"eval_models": ["default"],
"input_path": "data/inputs/test_data1.json", # replace with your data path here
"data_type": "json",
"column_content": ["prediction"],
}
raw_input = RawInputModel(**input_data)
Model.apply_config(raw_input.custom_config_path)
executor = Executor.exec_map["local"](raw_input)
result = executor.evaluate()
print(result)
Tutorials
Config
Dingo
enables users to personalize their data quality inspection methods, which can include the use of heuristic rules,
third-party quality inspection tools or services, and large models. These can be implemented through configuration.
Specifically, users can pass a parameter named custom_config_path
which points to a configuration file.
Below is a template for this configuration file: template.json
Rules
Heuristic rules are a common method for data processing and quality inspection. Dingo
has implemented a series of
heuristic rules and grouped them into rule groups, such as zh-all
, and en-all
, which represent the heuristic quality
inspection rule sets for Chinese and English respectively. In the template of the configuration file, the two configuration
items related to heuristic rule configuration are custom_rule_list
and rule_config
, which represent the rule set
and the configuration parameters for a specific rule, respectively. Below is a configuration example:
{
"custom_rule_list": [],
"rule_config": {}
}
Large Models
Dingo
supports data quality inspection using large models. Before use, users need to configure llm_config
.
For OpenAI
models:
{
"key": "YOUR_API_KEY"
}
For HuggingFace models(currently support the downloaded models):
{
"path": "your local model path",
}
Execute
Dingo
can be run locally or on a Spark cluster.
Local Mode
In addition to the aforementioned SDK calls, you can also run data evaluation locally with CLI
:
python -m dingo.run.cli
The CLI parameters are as follows.
parameter name | description |
---|---|
-i or --input_path |
The path of data. It can be a file or a directory. |
-e or --eval_models |
The model used to evaluate data quality. |
--dataset_id |
The id of data input. |
--data_type |
The type of data. It can be JSON, jsonl, plaintext and list json. |
--output_path |
The path of result data. |
--column_id |
The column name of id in data. |
--column_prompt |
The column name of prompt in data. |
--column_content |
The column name of content in data. |
custom_config_path |
The path of custom config file. |
More information can be obtained by running the following command: python -m dingo.run.cli --help
.
Spark Mode
If the scale of data is very large you can use Spark to run the project.
Firstly, create an object from SparkExecutor
, and set the actual instances of SparkSession and DataFrame.
from dingo.exec.spark import SparkExecutor
spark_exec = SparkExecutor()
spark_exec.set_spark(spark_session)
spark_exec.set_input_df(spark_data_frame)
Then, convert the data and execute the rule list.
spark_exec.convert_data(column_id=['data_id'], column_prompt=['prompt'], column_content=['content'])
spark_exec.execute(["CommonSpecialCharacter", "CommonColonEnd"])
Finally, summarize and get the result data.
spark_exec.summarize()
output_df = spark_exec.get_output_df()
summary = spark_exec.get_summary()
Evaluation Results
Summary
The summary.json
file is overall information about evaluation results. Here is an example:
{
"dataset_id": "20240618",
"input_model": "default",
"input_path": "data/inputs/test_data1.json",
"output_path": "data/outputs/20240625_134409",
"score": 90.0,
"num_good": 90,
"num_bad": 10,
"total": 100,
"error_ratio": {...}
}
The error_ratio
field shows data quality signals in seven different aspects:
EFFECTIVENESS
, COMPLETENESS
, UNDERSTANDABILITY
, SIMILARITY
, FLUENCY
, RELEVANCE
and SECURITY
.
Detailed Results
For more detailed issues found in data items, Dingo
created files in a directory named with the quality signals mentioned above.
Give an example. CommonColonEnd.json
in the QUALITY_SIGNAL_COMPLETENESS
directory is as follows:
{
"name": "CommonColonEnd", # rule name
"count": 1,
"ratio": 0.5,
"detail": [
{
"data_id": "0",
"prompt": "",
"content": "I am 8 years old. ^I love apple because:",
"error_reason": "Ends with a colon."
}
]
}
We evaluated the quality of these three datasets based on Dingo
.
Dataset | Dataset Type | EFFECTIVENESS | COMPLETENESS | UNDERSTANDABILITY | SIMILARITY | FLUENCY | RELEVANCE | SECURITY |
---|---|---|---|---|---|---|---|---|
SlimPajama-627B | Pretrain | 0 | 0.001797 | 0.011547 | 0.003563 | 0 | 0 | 0 |
Stanford_alpaca | SFT | 0.0008 | 0.0004 | 0.0013 | 0.0002 | 0 | 0 | 0 |
MMLU | Benchmark | 0.0064 | 0.0005 | 0.0113 | 0 | 0 | 0 | 0 |
Contributing
We appreciate all contributions to Dingo
. Please refer to CONTRIBUTING.md for the contributing guideline.
License
This project is released under the Apache 2.0 license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file dingo_python-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: dingo_python-1.0.1-py3-none-any.whl
- Upload date:
- Size: 48.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3df6c561d212b20cd232e018527944dadf7cf4d0ff7aa413e6e486b512cf1cbc |
|
MD5 | 56e310a97d4956d48c7fb083e0483596 |
|
BLAKE2b-256 | 9bb4981d8023a00c1173c1fd1d010607b5c048bff00b42ad450b2dd721b1139b |