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

nano-GPT train for letter sorting #12

Open
Nuclear6 opened this issue Dec 13, 2023 · 3 comments
Open

nano-GPT train for letter sorting #12

Nuclear6 opened this issue Dec 13, 2023 · 3 comments

Comments

@Nuclear6
Copy link

Great project! I would like to know how to train the letter sorting model mentioned in the nano-GPT visualization project? I think the visualization here is more clear when combined with the nano-GPT project code? So is it convenient to provide training documents for the alphabetical sorting model? Thank you so much!

@Nuclear6
Copy link
Author

I am a newbie in AI and want to try it myself, but I find it is still a bit difficult.

@gitzhangzhao
Copy link

@Nuclear6

I generated some training data and then replaced the Shakespeare_char demo to train a char sorting model.

import itertools
import random

# Set the number of samples you want
num_samples = 10000

# Generate the dataset
data = []
for _ in range(num_samples):
    # Create a random string using ABC characters
    string = ''.join(random.choice('ABC') for _ in range(random.randint(1, 5)))
    # Sort the string to get the correct answer
    sorted_string = ''.join(sorted(string))
    # Add the unsorted and sorted pair to the dataset
    data.append(f"{string}|{sorted_string}")

# Save the dataset to a file
with open('sorting_dataset.txt', 'w') as f:
    for line in data:
        f.write(line + "\n")

like this:
2024-02-01_09-27

@Nuclear6
Copy link
Author

Nuclear6 commented Feb 27, 2024

@gitzhangzhao
This is what I want. The training data format is quite different from the Shakespeare character set. How did you modify the training script? It looks like the vertical lines | are also predicted.

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

2 participants