Skip to content

VectorsAdjuster Class Documentation

Overview

The VectorsAdjuster class provides an abstract interface to adjust embedding vectors using improvement input data. It defines an abstract method, adjust_vectors, which must be implemented by subclasses. The primary functionality of the method is to move clicked item vectors closer to a query vector while shifting non-clicked ones further away.

Functionality

The adjust_vectors method adjusts embedding vectors in ImprovementInput objects, refining the vectors based on user click data.

Parameters

  • data_for_improvement: A list of ImprovementInput objects containing a query vector along with clicked and non-clicked elements and their corresponding embedding vectors.

Returns

  • A list of ImprovementInput objects with updated embedding vectors.

Usage

  • Purpose: Refine embedding vectors based on user click data to enhance search and recommendation systems.

Example Implementations

Custom Implementation

class CustomVectorsAdjuster(VectorsAdjuster):
    def adjust_vectors(self, data_for_improvement):
        # Adjust vectors by moving clicked items closer and
        # non-clicked items further away from the query vector
        for input_data in data_for_improvement:
            # Insert custom adjustment logic here
            pass
        return data_for_improvement

Simple Implementation

class SimpleVectorsAdjuster(VectorsAdjuster):
    def adjust_vectors(self, data_for_improvement):
        # Example: move clicked items closer and non-clicked items farther
        return data_for_improvement

Inheritance

The VectorsAdjuster class inherits from Python's ABC class, marking it as an abstract class. This enforces that any concrete subclass must provide an implementation for the adjust_vectors method.

Motivation

The class is designed to standardize the process of vector adjustment in embedding-based search and recommendation systems. By providing a clear interface, VectorsAdjuster drives consistent and effective improvement strategies across various implementations.