HuggingfaceHub
v0.1.2
一個使用 C# 從 HuggingFace 下載模型和檔案的庫。
下載單一文件。
取得文件和儲存庫的資訊。
下載快照(儲存庫)。
繼續下載。
並行下載多個檔案(僅在 .NET 6 或更高版本中)。
上傳文件。
支援模型以外的儲存庫類型。
PM> 安裝包 HuggingfaceHub
或者
dotnet 新增套件 <your_project> HuggingfaceHub
或在Visual Studio的nuget管理器工具中搜尋HuggingfaceHub
。
using Huggingface;var path = wait HFDownloader.DownloadFileAsync("<RepoId>", "<Filename>");
使用 Huggingface;var res = wait HFDownloader.DownloadSnapshotAsync("<RepoId>");
目前僅支援模型類型的儲存庫。
使用 Huggingface;var info = wait HFDownloader.GetModelInfoAsync("<RepoId>");
using Huggingface;var res = wait HFDownloader.DownloadSnapshotAsync("<RepoId>",progress: new MyConsoleProgress());class MyConsoleProgress: IGroupedProgress{public void Report(string filename, intprogress): IGroupedProgress{public void Report(string filename, intprogress){/filename, intprogress){ // `progress` 的範圍是 [0, 100]。
使用 Huggingface;HFGlobalConfig.EndPoint = "<端點 Url>";
請檢查HFGlobalConfig
的定義以查看您可以設定的所有配置。
該函式庫主要採用huggingface_hub,這是用Python編寫的官方實作。