Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complexity is n! where n is the maximum arity for a fact #3

Open
faceslog opened this issue Sep 17, 2024 · 0 comments
Open

Complexity is n! where n is the maximum arity for a fact #3

faceslog opened this issue Sep 17, 2024 · 0 comments

Comments

@faceslog
Copy link

faceslog commented Sep 17, 2024

Hey there,

So, this method is giving me some serious “math anxiety”! In my dataset (WD50k), I’ve got facts with an arity of 67. That means it tries to compute a humble 3.647111091818868e+94 permutations. 😅

To put it mildly, my CPU is now in therapy.

It would be great if there were some way to update the negative sampling or for example fix the maximum number of permutations for facts with an arity that is too big ?

def permutations(arr, position, end, res):
    """
    Permutate the array
    """
    if position == end:
        res.append(tuple(arr))
    else:
        for index in range(position, end):
            arr[index], arr[position] = arr[position], arr[index]
            permutations(arr, position+1, end, res)
            arr[index], arr[position] = arr[position], arr[index]
    return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant