1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// lib.rs
//
// Copyright (c) 2023-2025 Junpei Kawamoto
//
// This software is released under the MIT License.
//
// http://opensource.org/licenses/mit-license.php
//! This crate provides Rust bindings for [OpenNMT/CTranslate2](https://github.com/OpenNMT/CTranslate2).
//!
//! This crate provides the following:
//!
//! * Rust bindings for
//! [ctranslate2::Translator](https://opennmt.net/CTranslate2/python/ctranslate2.Translator.html),
//! [ctranslate2::Generator](https://opennmt.net/CTranslate2/python/ctranslate2.Generator.html),
//! and
//! [ctranslate2::Whisper](https://opennmt.net/CTranslate2/python/ctranslate2.models.Whisper.html)
//! provided by CTranslate2, specifically [`sys::Translator`], [`sys::Generator`], and
//! [`sys::Whisper`].
//! * More user-friendly versions of these, [`Translator`], [`Generator`],
//! and [`Whisper`] (`whisper` feature is required),
//! which incorporate tokenizers for easier handling.
//!
//! # Basic Usage
//! The following example translates two strings using default settings and outputs each to
//! the standard output.
//!
//! ```no_run
//! # use anyhow::Result;
//! #
//! use ct2rs::{Config, Translator, TranslationOptions};
//!
//! # fn main() -> Result<()> {
//! let sources = vec![
//! "Hallo World!",
//! "This crate provides Rust bindings for CTranslate2."
//! ];
//! let translator = Translator::new("/path/to/model", &Default::default())?;
//! let results = translator.translate_batch(&sources, &Default::default(), None)?;
//! for (r, _) in results{
//! println!("{}", r);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Supported Models
//! The `ct2rs` crate has been tested and confirmed to work with the following models:
//!
//! - BART
//! - BLOOM
//! - FALCON
//! - Marian-MT
//! - MPT
//! - NLLB
//! - GPT-2
//! - GPT-J
//! - OPT
//! - T5
//! - Whisper
//!
//! Please see the respective
//! [examples](https://github.com/jkawamoto/ctranslate2-rs/tree/main/examples) for each model.
//!
//! # Stream API
//! This crate also offers a streaming API that utilizes callback closures.
//! Please refer to
//! [the example code](https://github.com/jkawamoto/ctranslate2-rs/blob/main/examples/stream.rs)
//! for more information.
//!
//!
extern crate intel_onemkl_prebuild;
extern crate openblas_src;
extern crate onednn_src;
pub use ;
pub use download_model;
pub use GenerationStepResult;
pub use ;
pub use Tokenizer;
pub use ;
pub use ;