Skip to content

Commit

Permalink
Merge pull request #48 from milbk/main
Browse files Browse the repository at this point in the history
 Add ModelInfo
  • Loading branch information
awaescher authored Jun 25, 2024
2 parents ff516a5 + 9d5950c commit 5219e40
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/Models/ShowModel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OllamaSharp.Models;
Expand Down Expand Up @@ -52,4 +53,28 @@ public class ShowModelResponse
/// </summary>
[JsonPropertyName("details")]
public Details Details { get; set; } = null!;

/// <summary>
/// Extra information about the model
/// </summary>
[JsonPropertyName("model_info")]
public ModelInfo Info { get; set; } = null!;
}

public class ModelInfo
{
[JsonPropertyName("general.architecture")]
public string? Architecture { get; set; }

[JsonPropertyName("general.file_type")]
public int? FileType { get; set; }

[JsonPropertyName("general.parameter_count")]
public long? ParameterCount { get; set; }

[JsonPropertyName("general.quantization_version")]
public int? QuantizationVersion { get; set; }

[JsonExtensionData]
public IDictionary<string, object>? ExtraInfo { get; set; }
}
6 changes: 5 additions & 1 deletion test/OllamaApiClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public async Task Returns_Deserialized_Model_WithSystem()
_response = new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent("{\"modelfile\":\"# Modelfile generated by \\\"ollama show\\\"\\n# To build a new Modelfile based on this, replace FROM with:\\n# FROM magicoder:latest\\n\\nFROM C:\\\\Users\\\\jd\\\\.ollama\\\\models\\\\blobs\\\\sha256-4a501ed4ce55e5611922b3ee422501ff7cc773b472d196c3c416859b6d375273\\nTEMPLATE \\\"{{ .System }}\\n\\n@@ Instruction\\n{{ .Prompt }}\\n\\n@@ Response\\n\\\"\\nSYSTEM You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.\\nPARAMETER num_ctx 16384\\n\",\"parameters\":\"num_ctx 16384\",\"template\":\"{{ .System }}\\n\\n@@ Instruction\\n{{ .Prompt }}\\n\\n@@ Response\\n\",\"system\":\"You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.\",\"details\":{\"parent_model\":\"\",\"format\":\"gguf\",\"family\":\"llama\",\"families\":null,\"parameter_size\":\"7B\",\"quantization_level\":\"Q4_0\"}}")
Content = new StringContent("{\"modelfile\":\"# Modelfile generated by \\\"ollama show\\\"\\n# To build a new Modelfile based on this, replace FROM with:\\n# FROM magicoder:latest\\n\\nFROM C:\\\\Users\\\\jd\\\\.ollama\\\\models\\\\blobs\\\\sha256-4a501ed4ce55e5611922b3ee422501ff7cc773b472d196c3c416859b6d375273\\nTEMPLATE \\\"{{ .System }}\\n\\n@@ Instruction\\n{{ .Prompt }}\\n\\n@@ Response\\n\\\"\\nSYSTEM You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.\\nPARAMETER num_ctx 16384\\n\",\"parameters\":\"num_ctx 16384\",\"template\":\"{{ .System }}\\n\\n@@ Instruction\\n{{ .Prompt }}\\n\\n@@ Response\\n\",\"system\":\"You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.\",\"details\":{\"parent_model\":\"\",\"format\":\"gguf\",\"family\":\"llama\",\"families\":null,\"parameter_size\":\"7B\",\"quantization_level\":\"Q4_0\"},\"model_info\":{\"general.architecture\":\"llama\",\"general.file_type\":2,\"general.parameter_count\":8829407232,\"general.quantization_version\":2,\"llama.attention.head_count\":32,\"llama.attention.head_count_kv\":4,\"llama.attention.layer_norm_rms_epsilon\":0.000001,\"llama.block_count\":48,\"llama.context_length\":4096,\"llama.embedding_length\":4096,\"llama.feed_forward_length\":11008,\"llama.rope.dimension_count\":128,\"llama.rope.freq_base\":5000000,\"llama.vocab_size\":64000,\"tokenizer.ggml.add_bos_token\":false,\"tokenizer.ggml.add_eos_token\":false,\"tokenizer.ggml.bos_token_id\":1,\"tokenizer.ggml.eos_token_id\":2,\"tokenizer.ggml.model\":\"llama\",\"tokenizer.ggml.padding_token_id\":0,\"tokenizer.ggml.pre\":\"default\",\"tokenizer.ggml.scores\":[],\"tokenizer.ggml.token_type\":[],\"tokenizer.ggml.tokens\":[]},\"modified_at\":\"2024-05-14T23:33:07.4166573+08:00\"}")
};

var info = await _client.ShowModelInformation("starcoder:latest", CancellationToken.None);
Expand All @@ -324,6 +324,10 @@ public async Task Returns_Deserialized_Model_WithSystem()
info.Details.Families.Should().BeNull();
info.Details.ParameterSize.Should().Be("7B");
info.Details.QuantizationLevel.Should().Be("Q4_0");
info.Info.Architecture.Should().Be("llama");
info.Info.QuantizationVersion.Should().Be(2);
info.Info.FileType.Should().Be(2);
info.Info.ExtraInfo.Should().NotBeNullOrEmpty();
}
}

Expand Down

0 comments on commit 5219e40

Please sign in to comment.