Browse Source

Changes to compile in VS Mac + change model to llama2

This commit includes changes to compile en VS Mac + changest to use llama2 not codellama.

It includes MacOS binaries in memory and metal
tags/v0.5.1
SignalRT 2 years ago
parent
commit
fb007e5921
8 changed files with 2068 additions and 14 deletions
  1. +1
    -1
      LLama.Unittest/BasicTest.cs
  2. +1
    -1
      LLama.Unittest/Constants.cs
  3. +2
    -2
      LLama.Unittest/LLama.Unittest.csproj
  4. +1
    -1
      LLama.Unittest/LLamaContextTests.cs
  5. +14
    -9
      LLama.Unittest/ModelsParamsTests.cs
  6. +2049
    -0
      LLama/runtimes/ggml-metal.metal
  7. BIN
      LLama/runtimes/libllama-metal.dylib
  8. BIN
      LLama/runtimes/libllama.dylib

+ 1
- 1
LLama.Unittest/BasicTest.cs View File

@@ -25,7 +25,7 @@ namespace LLama.Unittest
[Fact]
public void BasicModelProperties()
{
Assert.Equal(32016, _model.VocabCount);
Assert.Equal(32000, _model.VocabCount);
Assert.Equal(2048, _model.ContextSize);
Assert.Equal(4096, _model.EmbeddingSize);
}


+ 1
- 1
LLama.Unittest/Constants.cs View File

@@ -2,6 +2,6 @@
{
internal static class Constants
{
public static string ModelPath = "Models/codellama-7b.Q3_K_S.gguf";
public static string ModelPath = "Models/llama-2-7b.q4_0.gguf";
}
}

+ 2
- 2
LLama.Unittest/LLama.Unittest.csproj View File

@@ -24,7 +24,7 @@
</ItemGroup>

<Target Name="DownloadContentFiles" BeforeTargets="Build">
<DownloadFile SourceUrl="https://huggingface.co/TheBloke/CodeLlama-7B-GGUF/resolve/main/codellama-7b.Q3_K_S.gguf" DestinationFolder="Models" DestinationFileName="codellama-7b.Q3_K_S.gguf" SkipUnchangedFiles="true">
<DownloadFile SourceUrl="https://huggingface.co/narrative-bi/Llama-2-7B-GGUF/resolve/main/llama-2-7b.q4_0.gguf" DestinationFolder="Models" DestinationFileName="llama-2-7b.q4_0.gguf" SkipUnchangedFiles="true">
</DownloadFile>
</Target>

@@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup>
<None Update="Models\codellama-7b.Q3_K_S.gguf">
<None Update="Models\llama-2-7b.q4_0.gguf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


+ 1
- 1
LLama.Unittest/LLamaContextTests.cs View File

@@ -29,7 +29,7 @@ namespace LLama.Unittest
{
Assert.Equal(768, _context.ContextSize);
Assert.Equal(4096, _context.EmbeddingSize);
Assert.Equal(32016, _context.VocabCount);
Assert.Equal(32000, _context.VocabCount);
}
}
}

+ 14
- 9
LLama.Unittest/ModelsParamsTests.cs View File

@@ -45,21 +45,26 @@ namespace LLama.Unittest
Assert.Equal(expected, actual);
}

private class NewtsonsoftEncodingConverter
: Newtonsoft.Json.JsonConverter<Encoding>


public class NewtsonsoftEncodingConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, Encoding? value, JsonSerializer serializer)
public override bool CanConvert(Type objectType)
{
writer.WriteValue((string?)value?.WebName);
return typeof(Encoding).IsAssignableFrom(objectType);
}

public override Encoding? ReadJson(JsonReader reader, Type objectType, Encoding? existingValue, bool hasExistingValue, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var name = (string?)reader.Value;
if (name == null)
return null;
return Encoding.GetEncoding(name);
writer.WriteValue(((Encoding)value).WebName);
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return Encoding.GetEncoding((string)reader.Value);
}
}


}
}

+ 2049
- 0
LLama/runtimes/ggml-metal.metal
File diff suppressed because it is too large
View File


BIN
LLama/runtimes/libllama-metal.dylib View File


BIN
LLama/runtimes/libllama.dylib View File


Loading…
Cancel
Save