---
title: instagger_qwen1_8B
canonical_url: "https://www.modelscope.cn/models/lukeminglkm/instagger_qwen1_8B"
md_url: "https://www.modelscope.cn/models/lukeminglkm/instagger_qwen1_8B.md"
repository: lukeminglkm/instagger_qwen1_8B
chinese_name: "InsTag指令打标工具千问1.8B版本"
last_updated: 2023-12-22
license: "Apache License 2.0"
pipeline_tag: universal-information-extraction
tasks:
  - universal-information-extraction
model_type:
  - qwen
architectures:
  - QWenLMHeadModel
library_name:
  - pytorch
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 9068
stars: 5
---

# instagger_qwen1_8B

> instagger_qwen1_8B - lukeminglkm 在 ModelScope 开源的模型。InsTag基于Qwen-18B训练的中英文指令标签标注器

lukeminglkm/instagger_qwen1_8B 是 ModelScope 魔搭社区上的universal-information-extraction模型，采用 Apache License 2.0 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: lukeminglkm/instagger_qwen1_8B
- **License**: Apache License 2.0
- **Tasks**: universal-information-extraction
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 9068
- **Stars**: 5
- **Last updated**: 2023-12-22

Source: https://www.modelscope.cn/models/lukeminglkm/instagger_qwen1_8B

---

# InsTag基于Qwen-1_8B训练的中英文指令标签标注器

## 使用方法

参考通义千问官方repo使用vllm+fastchat进行推理，离线推理方法示例如下：

```
from vllm import LLM, SamplingParams
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import load_model, get_conversation_template
import torch

model_id = "qwen-1p8b-tagger"
model_path = "/path/to/model/"

# Load model with vLLM
model = LLM(model=model_path, trust_remote_code=True)
# Setting greedy decoding with temperature=0
sampling_params = SamplingParams(temperature=0, max_tokens=512)


torch.manual_seed(0)
prompts = []
conv = get_conversation_template(model_id)
conv.append_message(conv.roles[0], "hi who are you")
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()
prompts.append(prompt)

outputs = model.generate(prompts, sampling_params)
for output in outputs:
    output_ids = output.outputs[0].token_ids

    # be consistent with the template's stop_token_ids
    if conv.stop_token_ids:
        stop_token_ids_index = [
            i
            for i, id in enumerate(output_ids)
            if id in conv.stop_token_ids
        ]
        if len(stop_token_ids_index) > 0:
            output_ids = output_ids[: stop_token_ids_index[0]]

    output = model.get_tokenizer().decode(
        output_ids,
        spaces_between_special_tokens=False,
    )
    if conv.stop_str and output.find(conv.stop_str) > 0:
        output = output[: output.find(conv.stop_str)]
    for special_token in model.get_tokenizer().special_tokens_map.values():
        if isinstance(special_token, list):
            for special_tok in special_token:
                output = output.replace(special_tok, "")
        else:
            output = output.replace(special_token, "")
    output = output.strip()
    print(output)
```


#### Clone with HTTP
```bash
 git clone https://www.modelscope.cn/lukeminglkm/instagger_qwen1_8B.git
```
