This repository was archived by the owner on Jun 24, 2024. It is now read-only.
File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ pub struct Args {
67
67
/// --cache-prompt
68
68
#[ arg( long, default_value = None ) ]
69
69
pub restore_prompt : Option < String > ,
70
+
71
+ /// Specifies the seed to use during sampling. Note that, depending on
72
+ /// hardware, the same seed may lead to different results on two separate
73
+ /// machines.
74
+ #[ arg( long, default_value = None ) ]
75
+ pub seed : Option < u64 > ,
70
76
}
71
77
72
78
/// CLI args are stored in a lazy static variable so they're accessible from
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::{convert::Infallible, io::Write};
2
2
3
3
use cli_args:: CLI_ARGS ;
4
4
use llama_rs:: { InferenceParameters , InferenceSnapshot } ;
5
- use rand:: thread_rng ;
5
+ use rand:: SeedableRng ;
6
6
7
7
mod cli_args;
8
8
@@ -94,7 +94,11 @@ fn main() {
94
94
95
95
log:: info!( "Model fully loaded!" ) ;
96
96
97
- let mut rng = thread_rng ( ) ;
97
+ let mut rng = if let Some ( seed) = CLI_ARGS . seed {
98
+ rand:: rngs:: StdRng :: seed_from_u64 ( seed)
99
+ } else {
100
+ rand:: rngs:: StdRng :: from_entropy ( )
101
+ } ;
98
102
99
103
let mut session = if let Some ( restore_path) = & args. restore_prompt {
100
104
let snapshot = InferenceSnapshot :: load_from_disk ( restore_path) ;
You can’t perform that action at this time.
0 commit comments