Skip to content

Add example scripts to show how to run the model #108

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

Merged
merged 5 commits into from
Aug 14, 2024
Merged

Add example scripts to show how to run the model #108

merged 5 commits into from
Aug 14, 2024

Conversation

ashwinb
Copy link
Contributor

@ashwinb ashwinb commented Aug 14, 2024

Folks really want the llama-models repository to be self-contained. That is, they want to be able to simply run the models without needing other dependencies like llama-toolchain. See #82 for a discussion.

This PR adapts the example_*_completion.py scripts from the meta-llama/llama3/ repository so it works for llama3.1 models with the updated types.

Note that in order to run these scripts, you need to install additional dependencies not specified in requirements.txt: These are:

  • torch
  • fairscale
  • fire
  • blobfile (tiktoken's dependency which it does not specify :/)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 14, 2024
):
max_gen_len = self.model.params.max_seq_len - 1

prompt_tokens = self.tokenizer.encode(x, bos=True, eos=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prompt_tokens = self.tokenizer.encode(x, bos=True, eos=False)
prompt_tokens = self.tokenizer.encode(prompt, bos=True, eos=False)

@@ -34,7 +34,36 @@ Pre-requisites: Ensure you have `wget` installed. Then run the script: `./downlo

Remember that the links expire after 24 hours and a certain amount of downloads. You can always re-request a link if you start seeing errors such as `403: Forbidden`.

### Access to Hugging Face
## Running the models
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this blurb here to the README. cc @karpathy

@ashwinb ashwinb linked an issue Aug 14, 2024 that may be closed by this pull request
@ashwinb ashwinb merged commit 82e417d into main Aug 14, 2024
3 checks passed
@zewpo
Copy link

zewpo commented Aug 15, 2024

The example is on the right track. Great effort. Thanks.

Still it assumes some prior experience of how these llama models are used. I'd like the example to be a bit more explicit for someone with no experience with llama models. A hello world that will just work by following the instructions. After I get it working, then I can start to break it down and see what is going on inside. I think it only needs a couple small tweaks.

Some explanation, with working example, as to what to use for <CHECKPOINT_DIR> and <TOKENIZER_PATH>

As it is now, it doesn't actually provide explicit example of how to run the downloaded files! How do we actually reference the files that were just downloaded?

models/llama3_1/Meta-Llama-3.1-8B/consolidated.00.pth
models/llama3_1/Meta-Llama-3.1-8B/params.json
models/llama3_1/Meta-Llama-3.1-8B/tokenizer.model

I'm also curious that the "tokenizer.model" file is also in the api folder, as well as with the model. And was thinking that since the example is based on the files in the api folder, it seems like we might not need to reference a tokenizer model explicitly? (I'm assuming that the <TOKENIZER_PATH> needs to refer to this tokenizer.model file.) Is this correct, and/or needed for a simple hello world example?

@whatdhack
Copy link

Do not see this PR in main anymore .

@ashwinb
Copy link
Contributor Author

ashwinb commented Aug 21, 2024

@whatdhack The content just changed location? It is in models/scripts/ instead of in the llama3_1 sub-folder. The top-level README has also been updated. See https://github.com/meta-llama/llama-models?tab=readme-ov-file#running-the-models

@ashwinb ashwinb deleted the run_scripts branch February 1, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to run the model?
5 participants