Windows アプリ SDKの Phi Silica の API リファレンス
重要
Windows App SDK の最新の 試験的チャネル リリースで使用できます。
Windows App SDK の実験用チャネルには、開発の初期段階の API と機能が含まれています。 実験用チャネル内のすべての API は、広範な変更と破壊的変更の対象となり、今後のリリースからいつでも削除される可能性があります。 試験段階の機能は運用環境での使用はサポートされておらず、使用するアプリは Microsoft Store に公開できません。
- Phi Silica は中国では使用できません。
- パッケージ化されていないアプリはサポートされていません。
Microsoft の最も強力な NPU チューニングローカル言語モデルである Phi Silica などのローカル言語モデルにアクセスできるWindows アプリ SDK API について説明します。これにより、デバイス上での処理とチャットの生成、テキストの推論、数学の解決、コードの生成などが可能になります。
詳細については、「Windows アプリ SDKの Phi Silica の使用を開始する」を参照してください。
ヒント
これらの API とその機能に関するフィードバックをご提供ください。これには、Windows App SDK GitHub リポジトリで新しい問題を作成する (タイトルに Phi Silica を含める) 方法と、既存の問題に返信する方法があります。
Microsoft.Windows.AI.Generative 名前空間
ローカルのデバイス上の生成 AI プロンプト処理と応答用の API を提供します。
ImageDescriptionGenerator クラス
public sealed class ImageDescriptionGenerator : System.IDisposable
ImageDescriptionGenerator.Close メソッド
// This member is not implemented in C#
解説
C# では実装されていません。
ImageDescriptionGenerator.CreateAsync メソッド
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageDescriptionGenerator> CreateAsync ();
ImageDescriptionGenerator.DescribeAsync(Microsoft.Windows.Imaging.ImageBuffer) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Windows.Imaging.ImageBuffer image);
警告
画像を ImageDescriptionGenerator.DescribeAsync()
と呼び出すと、エラーが発生することがあります。 このエラーはスキップして、デバッガーが続行して正しい出力を生成できるようにします。 このエラーは開発環境でのみ表示され、エンド ユーザー (アプリを使用しているユーザー) には表示されません。 デバッグ ビルドまたはリリース ビルドを使用すると、このエラーがトリガーされます。 エラーは、すべての実行でではなく、時々表示されます。
ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image, Microsoft.Windows.AI.Generative.ImageDescriptionScenario scenario);
パラメーター
image
scenario
返品
解説
ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image, Microsoft.Windows.AI.Generative.ImageDescriptionScenario scenario, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
image
scenario
コンテンツフィルターオプション
返品
解説
ImageDescriptionGenerator.IsAvailable メソッド
public static bool IsAvailable ();
ImageDescriptionGenerator.MakeAvailableAsync メソッド
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
ImageDescriptionScenario 列挙子
public enum ImageDescriptionScenario
Fields
アクセシビリティ: 1
キャプション: 2
DetailedNarration: 3
OfficeCharts: 4
ImageLLMAdapterCreator クラス
public sealed class ImageLLMAdapterCreator : System.IDisposable
ImageLLMAdapterCreator.Close メソッド
// This member is not implemented in C#
解説
C# では実装されていません。
ImageLLMAdapterCreator.CreateAsync メソッド
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageLLMAdapterCreator> CreateAsync ();
返品
ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector) メソッド
public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
パラメーター
embeddings
返品
ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector) メソッド
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
パラメーター
embeddings
返品
ImageLLMAdapterCreator.GetModelInputSize メソッド
public uint GetModelInputSize ();
返品
ImageLLMAdapterCreator.GetModelOutputSize メソッド
public uint GetModelOutputSize ();
返品
ImageLLMAdapterCreator.IsAvailable メソッド
public static bool IsAvailable ();
返品
ImageLLMAdapterCreator.MakeAvailableAsync メソッド
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
返品
LanguageModel クラス
public sealed class LanguageModel : System.IDisposable
ローカル言語モデルと対話して、指定されたプロンプトの応答を生成できるオブジェクトを表します。
LanguageModel.Close メソッド
オブジェクトと関連付けられているリソースを破棄します。
解説
C# では実装されていません。
LanguageModel.CreateAsync メソッド
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModel> CreateAsync ();
LanguageModel クラスの新しいインスタンスを非同期的に作成します。
返品
TextRecognizer クラスの新しいインスタンス。
LanguageModel.CreateContext メソッド
public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
返品
解説
LanguageModel.CreateContext(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
システムプロンプト
コンテンツフィルターオプション
返品
解説
LanguageModel.GenerateEmbeddingVector(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
prompt
コンテンツフィルターオプション
返品
解説
LanguageModel.GenerateEmbeddingVector(System.String) メソッド
public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
パラメーター
prompt
返品
解説
LanguageModel.GenerateEmbeddingVectorAsync(System.String) メソッド
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
パラメーター
prompt
返品
解説
LanguageModel.GenerateEmbeddingVectorAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
prompt
コンテンツフィルターオプション
返品
解説
LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generateive.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
prompt
コンテンツフィルターオプション
返品
解説
LanguageModel.GenerateResponseAsync(System.String) メソッド
public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (string prompt);
1 つのプロンプトに対する完全な応答を生成して返します。
パラメーター
prompt
質問の形式のプロンプト。
返品
応答文字列と状態。
例外
ArgumentException: 指定されたプロンプトが、モデルが受け入れ可能なトークンの最大数より長くなっています。
LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド
public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
prompt
コンテンツフィルターオプション
context
返品
解説
LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String) メソッド
public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
パラメーター
options
prompt
返品
解説
LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
promptEmbedding
コンテンツフィルターオプション
context
返品
解説
LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
promptEmbedding
コンテンツフィルターオプション
返品
解説
LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector}) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding);
パラメーター
promptEmbedding
返品
解説
LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector}) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding);
パラメーター
options
promptEmbedding
返品
LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64}) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens);
パラメーター
options
プロンプトトークンズ
返品
LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
プロンプトトークン
コンテンツフィルターオプション
context
返品
LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
promptTokens
コンテンツフィルターのオプション
返品
LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generateive.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
prompt
コンテンツフィルターオプション
返品
LanguageModel.GenerateResponseWithProgressAsync(System.String) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
パラメーター
prompt
返品
LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generateive.LanguageModelOptions,System.String) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
パラメーター
options
prompt
返品
LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
prompt
コンテンツフィルターオプション
context
返品
LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
テキスト
コンテンツフィルターオプション
返品
LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
テキスト
コンテンツフィルターオプション
返品
LanguageModel.GenerateTokensAsync(System.String) メソッド
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
パラメーター
テキスト
返品
LanguageModel.GenerateTokensAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
テキスト
コンテンツフィルターオプション
返品
LanguageModel.IsAvailable メソッド
public static bool IsAvailable ();
返品
LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String) メソッド
public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
パラメーター
context
prompt
返品
LanguageModel.IsPromptLargerThanContext(System.String) メソッド
public bool IsPromptLargerThanContext (string prompt);
パラメーター
prompt
返品
LanguageModel.MakeAvailableAsync メソッド
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
返品
LanguageModelContext クラス
public sealed class LanguageModelContext
LanguageModelOptions クラス
public sealed class LanguageModelOptions
LanguageModelOptions.#ctor コンストラクター
public LanguageModelOptions ();
LanguageModelOptions.#ctor(Microsoft.Windows.AI.Generative.LanguageModelSkill,System.Single,System.Single,System.UInt32) コンストラクター
public LanguageModelOptions (Microsoft.Windows.AI.Generative.LanguageModelSkill skill, float temp, float top_p, uint top_k);
パラメーター
skill
temp
top_p
top_k
LanguageModelOptions.Skill プロパティ
public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
プロパティ値
LanguageModelOptions.Temp プロパティ
public float Temp { get; set; }
プロパティ値
LanguageModelOptions.Top_k プロパティ
public uint Top_k { get; set; }
プロパティ値
LanguageModelOptions.Top_p プロパティ
public float Top_p { get; set; }
プロパティ値
LanguageModelResponse クラス
public sealed class LanguageModelResponse
LanguageModelResponse.#ctor(System.String,Microsoft.Windows.AI.Generative.LanguageModelResponseStatus) コンストラクター
public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
パラメーター
返答
ステータス
LanguageModelResponse.Response プロパティ
public string Response { get; }
プロパティ値
LanguageModelResponse.Status プロパティ
public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
プロパティ値
LanguageModelResponseStatus 列挙
public enum LanguageModelResponseStatus
Fields
完了: 0
InProgress: 1
BlockedByPolicy: 2
PromptLargerThanContext: 3
ポリシーによってプロンプトがブロックされました: 4
ポリシーにより応答がブロックされました: 5
LanguageModelSkill 列挙
public enum LanguageModelSkill