Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: Text generator function in Scipy tutorial not sampling words based on calculated probabilities #138

Open
apoorvasheera opened this issue Sep 25, 2024 · 0 comments

Comments

@apoorvasheera
Copy link
Member

Notebook - SciPy2024/module1/1-introduction-to-language-models.ipynb
Function - text_generator

next word is chosen based on below code:

word = model_sorted_probabilities[
np.random.choice(np.arange(len(model_sorted_probabilities)))
][0]

Should be something like this instead:

words = [item[0] for item in model_sorted_probabilities] # Get list of words
probabilities = [item[1] for item in model_sorted_probabilities] # Get corresponding probabilities
word = np.random.choice(words, p=probabilities) # Select based on probabilities

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant