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

Support phi model on feature-extraction, text-classification, token-classification tasks #509

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

JingyaHuang
Copy link
Collaborator

@JingyaHuang JingyaHuang commented Mar 9, 2024

What does this PR do?

Support phi family models on feature-extraction, text-classification, token-classification tasks.

Fixes #508


Export

optimum-cli export neuron --model microsoft/phi-1_5 --sequence_length 64 --batch_size 1 --task text-classification phi1_5/

Inference

from transformers import AutoTokenizer
from optimum.neuron import NeuronModelForSequenceClassification

model_id = "phi1_5/"
text = "This is a sample output"
tokenizer = AutoTokenizer.from_pretrained(model_id)
neuron_model = NeuronModelForSequenceClassification.from_pretrained(model_id)
inputs = tokenizer(text, return_tensors="pt")
neuron_outputs = neuron_model(**inputs)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

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

@JingyaHuang
Copy link
Collaborator Author

Update styling tool and fix style following this:

Run source venv/bin/activate
  source venv/bin/activate
  ruff .
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.8.18/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.18/x64/lib
warning: `ruff <path>` is deprecated. Use `ruff check <path>` instead.
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'isort' -> 'lint.isort'
  - 'per-file-ignores' -> 'lint.per-file-ignores'
text-generation-inference/server/text_generation_server/model.py:1[2](https://github.com/huggingface/optimum-neuron/actions/runs/8216181267/job/22470453310?pr=509#step:7:2)9:[5](https://github.com/huggingface/optimum-neuron/actions/runs/8216181267/job/22470453310?pr=509#step:7:5): E[7](https://github.com/huggingface/optimum-neuron/actions/runs/8216181267/job/22470453310?pr=509#step:7:7)22 Do not use bare `except`
Found 1 error.

Copy link
Collaborator

@dacorvo dacorvo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks !

@JingyaHuang JingyaHuang merged commit b140cd5 into main Mar 11, 2024
13 checks passed
@JingyaHuang JingyaHuang deleted the support-phi branch March 11, 2024 08:21
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.

Add support for phi-2
3 participants