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
This commit is contained in:
SignalRT 2023-08-30 22:08:29 +02:00
parent 516c291e3f
commit fb007e5921
8 changed files with 2068 additions and 14 deletions

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);
}

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";
}
}

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>

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);
}
}
}

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);
}
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

BIN
LLama/runtimes/libllama.dylib Normal file → Executable file

Binary file not shown.