T5: Add option to override use_cache from config (#892)

* Add option to override use_cache from config

* Disable cache by default and cleanup code
This commit is contained in:
Juarez Bochi
2023-09-18 12:20:21 -07:00
committed by GitHub
parent 82a98f6da0
commit 1542e92629

View File

@ -44,6 +44,10 @@ struct Args {
#[arg(long)]
decode: bool,
// Enable/disable decoding.
#[arg(long, default_value = "false")]
use_cache: bool,
/// Use this prompt, otherwise compute sentence similarities.
#[arg(long)]
prompt: Option<String>,
@ -111,7 +115,8 @@ impl T5ModelBuilder {
)
};
let config = std::fs::read_to_string(config_filename)?;
let config: t5::Config = serde_json::from_str(&config)?;
let mut config: t5::Config = serde_json::from_str(&config)?;
config.use_cache = args.use_cache;
let tokenizer = Tokenizer::from_file(tokenizer_filename).map_err(E::msg)?;
Ok((
Self {