Repository navigation
Get‑ShpCosineSimilarity
Computes the cosine similarity between two embedding vectors.
Get-ShpCosineSimilarity [-Reference] <Double[]> [-Candidate] <Double[]>
[<CommonParameters>]
Returns the cosine similarity (a value from -1 to 1, where 1 means identical direction) between a reference vector and a candidate vector, using pure PowerShell so no compiled dependency is needed. Pair it with Request-ShpEmbedding to rank texts by semantic similarity for search or retrieval; to score many candidates, pipe them through ForEach-Object. The two vectors must have the same length; a zero-magnitude vector yields a score of 0.
Get-ShpCosineSimilarity -Reference $a -Candidate $b
Returns the cosine similarity between vectors $a and $b.
$docs | ForEach-Object { Get-ShpCosineSimilarity -Reference $query -Candidate $_.Embedding }
Scores each document embedding against the query vector.
The candidate embedding vector to score. Mandatory.
Type: Double[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe reference embedding vector to compare against. Mandatory.
Type: Double[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- Clear-ShpChat
- Clear-ShpContext
- Clear-ShpRedactionPolicy
- Clear-ShpToolPolicy
- Clear-ShpUsage
- Compress-ShpChat
- ConvertTo-ShpAnnotation
- ConvertTo-ShpOtelTrace
- ConvertTo-ShpTokenCount
- Get-ShpChat
- Get-ShpChatCheckpoint
- Get-ShpContext
- Get-ShpContextReport
- Get-ShpCosineSimilarity
- Get-ShpCostEstimate
- Get-ShpDefault
- Get-ShpMcpServer
- Get-ShpModel
- Get-ShpModelName
- Get-ShpRedactionPolicy
- Get-ShpTool
- Get-ShpToolPolicy
- Get-ShpUsage
- Initialize-Shp
- Invoke-Shp
- Invoke-ShpBatch
- Invoke-ShpEval
- Invoke-ShpSubagent
- Register-ShpMcpServer
- Register-ShpTool
- Request-ShpEmbedding
- Resolve-ShpError
- Restore-ShpChat
- Save-ShpChat
- Select-ShpModel
- Set-ShpContext
- Set-ShpRedactionPolicy
- Set-ShpToolPolicy
- Start-ShpChat
- Test-ShpCiReadiness
- Unregister-ShpMcpServer
- Unregister-ShpTool