10000 Updated the Model docs - for the ALIGN model by 1himan · Pull Request #38072 · huggingface/transformers · GitHub
[go: up one dir, main page]

Skip to content

Updated the Model docs - for the ALIGN model #38072

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 12 commits into from
May 28, 2025
Merged

Conversation

1himan
Copy link
Contributor
@1himan 1himan commented May 11, 2025

What does this PR do?

Fixes # (issue)

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.

@github-actions github-actions bot marked this pull request as draft May 11, 2025 22:04
Copy link
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.

@1himan
Copy link
Contributor Author
1himan commented May 11, 2025

hey @stevhliu can you help me with this one? this is my first time making a PR here 🤗. Hit me up if you need me to make any further updates in the docs.

@1himan 1himan marked this pull request as ready for review May 12, 2025 03:09
@github-actions github-actions bot requested a review from stevhliu May 12, 2025 03:10
Copy link
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.

Congrats on your first PR to Hugging Face and really nice work! 🤗

- Pre-trained on 1.8B image-text pairs from the web

```py
# Example of using ALIGN for image-text similarity
Copy link
Member

Choose a reason for hiding this comment

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

Indent this code example under the list item above

import torch
import requests
from PIL import Image
from transformers import AlignProcessor, AlignModel

processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
model = AlignModel.from_pretrained("kakaobrain/align-base").to("cuda")

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
image = requests.get(url, stream=True)
inputs = Image.open(image.raw).convert("RGB")
texts = ["a photo of a cat", "a photo of a dog"]

inputs = processor(images=inputs, text=texts, return_tensors="pt").to("cuda")

with torch.no_grad():
    outputs = model(**inputs)

image_embeds = outputs.image_embeds
text_embeds = outputs.text_embeds

image_embeds = image_embeds / image_embeds.norm(dim=1, keepdim=True)
text_embeds = text_embeds / text_embeds.norm(dim=1, keepdim=True)

similarity_scores = torch.matmul(text_embeds, image_embeds.T)
print("Similarity scores:", similarity_scores)

probs = torch.nn.functional.softmax(similarity_scores, dim=0)
print("Probabilities:", probs)

most_similar_idx = similarity_scores.argmax().item()
print(f"Most similar text: '{texts[most_similar_idx]}'")

Copy link
Member

Choose a reason for hiding this comment

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

Not resolved yet


## AlignConfig

[[autodoc]] AlignConfig
- from_text_vision_configs
[[autodoc]] AlignConfig - from_text_vision_configs
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to format the [[autodoc] here, so you can revert these changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

Copy link
Member

Choose a reason for hiding this comment

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

Changes to the [[autodoc]] haven't been reverted yet

Copy link
Member

Choose a reason for hiding this comment

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

This still hasn't been reverted yet. It should look like:

[[autodoc]] AlignConfig
    - from_text_vision_configs

1himan and others added 4 commits May 23, 2025 07:16
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
@1himan
Copy link
Contributor Author
1himan commented May 23, 2025

Anything else? :)

1himan and others added 2 commits May 24, 2025 12:37
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
@1himan
Copy link
Contributor Author
1himan commented May 24, 2025

Now yeah, I think it looks good.

Copy link
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.

Still a few minor formatting things!


## AlignConfig

[[autodoc]] AlignConfig
- from_text_vision_configs
[[autodoc]] AlignConfig - from_text_vision_configs
Copy link
Member

Choose a reason for hiding this comment

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

This still hasn't been reverted yet. It should look like:

[[autodoc]] AlignConfig
    - from_text_vision_configs

1himan and others added 4 commits May 28, 2025 11:56
@HuggingFaceDocBuilderDev

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
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!

@stevhliu stevhliu merged commit c9fcbd5 into huggingface:main May 28, 2025
10 checks passed
@1himan 1himan deleted the docs/align branch May 29, 2025 09:13
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
0