Skip to content

Commit

Permalink
added phi w/ functions template (#325)
Browse files Browse the repository at this point in the history
* added phi w/ functions template

* update token tags per template understanding

* update test
  • Loading branch information
robch authored Aug 6, 2024
1 parent 7c2120f commit 0970e76
Show file tree
Hide file tree
Showing 16 changed files with 1,052 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

public class ContentMessage
{
public ContentMessage()
{
Role = string.Empty;
Content = string.Empty;
}

public string Role { get; set; }
public string Content { get; set; }
}
Expand Down Expand Up @@ -33,8 +39,8 @@ public string GetChatCompletionStreaming(string userPrompt, Action<string>? call

var responseContent = string.Empty;
using var tokens = _tokenizer.Encode(string.Join("\n", _messages
.Select(m => $"<|{m.Role}|>{m.Content}<|end|>"))
+ "<|assistant|>");
.Select(m => $"<|{m.Role}|>\n{m.Content}\n<|end|>"))
+ "<|assistant|>\n");

using var generatorParams = new GeneratorParams(_model);
generatorParams.SetSearchOption("max_length", 2048);
Expand Down
2 changes: 1 addition & 1 deletion src/ai/.x/templates/phi3-onnx-chat-streaming-cs/_.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"_ShortName": "phi3-onnx-chat-streaming",
"_Language": "C#",

"ONNX_GENAI_MODEL_PLATFORM": "CPU"
"ONNX_GENAI_MODEL_PLATFORM": "DIRECTML"
}
Loading

0 comments on commit 0970e76

Please sign in to comment.