deepspeedai / deepspeedai/DeepSpeedExamples

Zero shot classification inference

Open
#128 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.8k
Forks
1.1k
Avg merge
2d 16h
Merged PRs (30d)
1

Description

Hi

I need help with using deepspeed for transformers zero shot classification pipeline.

My dataset has 500K sentences and 52 labels.

I tried editing the gpt generation example but I am not sure if I did it right.

import os
import deepspeed
import torch
import transformers
from transformers import pipeline

local_rank = int(os.getenv('LOCAL_RANK', '0'))
world_size = int(os.getenv('WORLD_SIZE', '1'))
classifier = pipeline("zero-shot-classification", model="typeform/distilbert-base-uncased-mnli", device=0)



classifier.model = deepspeed.init_inference(classifier.model,
                                           mp_size=world_size,
                                           dtype=torch.float,
                                           replace_method='auto')

res =  classifier(prod_name_lst[:1000], tag_values)
if torch.distributed.get_rank() == 0:
    print(res)

Kindly help with an example.

Thanks,
Subham

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the provided Python snippet and the GPT generation example it references, then verify how the zero-shot-classification pipeline is intended to work with DeepSpeed inference. Done would be a clear, tested example for the stated dataset and label setup, but the issue does not name repository files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.