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 954 B

1234567891011121314151617181920212223242526272829303132333435
  1. using LLama.Common;
  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 byte[] OriginalState { get; set; }
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. /// <param name="Params"></param>
  20. /// <param name="encoding"></param>
  21. public ResettableLLamaModel(ModelParams Params, string encoding = "UTF-8") : base(Params, encoding)
  22. {
  23. OriginalState = GetStateData();
  24. }
  25. /// <summary>
  26. /// Reset the state to the initial state.
  27. /// </summary>
  28. public void Reset()
  29. {
  30. LoadState(OriginalState);
  31. }
  32. }
  33. }

C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。