Documentation
¶
Overview ¶
Package toolmodel runs local embedding models used for tool retrieval. The model layout and WordPiece implementation are adapted from Pulse (github.com/bryanbarton525/pulse, Apache-2.0 license).
Index ¶
- Constants
- func Cosine(a, b []float32) float64
- func MiniLMPath(stateDir string) string
- func PotionPaths(stateDir string) (string, string)
- func SetupMiniLM(ctx context.Context, stateDir string) error
- func SetupPotion(ctx context.Context, stateDir string) error
- type DecisionClient
- func (c *DecisionClient) ModelIdentity() string
- func (c *DecisionClient) Score(ctx context.Context, task string, tools []KevTool) ([]float64, error)
- func (c *DecisionClient) ScoreChoice(ctx context.Context, task string, tools []DecisionTool, instructions string) ([]float64, error)
- func (c *DecisionClient) ScoreKind() string
- type DecisionTool
- type EncodeOptions
- type KevClient
- type KevTool
- type MiniLM
- type Potion
- type WordPiece
Constants ¶
const ( PotionRevision = "1e5a03f8eeb2c98b928fbbd846f22f816360919f" MiniLMRevision = "1110a243fdf4706b3f48f1d95db1a4f5529b4d41" )
const LayaRevision = "55cf4c4ebb4ebe31b2550e8bdf3bd21b99753851"
Variables ¶
This section is empty.
Functions ¶
func MiniLMPath ¶
func PotionPaths ¶
Types ¶
type DecisionClient ¶ added in v0.1.26
type DecisionClient struct {
// contains filtered or unexported fields
}
DecisionClient calls an explicitly started decision server. A timed-out server exchange disables the adapter until Prism restarts because server inference may still be queued after HTTP cancellation.
func NewDecisionClient ¶ added in v0.1.25
func NewDecisionClient(rawURL, apiKeyEnv, model string) (*DecisionClient, error)
NewDecisionClient supports Kev/Jev binary scoring and Laya categorical choices.
func NewKevClient ¶
func NewKevClient(rawURL, apiKeyEnv string) (*DecisionClient, error)
func (*DecisionClient) ModelIdentity ¶ added in v0.1.26
func (c *DecisionClient) ModelIdentity() string
func (*DecisionClient) ScoreChoice ¶ added in v0.1.36
func (c *DecisionClient) ScoreChoice(ctx context.Context, task string, tools []DecisionTool, instructions string) ([]float64, error)
ScoreChoice asks an explicit categorical question. Routing uses a next-action question rather than reusing the advisory recommender's whole-task question.
func (*DecisionClient) ScoreKind ¶ added in v0.1.26
func (c *DecisionClient) ScoreKind() string
ScoreKind distinguishes relative choice probabilities from independent binary scores.
type DecisionTool ¶ added in v0.1.26
type DecisionTool struct{ Name, Description string }
type EncodeOptions ¶
type EncodeOptions struct {
// AddSpecialTokens wraps the sequence in [CLS] and [SEP].
//
// Transformers need them: [CLS] is a real position the attention layers
// read. Static embeddings do not — there is no attention, so a special
// token would just be one more vector dragging the mean toward a constant.
AddSpecialTokens bool
// MaxTokens truncates the sequence. Zero means no limit.
MaxTokens int
}
EncodeOptions controls how a sequence is prepared for a specific model.
type KevClient ¶
type KevClient = DecisionClient
KevClient preserves compatibility with existing callers.
type MiniLM ¶
type MiniLM struct {
// contains filtered or unexported fields
}
MiniLM runs an ONNX sentence embedding graph through Hugot's pure-Go backend.
func LoadMiniLM ¶
type WordPiece ¶
type WordPiece struct {
// contains filtered or unexported fields
}
WordPiece is a BERT WordPiece tokenizer.
Both embedding tiers use a BERT-family vocabulary, so one pure-Go tokenizer serves both. Implementing it here rather than pulling in a cgo/Rust tokenizer keeps Prism's runtime binary free of cgo entirely.
func LoadWordPiece ¶
LoadWordPiece reads a vocab.txt where line N holds the token with ID N.