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.

README.md 1.7 kB

2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. # LLamaSharp.SemanticKernel
  2. LLamaSharp.SemanticKernel are connections for [SemanticKernel](https://github.com/microsoft/semantic-kernel): an SDK for intergrating various LLM interfaces into a single implementation. With this, you can add local LLaMa queries as another connection point with your existing connections.
  3. For reference on how to implement it, view the following examples:
  4. - [SemanticKernelChat](../LLama.Examples/NewVersion/SemanticKernelChat.cs)
  5. - [SemanticKernelPrompt](../LLama.Examples/NewVersion/SemanticKernelPrompt.cs)
  6. - [SemanticKernelMemory](../LLama.Examples/NewVersion/SemanticKernelMemory.cs)
  7. ## ITextCompletion
  8. ```csharp
  9. using var model = LLamaWeights.LoadFromFile(parameters);
  10. // LLamaSharpTextCompletion can accept ILLamaExecutor.
  11. var ex = new StatelessExecutor(model, parameters);
  12. var builder = new KernelBuilder();
  13. builder.WithAIService<ITextCompletion>("local-llama", new LLamaSharpTextCompletion(ex), true);
  14. ```
  15. ## IChatCompletion
  16. ```csharp
  17. using var model = LLamaWeights.LoadFromFile(parameters);
  18. using var context = model.CreateContext(parameters);
  19. // LLamaSharpChatCompletion requires InteractiveExecutor, as it's the best fit for the given command.
  20. var ex = new InteractiveExecutor(context);
  21. var chatGPT = new LLamaSharpChatCompletion(ex);
  22. ```
  23. ## ITextEmbeddingGeneration
  24. ```csharp
  25. using var model = LLamaWeights.LoadFromFile(parameters);
  26. var embedding = new LLamaEmbedder(model, parameters);
  27. var kernelWithCustomDb = Kernel.Builder
  28. .WithLoggerFactory(ConsoleLogger.LoggerFactory)
  29. .WithAIService<ITextEmbeddingGeneration>("local-llama-embed", new LLamaSharpEmbeddingGeneration(embedding), true)
  30. .WithMemoryStorage(new VolatileMemoryStore())
  31. .Build();
  32. ```