一个清洗 jsonl 文件的小脚本
工作中有清洗 jsonl 文件的需求,原因是 LLM 输出的内容有可能存在错误的补全,不能直接全部用于 Fine-tuning。这个脚本清洗了 jsonl 文件中 input/output == "" 和 input 行重复 的情况。import json
import random
input_file = 'file.jsonl'
output_file = 'file_cleaned.jsonl'
# 用于存储唯一 input 的行
input_map = {}
total_lines = 0 ...