# FISM¶

Reference:
1. Kabbur et al. “FISM: Factored item similarity models for top-n recommender systems” in KDD 2013

Reference code:

https://github.com/AaronHeee/Neural-Attentive-Item-Similarity-Model

class recbole.model.general_recommender.fism.FISM(config, dataset)[source]

FISM is an item-based model for generating top-N recommendations that learns the item-item similarity matrix as the product of two low dimensional latent factor matrices. These matrices are learned using a structural equation modeling approach, where in the value being estimated is not used for its own estimation.

calculate_loss(interaction)[source]

Calculate the training loss for a batch data.

Parameters

interaction (Interaction) – Interaction class of the batch.

Returns

Training loss, shape: []

Return type

torch.Tensor

forward(user, item)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

full_sort_predict(interaction)[source]

full sort prediction function. Given users, calculate the scores between users and all candidate items.

Parameters

interaction (Interaction) – Interaction class of the batch.

Returns

Predicted scores for given users and all candidate items, shape: [n_batch_users * n_candidate_items]

Return type

torch.Tensor

get_history_info(dataset)[source]

get the user history interaction information

Parameters

dataset (DataSet) – train dataset

Returns

Return type

tuple

input_type = 1
inter_forward(user, item)[source]

forward the model by interaction

predict(interaction)[source]

Predict the scores between users and items.

Parameters

interaction (Interaction) – Interaction class of the batch.

Returns

Predicted scores for given users and items, shape: [batch_size]

Return type

torch.Tensor

reg_loss()[source]

calculate the reg loss for embedding layers

Returns

reg loss

Return type

torch.Tensor

training: bool
user_forward(user_input, item_num, user_bias, repeats=None, pred_slc=None)[source]

forward the model by user

Parameters
• user_input (torch.Tensor) – user input tensor

• item_num (torch.Tensor) – user history interaction lens

• repeats (int, optional) – the number of items to be evaluated

• pred_slc (torch.Tensor, optional) – continuous index which controls the current evaluation items, if pred_slc is None, it will evaluate all items

Returns

result

Return type

torch.Tensor