Documentation
¶
Overview ¶
Package contextlengthaware provides plugins that implement multiple extension points (e.g., both Filter and Scorer interfaces).
Index ¶
- Constants
- func Factory(name string, rawParameters *json.Decoder, _ plugin.Handle) (plugin.Plugin, error)
- type ContextLengthAware
- func (p *ContextLengthAware) Category() scheduling.ScorerCategory
- func (p *ContextLengthAware) Consumes() plugin.DataDependencies
- func (p *ContextLengthAware) Filter(ctx context.Context, request *scheduling.InferenceRequest, ...) []scheduling.Endpoint
- func (p *ContextLengthAware) Score(ctx context.Context, request *scheduling.InferenceRequest, ...) map[scheduling.Endpoint]float64
- func (p *ContextLengthAware) TypedName() plugin.TypedName
- func (p *ContextLengthAware) WithName(name string) *ContextLengthAware
Constants ¶
const ( // ContextLengthAwareType is the type of the ContextLengthAware plugin ContextLengthAwareType = "context-length-aware" // DefaultContextLengthLabel is the default label name used to identify context length ranges on pods DefaultContextLengthLabel = "llm-d.ai/context-length-range" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextLengthAware ¶
type ContextLengthAware struct {
// contains filtered or unexported fields
}
ContextLengthAware is a plugin that filters or scores endpoints based on their association with input context length groups. It checks for a specific label on endpoints that defines the context length ranges they support. If filtering is enabled, endpoints that don't support the request's context length are filtered out. Additionally, it scores endpoints based on how well their context length ranges match the request.
The context length is the token count from InferenceRequestBody.TokenizedPrompt as populated by the tokenizer DataProducer plugin. When tokens are not available it is treated as 0 (unknown).
func NewContextLengthAware ¶
func NewContextLengthAware(name string, params *contextLengthAwareParameters) *ContextLengthAware
NewContextLengthAware creates and returns an instance of the ContextLengthAware plugin.
func (*ContextLengthAware) Category ¶
func (p *ContextLengthAware) Category() scheduling.ScorerCategory
Category returns the preference the scorer applies when scoring candidate endpoints.
func (*ContextLengthAware) Consumes ¶
func (p *ContextLengthAware) Consumes() plugin.DataDependencies
Consumes declares the TokenizedPrompt dependency so the data-layer DAG orders the token-producer before this plugin runs and auto-creates one when none is configured; the context length is the token count it provides.
func (*ContextLengthAware) Filter ¶
func (p *ContextLengthAware) Filter(ctx context.Context, request *scheduling.InferenceRequest, endpoints []scheduling.Endpoint) []scheduling.Endpoint
Filter filters out endpoints that don't have a context length range matching the request. This is only active when enableFiltering is true.
func (*ContextLengthAware) Score ¶
func (p *ContextLengthAware) Score(ctx context.Context, request *scheduling.InferenceRequest, endpoints []scheduling.Endpoint) map[scheduling.Endpoint]float64
Score scores endpoints based on how well their context length ranges match the request. Endpoints with tighter/more specific ranges matching the request get higher scores.
func (*ContextLengthAware) TypedName ¶
func (p *ContextLengthAware) TypedName() plugin.TypedName
TypedName returns the typed name of the plugin.
func (*ContextLengthAware) WithName ¶
func (p *ContextLengthAware) WithName(name string) *ContextLengthAware
WithName sets the name of the plugin.