modelscope / modelscope/ms-swift

请问seq_cls分类任务lora训练如何加速推理

Open
#9,576 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question stale
Dominant language
Python
Stars
15.7k
Forks
1.7k
Avg merge
1d 16h
Merged PRs (30d)
136

Description

Checklist / 检查清单
  • I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。
Question Description / 问题描述

目前的推理代码如下,请问有支持batch推理或者vllm的batch推理嘛

import os
import json
from swift import BaseArguments, InferRequest, TransformersEngine, get_template
from tqdm import tqdm

adapter_path = 'xxx'
args = BaseArguments.from_pretrained(adapter_path)
engine = TransformersEngine(args.model, adapters=[adapter_path])
template = get_template(
    engine.processor, args.system, template_type=args.template, use_chat_template=args.use_chat_template)
engine.template = template
with open('xxx', 'r') as f,open('xxx', 'w') as f1:
    for line in tqdm(f):
        data = json.loads(line)
        data['messages'].append({"role": "assistant", "content": "<think>\n\n</think>\n\n"})
        infer_request = InferRequest(data["messages"])
        resp_list = engine.infer([infer_request])
        response: int = resp_list[0].choices[0].message.content
        data['predict'] = response  
        f1.write(json.dumps(data, ensure_ascii=False) + '\n')
        f1.flush()

Contributor guide

Open the contributing guide

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 with the shown TransformersEngine and engine.infer([infer_request]) call, then inspect the repository's inference entry points and documentation for batch inputs and vLLM support. Confirm how seq_cls LoRA requests are handled and define done as a documented, working faster inference path for the provided JSONL loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.