feat: add sampling param CLI flags to populate_knowledge binary
Adds --temperature, --top-p, --top-k, --min-p flags so batch runs can tune the same sampling params now supported by the API endpoints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,22 @@ struct Args {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
num_ctx: Option<i32>,
|
num_ctx: Option<i32>,
|
||||||
|
|
||||||
|
/// Sampling temperature (e.g. 0.8). Omit for model default
|
||||||
|
#[arg(long)]
|
||||||
|
temperature: Option<f32>,
|
||||||
|
|
||||||
|
/// Top-p (nucleus) sampling (e.g. 0.9). Omit for model default
|
||||||
|
#[arg(long)]
|
||||||
|
top_p: Option<f32>,
|
||||||
|
|
||||||
|
/// Top-k sampling (e.g. 40). Omit for model default
|
||||||
|
#[arg(long)]
|
||||||
|
top_k: Option<i32>,
|
||||||
|
|
||||||
|
/// Min-p sampling (e.g. 0.05). Omit for model default
|
||||||
|
#[arg(long)]
|
||||||
|
min_p: Option<f32>,
|
||||||
|
|
||||||
/// Re-process files that already have an insight stored
|
/// Re-process files that already have an insight stored
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
reprocess: bool,
|
reprocess: bool,
|
||||||
@@ -78,6 +94,13 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
if let Some(ctx) = args.num_ctx {
|
if let Some(ctx) = args.num_ctx {
|
||||||
ollama.set_num_ctx(Some(ctx));
|
ollama.set_num_ctx(Some(ctx));
|
||||||
}
|
}
|
||||||
|
if args.temperature.is_some()
|
||||||
|
|| args.top_p.is_some()
|
||||||
|
|| args.top_k.is_some()
|
||||||
|
|| args.min_p.is_some()
|
||||||
|
{
|
||||||
|
ollama.set_sampling_params(args.temperature, args.top_p, args.top_k, args.min_p);
|
||||||
|
}
|
||||||
|
|
||||||
let sms_api_url =
|
let sms_api_url =
|
||||||
std::env::var("SMS_API_URL").unwrap_or_else(|_| "http://localhost:8000".to_string());
|
std::env::var("SMS_API_URL").unwrap_or_else(|_| "http://localhost:8000".to_string());
|
||||||
@@ -125,6 +148,18 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
if let Some(ctx) = args.num_ctx {
|
if let Some(ctx) = args.num_ctx {
|
||||||
println!("Num ctx: {}", ctx);
|
println!("Num ctx: {}", ctx);
|
||||||
}
|
}
|
||||||
|
if let Some(t) = args.temperature {
|
||||||
|
println!("Temperature: {}", t);
|
||||||
|
}
|
||||||
|
if let Some(p) = args.top_p {
|
||||||
|
println!("Top P: {}", p);
|
||||||
|
}
|
||||||
|
if let Some(k) = args.top_k {
|
||||||
|
println!("Top K: {}", k);
|
||||||
|
}
|
||||||
|
if let Some(m) = args.min_p {
|
||||||
|
println!("Min P: {}", m);
|
||||||
|
}
|
||||||
println!(
|
println!(
|
||||||
"Mode: {}",
|
"Mode: {}",
|
||||||
if args.reprocess {
|
if args.reprocess {
|
||||||
@@ -202,10 +237,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
args.model.clone(),
|
args.model.clone(),
|
||||||
None,
|
None,
|
||||||
args.num_ctx,
|
args.num_ctx,
|
||||||
None,
|
args.temperature,
|
||||||
None,
|
args.top_p,
|
||||||
None,
|
args.top_k,
|
||||||
None,
|
args.min_p,
|
||||||
args.max_iterations,
|
args.max_iterations,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user