Skip to content

chore: Update model doc for code_llama#37115

Merged
stevhliu merged 13 commits intohuggingface:mainfrom
AbhishekRP2002:model-card-update
Apr 3, 2025
Merged

chore: Update model doc for code_llama#37115
stevhliu merged 13 commits intohuggingface:mainfrom
AbhishekRP2002:model-card-update

Conversation

@AbhishekRP2002
Copy link
Copy Markdown
Contributor

@AbhishekRP2002 AbhishekRP2002 commented Mar 30, 2025

What does this PR do?

aims to handle #36979 (comment)

sub part of #36979

(36979)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@stevhliu

@github-actions github-actions Bot marked this pull request as draft March 30, 2025 12:56
@github-actions
Copy link
Copy Markdown
Contributor

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Copy Markdown
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Great job! 👏

Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md
Copy link
Copy Markdown
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Nice, just a few more comments :)

Comment thread docs/source/en/model_doc/code_llama.md
Comment thread docs/source/en/model_doc/code_llama.md Outdated
Comment thread docs/source/en/model_doc/code_llama.md Outdated
## Notes

- Infilling is only available in the 7B and 13B base models, and not in the Python, Instruct, 34B, or 70B models.
- Use the `<FILL_ME>` token where you want your input to be filled. The tokenizer splits this token to create a formatted input string that follows the [original training pattern](https://github.com/facebookresearch/codellama/blob/cb51c14ec761370ba2e2bc351374a79265d0465e/llama/generation.py#L402). This is more robust than preparing the pattern yourself.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Put the indented code example here for <FILL_ME>:

from transformers import LlamaForCausalLM, CodeLlamaTokenizer

tokenizer = CodeLlamaTokenizer.from_pretrained("meta-llama/CodeLlama-7b-hf")
model = LlamaForCausalLM.from_pretrained("meta-llama/CodeLlama-7b-hf")
PROMPT = '''def remove_non_ascii(s: str) -> str:
    """ <FILL_ME>
    return result
'''
input_ids = tokenizer(PROMPT, return_tensors="pt")["input_ids"]
generated_ids = model.generate(input_ids, max_new_tokens=128)

filling = tokenizer.batch_decode(generated_ids[:, input_ids.shape[1]:], skip_special_tokens = True)[0]
print(PROMPT.replace("<FILL_ME>", filling))

Copy link
Copy Markdown
Contributor Author

@AbhishekRP2002 AbhishekRP2002 Apr 3, 2025

Choose a reason for hiding this comment

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

Implemented the suggested changes ! Thank you for assisting. @stevhliu , please lemme know if there's anything else missed from my end.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code example here isn't indented yet. It should be formatted like below:

- some text
   
   ```py
   code snippet

Comment thread docs/source/en/model_doc/code_llama.md Outdated
Copy link
Copy Markdown
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Super close! Remember to mark as ready for review when you're done 🤗

## Notes

- Infilling is only available in the 7B and 13B base models, and not in the Python, Instruct, 34B, or 70B models.
- Use the `<FILL_ME>` token where you want your input to be filled. The tokenizer splits this token to create a formatted input string that follows the [original training pattern](https://github.com/facebookresearch/codellama/blob/cb51c14ec761370ba2e2bc351374a79265d0465e/llama/generation.py#L402). This is more robust than preparing the pattern yourself.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code example here isn't indented yet. It should be formatted like below:

- some text
   
   ```py
   code snippet

Comment thread docs/source/en/model_doc/code_llama.md Outdated
@AbhishekRP2002 AbhishekRP2002 marked this pull request as ready for review April 3, 2025 04:37
@AbhishekRP2002
Copy link
Copy Markdown
Contributor Author

AbhishekRP2002 commented Apr 3, 2025

Super close! Remember to mark as ready for review when you're done 🤗

Thank you ! marked the PR as Ready @stevhliu

@stevhliu stevhliu merged commit b552708 into huggingface:main Apr 3, 2025
10 checks passed
yuchenxie4645 pushed a commit to yuchenxie4645/transformers that referenced this pull request Apr 5, 2025
* Update code_llama.md

aims to handle huggingface#36979 (comment)

sub part of huggingface#36979

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* make changes as per code review

* chore: make the function smaller for attention mask visualizer

* chore[docs]: update code_llama.md with some more suggested changes

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* chore[docs] : Update code_llama.md with indentation changes

---------

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* Update code_llama.md

aims to handle huggingface#36979 (comment)

sub part of huggingface#36979

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* make changes as per code review

* chore: make the function smaller for attention mask visualizer

* chore[docs]: update code_llama.md with some more suggested changes

* Update docs/source/en/model_doc/code_llama.md

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* chore[docs] : Update code_llama.md with indentation changes

---------

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants