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

Fix typo in LocalAgent #24736

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

jamartin9
Copy link
Contributor

@jamartin9 jamartin9 commented Jul 10, 2023

What does this PR do?

This PR fixes a typo in LocalAgent.

Crash Log:

Traceback (most recent call last):
  File "/gnu/git/hf-agent/./agent.py", line 18, in <module>
    agent.run(prompt)
  File "/gnu/git/hf-agent/venv/lib/python3.11/site-packages/transformers/tools/agents.py", line 335, in run
    result = self.generate_one(prompt, stop=["Task:"])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gnu/git/hf-agent/venv/lib/python3.11/site-packages/transformers/tools/agents.py", line 731, in generate_one
    encoded_inputs = self.tokenizer(prompt, return_tensors="pt").to(self._model_device)
                                                                    ^^^^^^^^^^^^^^^^^^
  File "/gnu/git/hf-agent/venv/lib/python3.11/site-packages/transformers/tools/agents.py", line 727, in _model_device
    for param in self.mode.parameters():
                 ^^^^^^^^^
AttributeError: 'LocalAgent' object has no attribute 'mode'. Did you mean: 'model'?

Code that triggered the above crash

#!/usr/bin/env python3

import torch
from transformers import LocalAgent

model = "bigcode/tiny_starcoder_py"

agent = LocalAgent.from_pretrained(model, torch_dtype=torch.bfloat16)

text = "Sally sold sea shells down by the seashore."

prompt = "Summarize the text given in the variable `text` and read it out loud."

agent.run(prompt, text=text)

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.

@sgugger

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@sgugger sgugger merged commit 2489e38 into huggingface:main Jul 11, 2023
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Lorenzobattistela pushed a commit to Lorenzobattistela/transformers that referenced this pull request Jul 13, 2023
blbadger pushed a commit to blbadger/transformers that referenced this pull request Nov 8, 2023
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