You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

BatchedExecutorFork.md 3.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # BatchedExecutor Fork - Generate Multiple Completions With Shared Memory
  2. This example demonstrates using the `BatchedExecutor` to split one sequence into multiple sequences. See the source code [here](https://github.com/SciSharp/LLamaSharp/blob/master/LLama.Examples/Examples/BatchedExecutorFork.cs).
  3. Sequences share memory up to the point they were split, meaning no extra memory is consumed by creating a fork. Inference runs for all sequences simultaneously, this means that running two sequences does _not_ take twice as much time as running one.
  4. An example output, starting with the prompt `Not many people know that`:
  5. ```
  6. Not many people know that
  7. └── , in the 17th century, a military band led by Captain Charles
  8. ├── Bossler of Baden, Germany, composed and played a music suite titled
  9. │ ├── the "Civil Psalm," in order to rally German Protestants during
  10. │ │ ├── the Thirty Years' War. This tune became popular among German soldiers,
  11. │ │ │ ├── and its popularity continued long after the war
  12. │ │ │ └── and, eventually, reached France. The
  13. │ │ └── the Thirty Years' War.This music, with its clear call
  14. │ │ ├── to arms and strong Christian themes, helped
  15. │ │ └── to arms and unwavering belief
  16. │ └── "Baden's First National Symphony," with lyrics by a young Wol
  17. │ ├── fgang Amadeus Mozart. The story of the composition's creation
  18. │ │ ├── has long been forgotten. But the B
  19. │ │ └── was popularized by a novelty book
  20. │ └── fgang Amadeus Mozart. It's said that this music brought
  21. │ ├── peace to Europe, at least for a
  22. │ └── the troops together during difficult times. It
  23. └── Newdick played a mournful dirge to accompany the procession of
  24. ├── the head of King Charles I. It is the scene that opens my latest book
  25. │ ├── , "Death and Taxes." The book follows a British army captain named
  26. │ │ ├── Marcus as he seeks revenge for his wife
  27. │ │ └── William Darnay who becomes involved in
  28. │ └── , A King, A Pawn and a Prince. The murder of the king
  29. │ ├── and the civil war that followed are the
  30. │ └── is a watershed moment in the political
  31. └── the coffin of William Shakespeare, as it was carried to its final resting place
  32. ├── . That is the least that can be said for a man who is often regarded
  33. │ ├── as the greatest writer in the English language
  34. │ └── as the greatest writer the English language has
  35. └── at Stratford-upon-Avon. Shakespeare, of course
  36. ├── , was a famous English poet and play
  37. └── , was one of the greatest playwright
  38. ```
  39. Forked sequences can be used for many possible things. For example
  40. - Evaluating the system prompt once and forking for each independent conversation.
  41. - Saving a "checkpoint" in a conversation to return to later.
  42. - Beam Search.
  43. - Splitting a conversation, generating completions from several different "agents", and taking the best response.