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.

ResettableLLamaModel.cs 1.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using LLama.Abstractions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace LLama
  6. {
  7. /// <summary>
  8. /// A LLamaModel what could be reset. Note that using this class will consume about 10% more memories.
  9. /// </summary>
  10. public class ResettableLLamaModel : LLamaModel
  11. {
  12. /// <summary>
  13. /// The initial state of the model
  14. /// </summary>
  15. public State OriginalState { get; set; }
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. /// <param name="Params"></param>
  20. /// <param name="encoding"></param>
  21. public ResettableLLamaModel(IModelParams Params, string encoding = "UTF-8") : base(Params, encoding)
  22. {
  23. OriginalState = GetState();
  24. }
  25. /// <summary>
  26. /// Reset the state to the initial state.
  27. /// </summary>
  28. public void Reset()
  29. {
  30. LoadState(OriginalState);
  31. }
  32. /// <inheritdoc />
  33. public override void Dispose()
  34. {
  35. OriginalState.Dispose();
  36. base.Dispose();
  37. }
  38. }
  39. }