#converter #jsonl #rwkv #json #format #convert #binidx

app json2bin

一个快速的 Rust 语言 Jsonl 到 RWKV binidx 转换器

6 个版本

0.2.0 2024 年 8 月 10 日
0.1.4 2024 年 8 月 4 日
0.1.3 2024 年 7 月 14 日

#69机器学习

Download history 98/week @ 2024-07-05 158/week @ 2024-07-12 19/week @ 2024-07-19 22/week @ 2024-07-26 128/week @ 2024-08-02 123/week @ 2024-08-09

每月 297 次下载

Apache-2.0

165KB
237 代码行

Json2bin

Crates.io Version Crates.io Downloads License: Apache 2.0

一个快速的多线程 Jsonl 转换器,用于将 RWKV binidx 文件写入 Rust。

安装

$ cargo install json2bin

使用

$ json2bin -h
Json converter to RWKV binidx file format
Usage: json2bin [OPTIONS] --input <INPUT>

Options:
  -i, --input <INPUT>            Jsonlines file to read
  -o, --output-dir <OUTPUT_DIR>  Output directory for binidx files [default: -]
  -t, --thread <THREAD>          Number of threads [default: 8]
  -v, --verbose                  Verbosity
  -h, --help                     Print help
  -V, --version                  Print version

以下命令将 src/sample.jsonl 文件转换为 src/sample.bin 和 src/sample.idx 文件。

$ json2bin -i src/sample.jsonl

输出目录可以使用参数 "--output-dir <OUTPUT_DIR>" 或 "-o <OUTPUT_DIR>" 设置。

$ json2bin -i src/sample.jsonl -o output

默认线程数是 8,可以使用参数 "--thread" 或 "-t" 进行更改。

$ json2bin -i src/sample.jsonl -t 4

性能比较

我们在 M2 Apple 机器上将 19GB 的英文维基百科(20231101.en)jsonl 格式转换为 binidx 格式。Rust json2bin 以 7 个线程运行,比 Python json2binidx 快 70 倍。

  • Python json2binidx:1:01:45 或 5.13MB/s
  • 这个 Rust json2bin:52.64s 或 360.86MB/s

依赖项

~7–19MB
~184K SLoC