logics

package
v0.5.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 42 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LatestRecommender          = "latest"
	NonPersonalizedRecommender = "non-personalized/"
	ItemToItemRecommender      = "item-to-item/"
	UserToUserRecommender      = "user-to-user/"
	ExternalRecommender        = "external/"
	CollaborativeRecommender   = "collaborative"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatReranker added in v0.5.5

type ChatReranker struct {
	// contains filtered or unexported fields
}

func NewChatReranker added in v0.5.5

func NewChatReranker(cfg config.RerankerAPIConfig, queryTemplate, docTemplate string) (*ChatReranker, error)

func (*ChatReranker) Rank added in v0.5.5

func (r *ChatReranker) Rank(ctx context.Context, user *data.User, feedback []*FeedbackItem, items []*data.Item) ([]cache.Score, error)

type External

type External struct {
	// contains filtered or unexported fields
}

func NewExternal

func NewExternal(cfg config.ExternalConfig) (*External, error)

func (*External) Close

func (e *External) Close() error

func (*External) Pull

func (e *External) Pull(userId string) (res []string, err error)

type FeedbackItem

type FeedbackItem struct {
	FeedbackType string
	data.Item
}

type IDF

type IDF[T dataset.ID | int32] []float32

type ItemToItem

type ItemToItem interface {
	Timestamp() time.Time
	Count() int
	Get(i int) *data.Item
	Push(item *data.Item, feedback []int32)
	PopAll(i int) []cache.Score
}

func NewItemToItem

func NewItemToItem(cfg config.ItemToItemConfig, n int, timestamp time.Time, opts *ItemToItemOptions) (ItemToItem, error)

type ItemToItemOptions

type ItemToItemOptions struct {
	TagsIDF      []float32
	UsersIDF     []float32
	OpenAIConfig config.OpenAIConfig
}

type MatrixFactorizationItems

type MatrixFactorizationItems struct {
	// contains filtered or unexported fields
}

func NewMatrixFactorizationItems

func NewMatrixFactorizationItems(timestamp time.Time) *MatrixFactorizationItems

func (*MatrixFactorizationItems) Add

func (items *MatrixFactorizationItems) Add(itemId string, v []float32)

func (*MatrixFactorizationItems) Marshal

func (items *MatrixFactorizationItems) Marshal(w io.Writer) error

func (*MatrixFactorizationItems) Search

func (items *MatrixFactorizationItems) Search(v []float32, n int) []cache.Score

func (*MatrixFactorizationItems) Unmarshal

func (items *MatrixFactorizationItems) Unmarshal(r io.Reader) error

type MatrixFactorizationUsers

type MatrixFactorizationUsers struct {
	// contains filtered or unexported fields
}

func NewMatrixFactorizationUsers

func NewMatrixFactorizationUsers() *MatrixFactorizationUsers

func (*MatrixFactorizationUsers) Add

func (users *MatrixFactorizationUsers) Add(userId string, v []float32)

func (*MatrixFactorizationUsers) Get

func (users *MatrixFactorizationUsers) Get(userId string) ([]float32, bool)

func (*MatrixFactorizationUsers) Marshal

func (users *MatrixFactorizationUsers) Marshal(w io.Writer) error

func (*MatrixFactorizationUsers) Unmarshal

func (users *MatrixFactorizationUsers) Unmarshal(r io.Reader) error

type NonPersonalized

type NonPersonalized struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewNonPersonalized

func NewNonPersonalized(cfg config.NonPersonalizedConfig, n int, timestamp time.Time) (*NonPersonalized, error)

func (*NonPersonalized) Name

func (l *NonPersonalized) Name() string

func (*NonPersonalized) PopAll

func (l *NonPersonalized) PopAll() []cache.Score

func (*NonPersonalized) Push

func (l *NonPersonalized) Push(item data.Item, feedback []data.Feedback)

func (*NonPersonalized) Timestamp

func (l *NonPersonalized) Timestamp() time.Time

type Recommender

type Recommender struct {
	// contains filtered or unexported fields
}

func NewRecommender

func NewRecommender(config config.RecommendConfig, cacheClient cache.Database, dataClient data.Database, online bool, userId string, categories []string) (*Recommender, error)

func (*Recommender) ExcludeSet

func (r *Recommender) ExcludeSet() mapset.Set[string]

func (*Recommender) IsColdStart

func (r *Recommender) IsColdStart() bool

func (*Recommender) Recommend

func (r *Recommender) Recommend(ctx context.Context, limit int) (result []cache.Score, err error)

func (*Recommender) RecommendSequential

func (r *Recommender) RecommendSequential(ctx context.Context, result []cache.Score, limit int, names ...string) ([]cache.Score, string, error)

RecommendSequential recommend items from multiple recommenders sequentially util reaching the limit. If limit <= 0, all recommendations are returned.

func (*Recommender) UserFeedback

func (r *Recommender) UserFeedback() []data.Feedback

type RecommenderFunc

type RecommenderFunc func(ctx context.Context) ([]cache.Score, string, error)

type UserToUser

type UserToUser interface {
	Users() []*data.User
	Push(user *data.User, feedback []int32)
	PopAll(i int) []cache.Score
	Timestamp() time.Time
}

func NewUserToUser

func NewUserToUser(cfg config.UserToUserConfig, n int, timestamp time.Time, opts *UserToUserOptions) (UserToUser, error)

type UserToUserOptions

type UserToUserOptions struct {
	TagsIDF  []float32
	ItemsIDF []float32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL