Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving README.md and making it developer-friendly #2

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
minbpe
# `minbpe-rs`

Port of Andrej Karpathy's [minbpe](https://github.com/karpathy/minbpe) to Rust.
> Port of Andrej Karpathy's [minbpe](https://github.com/karpathy/minbpe) to Rust.

[![minbpe-rs crate](https://img.shields.io/crates/v/minbpe.svg)](https://crates.io/crates/minbpe)
[![minbpe-rs documentation](https://docs.rs/minbpe/badge.svg)](https://docs.rs/minbpe)


## Quick Start

Create a Rust application crate with `cargo`,

```
$> cargo new minbpe-test
```

In the resulting project, add `minbpe` to `Cargo.toml`,

```toml
[dependencies]
minbpe = "0.1.0"
```

Refer [`crates.io`](https://crates.io/crates/minbpe) for selecting the latest version. Next in `src/main.rs`,

```rust
use std::path::Path;
use minbpe::{BasicTokenizer, Saveable, Tokenizer, Trainable};

fn main() {
let text = "aaabdaaabac" ;
let mut tokenizer = BasicTokenizer::new() ;
tokenizer.train( text , 256 + 3 , false ) ;
println!( "{:?}" , tokenizer.encode(text) ) ;
println!( "{:?}" , tokenizer.decode( &[258, 100, 258, 97, 99] ) ) ;
tokenizer.save( Path::new( "./" ) , "toy" ) ;
}
```

Execute the binary with `cargo run`,

```
$> cargo run

...
Compiling minbpe-test v0.1.0 (~/minbpe-test)
Finished dev [unoptimized + debuginfo] target(s) in 15.71s
Running `target/debug/minbpe-test`
[258, 100, 258, 97, 99]
"aaabdaaabac"

```