This repository was archived by the owner on Dec 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 320
Add frequencePenalty and presencePenalty parameters support for gener… #264
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
caa57fc
Add frequencePenalty and presencePenalty parameters support for gener…
junyanxu 75be7c3
Change frequence to frequency
junyanxu ef688bd
Update format
junyanxu 8be7537
Update parameter description
junyanxu 00216ce
Update the parameter doc.
junyanxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@google/generative-ai": minor | ||
| --- | ||
|
|
||
| Add frequencePenalty and presencePenalty parameters support for generate content. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
docs/reference/main/generative-ai.baseparams.frequencepenalty.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [BaseParams](./generative-ai.baseparams.md) > [frequencePenalty](./generative-ai.baseparams.frequencepenalty.md) | ||
|
|
||
| ## BaseParams.frequencePenalty property | ||
|
|
||
| **Signature:** | ||
|
|
||
| ```typescript | ||
| frequencePenalty?: number; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
docs/reference/main/generative-ai.baseparams.presencepenalty.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [BaseParams](./generative-ai.baseparams.md) > [presencePenalty](./generative-ai.baseparams.presencepenalty.md) | ||
|
|
||
| ## BaseParams.presencePenalty property | ||
|
|
||
| **Signature:** | ||
|
|
||
| ```typescript | ||
| presencePenalty?: number; | ||
| ``` |
11 changes: 11 additions & 0 deletions
11
docs/reference/main/generative-ai.generativemodel.frequencypenalty.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [GenerativeModel](./generative-ai.generativemodel.md) > [frequencyPenalty](./generative-ai.generativemodel.frequencypenalty.md) | ||
|
|
||
| ## GenerativeModel.frequencyPenalty property | ||
|
|
||
| **Signature:** | ||
|
|
||
| ```typescript | ||
| frequencyPenalty?: number; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
docs/reference/main/generative-ai.generativemodel.presencepenalty.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [GenerativeModel](./generative-ai.generativemodel.md) > [presencePenalty](./generative-ai.generativemodel.presencepenalty.md) | ||
|
|
||
| ## GenerativeModel.presencePenalty property | ||
|
|
||
| **Signature:** | ||
|
|
||
| ```typescript | ||
| presencePenalty?: number; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,12 @@ import { | |
| export interface BaseParams { | ||
| safetySettings?: SafetySetting[]; | ||
| generationConfig?: GenerationConfig; | ||
| // Presence penalty applied to the next token's logprobs if the token has | ||
|
||
| // already been seen in the response. | ||
| presencePenalty?: number | ||
| // Frequency penalty applied to the next token's logprobs, multiplied by the | ||
| // number of times each token has been seen in the respponse so far. | ||
| frequencePenalty?: number | ||
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will show up as a release note in the public changelog so we try to do our best to format it for public consumption. You can use backticks to format code literals and symbols. Suggestion: