dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
9.04k stars 1.88k forks source link

Add Microsoft.ML.GenAI.Phi, test package and sample project. #7184

Closed LittleLittleCloud closed 3 months ago

LittleLittleCloud commented 4 months ago

We are excited to review your PR.

So we can do the best job, please check:

7169

LittleLittleCloud commented 4 months ago

/azp run

azure-pipelines[bot] commented 4 months ago
Azure Pipelines successfully started running 2 pipeline(s).
luisquintanilla commented 4 months ago

@LittleLittleCloud samples look good.

Something we might want to think about is the naming of the SK naming conventions for adding a model to make it more generic.

Similar to:

https://github.com/feiyun0112/SemanticKernel.Connectors.OnnxRuntimeGenAI/blob/6efcbcfbb84c5ecdb5cc31215903b6df13f3f841/OnnxRuntimeGenAIServiceCollectionExtensions.cs#L26

LittleLittleCloud commented 4 months ago

@LittleLittleCloud samples look good.

Something we might want to think about is the naming of the SK naming conventions for adding a model to make it more generic.

Similar to:

https://github.com/feiyun0112/SemanticKernel.Connectors.OnnxRuntimeGenAI/blob/6efcbcfbb84c5ecdb5cc31215903b6df13f3f841/OnnxRuntimeGenAIServiceCollectionExtensions.cs#L26

Rename to AddGenAIChatCompletion and AddGenAITextCompletion

LittleLittleCloud commented 3 months ago

/azp run

azure-pipelines[bot] commented 3 months ago
Azure Pipelines successfully started running 2 pipeline(s).
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 50.28902% with 774 lines in your changes missing coverage. Please review.

Project coverage is 68.90%. Comparing base (579fe03) to head (a97afdf). Report is 10 commits behind head on main.

Files Patch % Lines
...crosoft.ML.GenAI.Core/Pipeline/CausalLMPipeline.cs 0.00% 98 Missing :warning:
src/Microsoft.ML.GenAI.Phi/Module/Phi3Attention.cs 25.00% 86 Missing and 1 partial :warning:
src/Microsoft.ML.GenAI.Phi/Utils.cs 12.94% 72 Missing and 2 partials :warning:
src/Microsoft.ML.GenAI.Phi/Module/Phi3Model.cs 19.04% 68 Missing :warning:
src/Microsoft.ML.GenAI.Phi/Module/Phi2Model.cs 12.16% 65 Missing :warning:
.../Microsoft.ML.GenAI.Phi/Module/Phi3DecoderLayer.cs 16.66% 59 Missing and 1 partial :warning:
src/Microsoft.ML.GenAI.Phi/Module/Phi2Attention.cs 32.09% 53 Missing and 2 partials :warning:
...crosoft.ML.GenAI.Phi/Module/Phi3RotaryEmbedding.cs 20.00% 32 Missing :warning:
...ML.GenAI.Phi/Module/Phi3SuScaledRotaryEmbedding.cs 24.39% 31 Missing :warning:
...c/Microsoft.ML.GenAI.Phi/Phi3/Phi3CausalLMAgent.cs 56.71% 21 Missing and 8 partials :warning:
... and 18 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #7184 +/- ## ========================================== - Coverage 69.06% 68.90% -0.16% ========================================== Files 1401 1441 +40 Lines 268516 270828 +2312 Branches 27812 28019 +207 ========================================== + Hits 185451 186619 +1168 - Misses 75902 77004 +1102 - Partials 7163 7205 +42 ``` | [Flag](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | Coverage Δ | | |---|---|---| | [Debug](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `68.90% <50.28%> (-0.16%)` | :arrow_down: | | [production](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `63.43% <41.62%> (-0.22%)` | :arrow_down: | | [test](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `89.02% <95.60%> (+0.06%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | Coverage Δ | | |---|---|---| | [...crosoft.ML.GenAI.Core/Extension/ModuleExtension.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Core%2FExtension%2FModuleExtension.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5Db3JlL0V4dGVuc2lvbi9Nb2R1bGVFeHRlbnNpb24uY3M=) | `54.22% <100.00%> (ø)` | | | [src/Microsoft.ML.GenAI.Core/Module/GenAILinear.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Core%2FModule%2FGenAILinear.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5Db3JlL01vZHVsZS9HZW5BSUxpbmVhci5jcw==) | `100.00% <100.00%> (ø)` | | | [....ML.GenAI.Phi/Extension/SemanticKernelExtension.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Phi%2FExtension%2FSemanticKernelExtension.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5QaGkvRXh0ZW5zaW9uL1NlbWFudGljS2VybmVsRXh0ZW5zaW9uLmNz) | `100.00% <100.00%> (ø)` | | | [...Microsoft.ML.GenAI.Phi/Phi2/Phi2TokenizerHelper.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Phi%2FPhi2%2FPhi2TokenizerHelper.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5QaGkvUGhpMi9QaGkyVG9rZW5pemVySGVscGVyLmNz) | `100.00% <100.00%> (ø)` | | | [...Microsoft.ML.GenAI.Phi/Phi3/Phi3TokenizerHelper.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Phi%2FPhi3%2FPhi3TokenizerHelper.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5QaGkvUGhpMy9QaGkzVG9rZW5pemVySGVscGVyLmNz) | `100.00% <100.00%> (ø)` | | | [test/Microsoft.ML.GenAI.Phi.Tests/AutoGenTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=test%2FMicrosoft.ML.GenAI.Phi.Tests%2FAutoGenTests.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuR2VuQUkuUGhpLlRlc3RzL0F1dG9HZW5UZXN0cy5jcw==) | `100.00% <100.00%> (ø)` | | | [...icrosoft.ML.GenAI.Phi.Tests/SemanticKernelTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=test%2FMicrosoft.ML.GenAI.Phi.Tests%2FSemanticKernelTests.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuR2VuQUkuUGhpLlRlc3RzL1NlbWFudGljS2VybmVsVGVzdHMuY3M=) | `100.00% <100.00%> (ø)` | | | [src/Microsoft.ML.GenAI.Phi/Phi2/Config.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Phi%2FPhi2%2FConfig.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5QaGkvUGhpMi9Db25maWcuY3M=) | `98.00% <98.00%> (ø)` | | | [...rosoft.ML.GenAI.Core.Tests/QuantizedLinearTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=test%2FMicrosoft.ML.GenAI.Core.Tests%2FQuantizedLinearTests.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuR2VuQUkuQ29yZS5UZXN0cy9RdWFudGl6ZWRMaW5lYXJUZXN0cy5jcw==) | `95.52% <95.52%> (ø)` | | | [src/Microsoft.ML.GenAI.Phi/Phi3/Config.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree&filepath=src%2FMicrosoft.ML.GenAI.Phi%2FPhi3%2FConfig.cs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5HZW5BSS5QaGkvUGhpMy9Db25maWcuY3M=) | `93.84% <93.84%> (ø)` | | | ... and [25 more](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | | ... and [38 files with indirect coverage changes](https://app.codecov.io/gh/dotnet/machinelearning/pull/7184/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet)