Skip to content

Refactor phi doc#37583

Merged
stevhliu merged 16 commits intohuggingface:mainfrom
JihadHammoud02:refactor-phi-doc
Apr 21, 2025
Merged

Refactor phi doc#37583
stevhliu merged 16 commits intohuggingface:mainfrom
JihadHammoud02:refactor-phi-doc

Conversation

@JihadHammoud02
Copy link
Copy Markdown
Contributor

Refactored the phi.md model card to follow the Hugging Face documentation conventions for model docs.

Reorganized the structure for consistency with other model docs (title, model overview, usage, and notes).

Included usage examples for:

pipeline (text generation)

AutoModel (text generation with AutoModelForCausal)

transformers-cli (text classification, to diversify usage)

Added general notes about the architecture and tokenizer.

What was left out:

The original documentation included:

Usage instructions for Phi-2

Flash Attention 2 integration tips

A performance graph

I didn’t include those in this version because there wasn’t a clear conventional place for them in model docs. I focused instead on making the file compliant with existing documentation structure.

If you'd like me to include the extra content from the original docs (e.g., FlashAttention setup, performance benchmarks, or Phi-2 usage), I’d be happy to revisit and integrate it in a way that fits well with the current doc style.

@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.

@github-actions github-actions Bot marked this pull request as draft April 17, 2025 14:34
@JihadHammoud02 JihadHammoud02 marked this pull request as ready for review April 17, 2025 15:51
@github-actions github-actions Bot requested a review from stevhliu April 17, 2025 15:51
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.

Thanks, great work!

Comment thread docs/source/en/model_doc/phi.md Outdated
Comment thread docs/source/en/model_doc/phi.md Outdated
Comment thread docs/source/en/model_doc/phi.md Outdated
Comment thread docs/source/en/model_doc/phi.md
Comment thread docs/source/en/model_doc/phi.md
Comment thread docs/source/en/model_doc/phi.md
Comment thread docs/source/en/model_doc/phi.md Outdated
Comment on lines +80 to +82
- This model is quite similar to `Llama` with the main difference in `PhiDecoderLayer`, where they used `PhiAttention` and `PhiMLP` layers in parallel configuration.

## PhiConfig
- The tokenizer used for this model is identical to the [CodeGenTokenizer](https://huggingface.co/docs/transformers/v4.51.3/en/model_doc/codegen#transformers.CodeGenTokenizer).
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.

I think we can remove these notes since they aren't directly related to usage and not that helpful. But we should make a note of using the model if you're using an older version of Transformers:

  • If you're using Transformers < 4.37.0.dev, set trust_remote_code=True in [~AutoModel.from_pretrained]. Otherwise, make sure you update Transformers to the latest stable version.

    code snippet demonstrating it

Comment thread docs/source/en/model_doc/phi.md Outdated
## PhiConfig
- The tokenizer used for this model is identical to the [CodeGenTokenizer](https://huggingface.co/docs/transformers/v4.51.3/en/model_doc/codegen#transformers.CodeGenTokenizer).

## PhiConfig
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.

Don't need to make any changes to the methods documented here

Comment thread docs/source/en/model_doc/phi.md Outdated
JihadHammoud02 and others added 4 commits April 18, 2025 09:48
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
@JihadHammoud02
Copy link
Copy Markdown
Contributor Author

Thanks for your return, I will work on it.

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.

Thanks again, just a few more changes and then we can merge!

Comment thread docs/source/en/model_doc/phi.md Outdated
Comment thread docs/source/en/model_doc/phi.md Outdated

[[autodoc]] PhiModel
- forward
[[autodoc]] PhiModel - forward
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.

You can revert the changes to the [[autodoc]] here, they don't need to be reformatted

Copy link
Copy Markdown
Contributor Author

@JihadHammoud02 JihadHammoud02 Apr 18, 2025

Choose a reason for hiding this comment

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

I pushed a new update, not sure if I understood correclty your last comment concerning the [[autodoc]], but I reverted the changes anw. Thanks for you guidance ! This is will be my first contribution to an open source project :)

@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.

Nice and thanks for your choosing Transformers as your first project to contribute to! 🤗

Comment thread docs/source/en/model_doc/phi.md Outdated
Comment thread docs/source/en/model_doc/phi.md Outdated
JihadHammoud02 and others added 2 commits April 19, 2025 10:42
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
@stevhliu stevhliu merged commit fee1190 into huggingface:main Apr 21, 2025
10 checks passed
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* Added documentation for phi model

* Update phi.md

* Update phi.md

* Update phi.md

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

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

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

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

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

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

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

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

* Updated model card

* Update phi.md

* Update phi.md

* Update phi.md

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

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

---------

Co-authored-by: Jihad <jihadhammoud_@hotmail.com>
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