ray_document_deduplicator¶
Deduplicates samples at the document level using exact matching in Ray distributed mode.
This operator computes a hash for each document and filters out duplicates based on exact matches. The hash is calculated from the text content, which can be optionally converted to lowercase and stripped of non-alphabet characters. The key metric used for deduplication is the MD5 hash of the processed text. If the lowercase
parameter is set, the text is converted to lowercase before hashing. If ignore_non_character
is enabled, all non-alphabet characters, including whitespaces, digits, and punctuation, are removed. The operator supports two backends: ‘ray_actor’ and ‘redis’, with the default being ‘ray_actor’.
在 Ray 分布式模式下,使用精确匹配在文档级别去重样本。
该算子为每个文档计算一个哈希值,并基于精确匹配过滤掉重复项。哈希值是从文本内容计算得出的,可以选择将文本转换为小写并去除非字母字符。用于去重的关键指标是处理后的文本的 MD5 哈希值。如果设置了 lowercase
参数,则在哈希之前将文本转换为小写。如果启用了 ignore_non_character
,则会移除所有非字母字符,包括空格、数字和标点符号。该算子支持两种后端:’ray_actor’ 和 ‘redis’,默认为 ‘ray_actor’。
Type 算子类型: deduplicator
Tags 标签: cpu, text
🔧 Parameter Configuration 参数配置¶
name 参数名 |
type 类型 |
default 默认值 |
desc 说明 |
---|---|---|---|
|
<class ‘str’> |
|
the backend for dedup, either ‘ray_actor’ or ‘redis’ |
|
<class ‘str’> |
|
the address of redis server |
|
<class ‘bool’> |
|
Whether to convert sample text to lower case |
|
<class ‘bool’> |
|
Whether to ignore non-alphabet |
|
|
extra args |
|
|
|
extra args. |
📊 Effect demonstration 效果演示¶
test_english_deduplication¶
RayDocumentDeduplicator(lowercase=False, ignore_non_character=False)
📥 input data 输入数据¶
Today is Sunday and it's a happy day!
Do you need a cup of coffee?
Today is sunday and it's a happy day!
This paper proposed a novel method on LLM pretraining.
This paper proposed a novel method on LLM pretraining.
📤 output data 输出数据¶
Today is Sunday and it's a happy day!
Do you need a cup of coffee?
Today is sunday and it's a happy day!
This paper proposed a novel method on LLM pretraining.
✨ explanation 解释¶
The operator removes exact duplicates based on the text content of each document. Since ‘This paper proposed a novel method on LLM pretraining.’ appears twice, one is removed. The case and non-alphabet characters are considered, so ‘Today is Sunday…’ and ‘Today is sunday…’ are treated as different documents. 算子基于每个文档的文本内容移除完全相同的重复项。由于’This paper proposed a novel method on LLM pretraining.’出现了两次,因此移除了其中一个。大小写和非字母字符被考虑在内,所以’Today is Sunday…’ 和 ‘Today is sunday…’被视为不同的文档。
test_chinese_deduplication¶
RayDocumentDeduplicator(lowercase=False, ignore_non_character=False)
📥 input data 输入数据¶
你好,请问你是谁
欢迎来到阿里巴巴!
第九届会议 2003年7月28日至8月8日 牙买加金斯敦 为来自发展中国家的法律和技术委员会以及财务委员会成员 参加委员会会议支付费用的方式 1.
第九届会议 2003年7月28日至8月8日 牙买加金斯敦 为来自发展中国家的法律和技术委员会以及财务委员会成员 参加委员会会议支付费用的方式 1.
第九届会议 时间:2003年7月28日至8月8日 牙买加金斯敦 为来自发展中国家的法律和技术委员会以及财务委员会成员 参加委员会会议支付费用的方式 1.
📤 output data 输出数据¶
你好,请问你是谁
欢迎来到阿里巴巴!
第九届会议 2003年7月28日至8月8日 牙买加金斯敦 为来自发展中国家的法律和技术委员会以及财务委员会成员 参加委员会会议支付费用的方式 1.
第九届会议 时间:2003年7月28日至8月8日 牙买加金斯敦 为来自发展中国家的法律和技术委员会以及财务委员会成员 参加委员会会议支付费用的方式 1.
✨ explanation 解释¶
The operator removes exact duplicates based on the text content of each document. Since the third and fourth documents in the input list have exactly the same text, one of them is removed. The fifth document, although similar, has a slight difference (‘时间:’ added), and thus is kept. 算子基于每个文档的文本内容移除完全相同的重复项。由于输入列表中的第三和第四个文档具有完全相同的文本,因此移除了其中一个。第五个文档虽然相似,但有一个细微的不同(添加了’时间:’),因此被保留。