Skip to content

Commit

Permalink
added support for meta 3.2 models
Browse files Browse the repository at this point in the history
  • Loading branch information
techthoughts2 committed Nov 7, 2024
1 parent 1b781a0 commit f9f8191
Show file tree
Hide file tree
Showing 22 changed files with 303 additions and 7 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"HEUN",
"hhmmss",
"Hmmss",
"inferencing",
"inpainting",
"isnot",
"jakemorrison",
Expand Down
6 changes: 4 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.2.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.22.0] - **BREAKING CHANGES**
## [0.26.0] - **BREAKING CHANGES**

- Module changes:
- stability.ai
Expand All @@ -22,7 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Cohere
- `Invoke-CohereCommandRModel` - minor corrections to debug output
- Meta
- `Invoke-MetaModel` - minor corrections to debug output and help
- `Invoke-MetaModel`
- Added support for new 3.2 models: `meta.llama3-2-1b-instruct-v1:0`, `meta.llama3-2-3b-instruct-v1:0`, `meta.llama3-2-11b-instruct-v1:0`, `meta.llama3-2-90b-instruct-v1:0`
- minor corrections to debug output and help
- Mistral
- `Invoke-MistralAIModel` - minor corrections to debug output and help. Adjusted Max token limit validation.
- Build changes:
Expand Down
8 changes: 8 additions & 0 deletions docs/Invoke-MetaModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,11 @@ Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
[https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/](https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/)
[https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md](https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md)
[https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/MODEL_CARD.md](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/MODEL_CARD.md)
[https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/MODEL_CARD_VISION.md](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/MODEL_CARD_VISION.md)
[https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/vision_prompt_format.md](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/vision_prompt_format.md)
[https://www.llama.com/docs/how-to-guides/vision-capabilities/](https://www.llama.com/docs/how-to-guides/vision-capabilities/)
2 changes: 1 addition & 1 deletion docs/pwshBedrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module Name: pwshBedrock
Module Guid: b4f9e4dc-0229-44ef-99a1-08be4c5e81f2
Download Help Link: NA
Help Version: 0.22.0
Help Version: 0.26.0
Locale: en-US
---

Expand Down
4 changes: 4 additions & 0 deletions src/Tests/Integration/ConverseAPI.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ InModuleScope 'pwshBedrock' {
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0',
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2',
'mistral.mistral-large-2402-v1:0',
'mistral.mistral-large-2407-v1:0',
Expand Down
4 changes: 4 additions & 0 deletions src/Tests/Integration/SupportedModels-Checks.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Describe 'Supported Models Checks' -Tag Integration {
'meta.llama3-1-8b-instruct-v1:0'
'meta.llama3-1-70b-instruct-v1:0'
'meta.llama3-1-405b-instruct-v1:0'
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2'
'mistral.mistral-large-2402-v1:0'
'mistral.mistral-large-2407-v1:0',
Expand Down
16 changes: 16 additions & 0 deletions src/Tests/Unit/Public/Get-ModelContext.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ InModuleScope 'pwshBedrock' {
ModelId = 'meta.llama3-1-405b-instruct-v1:0'
Context = 'test'
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-1b-instruct-v1:0'
Context = 'test'
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-3b-instruct-v1:0'
Context = 'test'
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-11b-instruct-v1:0'
Context = 'test'
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-90b-instruct-v1:0'
Context = 'test'
}
[PSCustomObject]@{
ModelId = 'mistral.mistral-7b-instruct-v0:2'
Context = 'test'
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Get-ModelTally.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ InModuleScope 'pwshBedrock' {

It 'should get the tally for all models' {
$eval = Get-ModelTally -AllModels
$eval.Count | Should -BeExactly 35
$eval.Count | Should -BeExactly 39
foreach ($model in $eval) {
if ($null -ne $model.ImageCount) {
$model.ImageCount | Should -BeExactly 0
Expand Down
56 changes: 56 additions & 0 deletions src/Tests/Unit/Public/Reset-ModelContext.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,62 @@ User: "Hi there!
}
)
}
[PSCustomObject]@{
ModelID = 'meta.llama3-2-1b-instruct-v1:0'
Context = @(
[PSCustomObject]@{
role = 'user'
content = @(
[PSCustomObject]@{
type = 'text'
text = 'Llama3 2 1b instruct v1 context'
}
)
}
)
}
[PSCustomObject]@{
ModelID = 'meta.llama3-2-3b-instruct-v1:0'
Context = @(
[PSCustomObject]@{
role = 'user'
content = @(
[PSCustomObject]@{
type = 'text'
text = 'Llama3 2 3b instruct v1 context'
}
)
}
)
}
[PSCustomObject]@{
ModelID = 'meta.llama3-2-11b-instruct-v1:0'
Context = @(
[PSCustomObject]@{
role = 'user'
content = @(
[PSCustomObject]@{
type = 'text'
text = 'Llama3 2 11b instruct v1 context'
}
)
}
)
}
[PSCustomObject]@{
ModelID = 'meta.llama3-2-90b-instruct-v1:0'
Context = @(
[PSCustomObject]@{
role = 'user'
content = @(
[PSCustomObject]@{
type = 'text'
text = 'Llama3 2 90b instruct v1 context'
}
)
}
)
}
[PSCustomObject]@{
ModelID = 'mistral.mistral-7b-instruct-v0:2'
Context = @(
Expand Down
132 changes: 132 additions & 0 deletions src/pwshBedrock/Imports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,38 @@ $Global:pwshBedRockSessionModelTally = @(
InputTokenCost = 0
OutputTokenCost = 0
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-1b-instruct-v1:0'
TotalCost = 0
InputTokenCount = 0
OutputTokenCount = 0
InputTokenCost = 0
OutputTokenCost = 0
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-3b-instruct-v1:0'
TotalCost = 0
InputTokenCount = 0
OutputTokenCount = 0
InputTokenCost = 0
OutputTokenCost = 0
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-11b-instruct-v1:0'
TotalCost = 0
InputTokenCount = 0
OutputTokenCount = 0
InputTokenCost = 0
OutputTokenCost = 0
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-90b-instruct-v1:0'
TotalCost = 0
InputTokenCount = 0
OutputTokenCount = 0
InputTokenCost = 0
OutputTokenCost = 0
}
[PSCustomObject]@{
ModelId = 'mistral.mistral-7b-instruct-v0:2'
TotalCost = 0
Expand Down Expand Up @@ -382,6 +414,22 @@ $Global:pwshBedrockModelContext = @(
ModelId = 'meta.llama3-1-405b-instruct-v1:0'
Context = ''
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-1b-instruct-v1:0'
Context = ''
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-3b-instruct-v1:0'
Context = ''
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-11b-instruct-v1:0'
Context = ''
}
[PSCustomObject]@{
ModelId = 'meta.llama3-2-90b-instruct-v1:0'
Context = ''
}
[PSCustomObject]@{
ModelId = 'mistral.mistral-7b-instruct-v0:2'
Context = ''
Expand Down Expand Up @@ -1039,6 +1087,90 @@ $script:metaModelInfo = @(
InputTokenCost = 0.00532
OutputTokenCost = 0.016
}
[PSCustomObject]@{
ProviderName = 'Meta'
ModelName = 'Llama 3.2 1B Instruct'
ModelId = 'meta.llama3-2-1b-instruct-v1:0'
Description = 'The most lightweight model in the Llama 3.2 collection of models, perfect for retrieval and summarization for edge devices and mobile applications.'
Strength = 'ideal for the following use cases: personal information management and multilingual knowledge retrieval.'
Multilingual = $true
Text = $true
Document = $true
Vision = $false
SystemPrompt = $true
ToolUse = $false
ResponseStreamingSupported = $true
ChatHistorySupported = $true
ContextWindow = 128000
MaxOutput = 4096
TrainingCutoff = '12-01-2023'
PayloadLimit = ''
InputTokenCost = 0.0001
OutputTokenCost = 0.0001
}
[PSCustomObject]@{
ProviderName = 'Meta'
ModelName = 'Llama 3.2 3B Instruct'
ModelId = 'meta.llama3-2-3b-instruct-v1:0'
Description = 'Designed for applications requiring low-latency inferencing and limited computational resources.'
Strength = 'excels at text summarization, classification, and language translation tasks. This model is ideal for the following use cases: mobile AI-powered writing assistants and customer service applications.'
Multilingual = $true
Text = $true
Document = $true
Vision = $false
SystemPrompt = $true
ToolUse = $false
ResponseStreamingSupported = $true
ChatHistorySupported = $true
ContextWindow = 128000
MaxOutput = 4096
TrainingCutoff = '12-01-2023'
PayloadLimit = ''
InputTokenCost = 0.00015
OutputTokenCost = 0.00015
}
[PSCustomObject]@{
ProviderName = 'Meta'
ModelName = 'Llama 3.2 11B Instruct'
ModelId = 'meta.llama3-2-11b-instruct-v1:0'
Description = 'Well-suited for content creation, conversational AI, language understanding, and enterprise applications requiring visual reasoning.'
Strength = 'The model demonstrates strong performance in text summarization, sentiment analysis, code generation, and following instructions, with the added ability to reason about images. This model use cases are similar to the 90B version: image captioning, image-text-retrieval, visual grounding, visual question answering and visual reasoning, and document visual question answering.'
Multilingual = $true
Text = $true
Document = $true
Vision = $true
SystemPrompt = $true
ToolUse = $false
ResponseStreamingSupported = $true
ChatHistorySupported = $true
ContextWindow = 128000
MaxOutput = 4096
TrainingCutoff = '12-01-2023'
PayloadLimit = ''
InputTokenCost = 0.00035
OutputTokenCost = 0.00035
}
[PSCustomObject]@{
ProviderName = 'Meta'
ModelName = 'Llama 3.2 90B Instruct'
ModelId = 'meta.llama3-2-90b-instruct-v1:0'
Description = "Meta's most advanced model, ideal for enterprise-level applications."
Strength = 'excels at general knowledge, long-form text generation, multilingual translation, coding, math, and advanced reasoning. It also introduces image reasoning capabilities, allowing for image understanding and visual reasoning tasks. This model is ideal for the following use cases: image captioning, image-text retrieval, visual grounding, visual question answering and visual reasoning, and document visual question answering.'
Multilingual = $true
Text = $true
Document = $true
Vision = $true
SystemPrompt = $true
ToolUse = $false
ResponseStreamingSupported = $true
ChatHistorySupported = $true
ContextWindow = 128000
MaxOutput = 4096
TrainingCutoff = '12-01-2023'
PayloadLimit = ''
InputTokenCost = 0.002
OutputTokenCost = 0.002
}
) #metaModelInfo

#endregion
Expand Down
20 changes: 20 additions & 0 deletions src/pwshBedrock/Private/Add-ModelCostEstimate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ function Add-ModelCostEstimate {
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0',
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2',
'mistral.mistral-large-2402-v1:0',
'mistral.mistral-large-2407-v1:0',
Expand Down Expand Up @@ -208,6 +212,22 @@ function Add-ModelCostEstimate {
$inputTokenCount = $Usage.prompt_token_count
$outputTokenCount = $Usage.generation_token_count
}
'meta.llama3-2-1b-instruct-v1:0' {
$inputTokenCount = $Usage.prompt_token_count
$outputTokenCount = $Usage.generation_token_count
}
'meta.llama3-2-3b-instruct-v1:0' {
$inputTokenCount = $Usage.prompt_token_count
$outputTokenCount = $Usage.generation_token_count
}
'meta.llama3-2-11b-instruct-v1:0' {
$inputTokenCount = $Usage.prompt_token_count
$outputTokenCount = $Usage.generation_token_count
}
'meta.llama3-2-90b-instruct-v1:0' {
$inputTokenCount = $Usage.prompt_token_count
$outputTokenCount = $Usage.generation_token_count
}
'mistral.mistral-7b-instruct-v0:2' {
$inputTokenCount = Get-TokenCountEstimate -Text $Message
$outputTokenCount = Get-TokenCountEstimate -Text $Usage.outputs.text
Expand Down
6 changes: 5 additions & 1 deletion src/pwshBedrock/Private/Format-MetaTextMessage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ function Format-MetaTextMessage {
'meta.llama3-70b-instruct-v1:0',
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0'
'meta.llama3-1-405b-instruct-v1:0',
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0'
)]
[string]$ModelID,

Expand Down
4 changes: 4 additions & 0 deletions src/pwshBedrock/Public/Get-ModelContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function Get-ModelContext {
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0',
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2',
'mistral.mistral-large-2402-v1:0',
'mistral.mistral-large-2407-v1:0',
Expand Down
4 changes: 4 additions & 0 deletions src/pwshBedrock/Public/Get-ModelCostEstimate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ function Get-ModelCostEstimate {
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0',
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2',
'mistral.mistral-small-2402-v1:0',
'mistral.mistral-large-2402-v1:0',
Expand Down
4 changes: 4 additions & 0 deletions src/pwshBedrock/Public/Get-ModelInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ function Get-ModelInfo {
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0',
'meta.llama3-2-1b-instruct-v1:0',
'meta.llama3-2-3b-instruct-v1:0',
'meta.llama3-2-11b-instruct-v1:0',
'meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2',
'mistral.mistral-small-2402-v1:0',
'mistral.mistral-large-2402-v1:0',
Expand Down
Loading

0 comments on commit f9f8191

Please sign in to comment.