Giter Site home page Giter Site logo

Comments (3)

JianxinMa avatar JianxinMa commented on June 14, 2024

如 README 所说:

NOTE: Neither the vLLM nor SGLang APIs currently offer built-in support for function calling. If you require function calling capabilities, please refer to the Qwen-Agent project, which provides a wrapper around these APIs to support function calling.

在 Qwen-Agent 项目有提供一层 wrapper 来提供函数调用

from qwen1.5.

zhiguoxu avatar zhiguoxu commented on June 14, 2024

那我应该如何防止特殊token注入呢?

from qwen1.5.

jklj077 avatar jklj077 commented on June 14, 2024

From what I understand, <|im_start|> and <|im_end|> does not prevent the misuse of function calls (injection of function calls that should not be generated) nor does it protect the running of arbitrary code (in terms of defintion of functions). In that sense, you should always run the model in a secure, isolated environment.

To prevent the injection of special tokens from user inputs, you could try:

>>> from transformers import AutoTokenizer

>>> tokenizer = AutoTokenizer.from_pretrained(path_to_model, split_special_tokens=True, use_fast=False)

>>> tokenizer("<|im_start|>This is a test.<|im_end|><|endoftext|>") # safe tokenization
{'input_ids': [27, 91, 318, 4906, 91, 29, 1986, 374, 264, 1273, 15757, 91, 318, 6213, 91, 1784, 91, 8691, 723, 427, 91, 29], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}

>>> tokenizer.convert_tokens_to_ids("<|im_start|>") # get special token ids manually
151644

>>> tokenizer.convert_tokens_to_ids("<|im_end|>") # get special token ids manually
151645

You could then manually construct the model inputs with the chatml template.

from qwen1.5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.