Skip to content

Commit

Permalink
src: increase MaxContextSize and MaxBatchSize
Browse files Browse the repository at this point in the history
This also restores the original prompt for the map step and
reduce step.

Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information
danbev committed Dec 4, 2023
1 parent 1b8297e commit ebe5e75
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions crates/llm-chain-llama/examples/map_reduce_llama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use llm_chain::{prompt, step::Step, Parameters};
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let opts = options!(
ModelType: "llama",
MaxContextSize: 2048_usize,
MaxContextSize: 4096_usize,
NThreads: 4_usize,
MaxTokens: 2048_usize,
MaxBatchSize: 4096_usize,
TopK: 40_i32,
TopP: 0.95,
TfsZ: 1.0,
Expand All @@ -26,20 +27,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
StopSequence: vec!["\n\n".to_string()]
);
let exec = executor!(llama, opts.clone())?;
let map_prompt = Step::for_prompt_template(prompt!(
"You are a bot for summarizing wikipedia articles, you are terse and focus on accuracy",
"Summarize this article into bullet points:\n{{text}}"
));
//let map_prompt = Step::for_prompt_template(prompt!("== ARTICLE ==\n{{text}}== SUMMARY ==\n"));
//let reduce_prompt =
// Step::for_prompt_template(prompt!("== ARTICLE ==\n{{text}}== FINAL SUMMARY ==\n"));

// Create the "reduce" step to combine multiple summaries into one
let reduce_prompt = Step::for_prompt_template(prompt!(
"You are a diligent bot that summarizes text",
"Please combine the articles below into one summary as bullet points:\n{{text}}"
));

let map_prompt = Step::for_prompt_template(prompt!("== ARTICLE ==\n{{text}}== SUMMARY ==\n"));
let reduce_prompt =
Step::for_prompt_template(prompt!("== ARTICLE ==\n{{text}}== FINAL SUMMARY ==\n"));
let chain = Chain::new(map_prompt, reduce_prompt);
let article = include_str!("article_to_summarize.md");
let docs = vec![Parameters::new_with_text(article)];
Expand Down

0 comments on commit ebe5e75

Please sign in to comment.