Skip to content

Commit

Permalink
bump version; update readme and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenkirstaetter committed Mar 18, 2024
1 parent f230e02 commit d03a1c3
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,65 @@ _ = await chat.SendMessage("Lastly, give a thorough definition for a CS graduate
chat.History.ForEach(c => Console.WriteLine($"{c.Role}: {c.Parts[0].Text}"));
```

### Create a tuned model

The Gemini API lets you tune models on your own data. Since it's your data and your tuned models this needs stricter access controls than API-Keys can provide.

Before you can create a tuned model, you'll need to [setup OAuth for your project](https://ai.google.dev/palm_docs/oauth_quickstart).

```csharp
using Mscc.GenerativeAI;

var projectId = "your_google_project_id"; // the ID of a project, not its name.
var accessToken = "your_access_token"; // use `gcloud auth application-default print-access-token` to get it.
var model = new GenerativeModel(apiKey: null, model: Model.Gemini10Pro001)
{
AccessToken = accessToken,
ProjectId = projectId
};
var request = new CreateTunedModelRequest()
{
BaseModel = $"models/{Model.Gemini10Pro001}",
DisplayName = "Autogenerated Test model",
TuningTask = new()
{
Hyperparameters = new() { BatchSize = 2, LearningRate = 0.001f, EpochCount = 3 },
TrainingData = new()
{
Examples = new()
{
Examples = new()
{
new TrainingDataExample() { TextInput = "1", Output = "2" },
new TrainingDataExample() { TextInput = "3", Output = "4" },
new TrainingDataExample() { TextInput = "-3", Output = "-2" },
new TrainingDataExample() { TextInput = "twenty two", Output = "twenty three" },
new TrainingDataExample() { TextInput = "two hundred", Output = "two hundred one" },
new TrainingDataExample() { TextInput = "ninety nine", Output = "one hundred" },
new TrainingDataExample() { TextInput = "8", Output = "9" },
new TrainingDataExample() { TextInput = "-98", Output = "-97" },
new TrainingDataExample() { TextInput = "1,000", Output = "1,001" },
new TrainingDataExample() { TextInput = "thirteen", Output = "fourteen" },
new TrainingDataExample() { TextInput = "seven", Output = "eight" },
}
}
}
}
};

// Act
var response = await model.CreateTunedModel(request);
Console.WriteLine($"Name: {response.Name}");
Console.WriteLine($"Model: {response.Metadata.TunedModel} (Steps: {response.Metadata.TotalSteps})");
```
(This is still work in progress but operational. Future release will provide types to simplify the create request.)

Tuned models appear in your Google AI Studio library.

[![Tuned models are listed below My Library in Google AI Studio](./docs/GeminiTunedModels.png)](https://aistudio.google.com/app/library)

### More samples

The folders [samples](./samples/) and [tests](./tests/) contain more examples.

- [Simple console application](./samples/Console.Minimal.Prompt/)
Expand Down
Binary file added docs/GeminiTunedModels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/Mscc.GenerativeAI.Google/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed

## 0.7.1

### Changed

- bump version

## 0.7.0

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/Mscc.GenerativeAI.Web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed

## 0.7.1

### Changed

- bump version

## 0.5.1

### Changed
Expand Down
20 changes: 20 additions & 0 deletions src/Mscc.GenerativeAI/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added

- provide types to simplify creation of tuned model

### Changed
### Fixed

## 0.7.1

### Added

- implement model tuning (works with stable models only)
- text-bison-001
- gemini-1.0-pro-001
- tests for model tuning
-
### Changed

- improved authentication regarding API key or OAuth/ADC
- added scope https://www.googleapis.com/auth/generative-language.tuning
- harmonized version among NuGet packages
- provide empty response on Safety stop
- merged regular and tuned ModelResponse

## 0.7.0

### Added
Expand Down

0 comments on commit d03a1c3

Please sign in to comment.