Giter Club home page Giter Club logo

Comments (3)

hyren avatar hyren commented on July 27, 2024 1

Yes exactly, we filter [q]_val by setting [q]_val to zero score. Let me give you one example, if there are 7 entities on a KG, e1-e7. And [q]_val = {e1,e2}, [q]_test \ [q]_val = {e3}. Then we only rank e3 against e4 to e7, masking the score of e1,e2 by making them zero.

from query2box.

hyren avatar hyren commented on July 27, 2024

Hi,

The goal of our experiments is to evaluate a model's performance in finding non-trivial answers. During evaluation, we first build a validation KG (train edges + valid edges) and a test KG (train edges + valid edges + test edges). Then given a test query q, we can achieve the answers to this query on both KGs, denoted as [q]_val and [q]_test. By non-trivial answers, we mean [q]_test / [q]_val, representing the answers that you can only achieve on the test KG but not on the validation KG.

Back to your question, the test_hard_ans dictionary contains (q, [q]_test / [q]_val), and the test_ans dictionary contains (q, [q]_test). During experiments, we only evaluate the data points in the test_hard_ans dictionary, and the reason why we also keep the test_ans dictionary is that we filter all [q]_test during ranking in order to calculate the numbers. This filtered setting is also standard in KG link prediction tasks. (It's also exactly the same case for valid_hard_ans and valid_ans).

Kindly let me know if you have additional questions.

from query2box.

osoblanco avatar osoblanco commented on July 27, 2024

Thanks for the swift reply,

I understood the first part. Here you set the [q]_test / [q]_val as the answer

query2box/codes/model.py

Lines 1008 to 1010 in 99dc9f5

ans_idxs = np.array(hard_ans_list)
vals = np.zeros((len(ans_idxs), args.nentity))
vals[np.arange(len(ans_idxs)), ans_idxs] = 1

I am not exactly sure if I understand what you mean by saying "the reason why we also keep the test_ans dictionary is that we filter all [q]_test during ranking in order to calculate the numbers".

By filtering do you mean that you remove the answers in [q]_val from the overall answer set?

Also, why do you need the "false_answers" for filtering in here

ans = test_ans[query]

false_ans = all_idx - ans

"false_answers" is everything not in [q]_test as I understand. And every such "false_answer" edge is activated while filtering.

query2box/codes/model.py

Lines 1011 to 1015 in 99dc9f5

axis2 = np.tile(false_ans_list, len(ans_idxs))
axis1 = np.repeat(range(len(ans_idxs)), len(false_ans))
vals[axis1, axis2] = 1
b = torch.Tensor(vals) if not args.cuda else torch.Tensor(vals).cuda()
filter_score = b*score

Doesn't this make the score for every edge in [q]_val to be 0?

from query2box.

Related Issues (10)

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.