Git Product home page Git Product logo

Comments (3)

dcy0577 avatar dcy0577 commented on June 1, 2024 3

I think this line of code need to be removed:

mask_labels = item_ids != self.padding_idx

As solution just use the mask_label from predict_all() above.

And I think the reason why current code somehow works is because of this part:

# shift sequence of interaction embeddings
pos_emb_inp = inputs[:, :-1]
# Adding a masked item in the sequence to return to the initial sequence.
pos_emb_inp = torch.cat( # type: ignore
[
pos_emb_inp,
torch.zeros(
(pos_emb_inp.shape[0], 1, pos_emb_inp.shape[2]),
dtype=pos_emb_inp.dtype,
).to(inputs.device),
],
axis=1,
)
# Replacing the inputs corresponding to padded items with a trainable embedding
pos_emb_inp = torch.where(
mask_schema.unsqueeze(-1).bool(),
pos_emb_inp,
self.masked_item_embedding.to(pos_emb_inp.dtype),
)
return pos_emb_inp

Given input sequence without padding [1,2,3], the mask schema generated by current code during evaluation will be [True, True, True], which exposes the last item. However the apply_mask_to_inputs will replace the last item with 0 embedding. And since the schema are all True, no mask embedding will be applied on input. I think in this case 0 embedding sort of plays a role as mask.
However, when input has padding like [1,2,3,0,0], the current mask schema will be [True, True, True, False, False]. And because the last item is a padding item, the apply_mask_to_inputs basically replaces the padding with 0 embedding. Then the mask schema comes in, masks the last 2 padding items, keeping the 1,2,3 visible to transformer.
I think thats why people encounter issues testing clm. If there are always paddings in input data, the evaluation metrics would be unrealistically high.

from transformers4rec.

jian-mo avatar jian-mo commented on June 1, 2024

I also noticed this bug as well. After the fix, the recall is down about 20% less

from transformers4rec.

zhouyu5 avatar zhouyu5 commented on June 1, 2024

Any further updates? It seems #723 still not solve this bug.

from transformers4rec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.