mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 18:48:51 +00:00
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:
@ -44,6 +44,10 @@ struct Args {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
decode: bool,
|
decode: bool,
|
||||||
|
|
||||||
|
// Enable/disable decoding.
|
||||||
|
#[arg(long, default_value = "false")]
|
||||||
|
use_cache: bool,
|
||||||
|
|
||||||
/// Use this prompt, otherwise compute sentence similarities.
|
/// Use this prompt, otherwise compute sentence similarities.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
prompt: Option<String>,
|
prompt: Option<String>,
|
||||||
@ -111,7 +115,8 @@ impl T5ModelBuilder {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
let config = std::fs::read_to_string(config_filename)?;
|
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)?;
|
let tokenizer = Tokenizer::from_file(tokenizer_filename).map_err(E::msg)?;
|
||||||
Ok((
|
Ok((
|
||||||
Self {
|
Self {
|
||||||
|
Reference in New Issue
Block a user