Git Product home page Git Product logo

Comments (7)

zhuifengzl avatar zhuifengzl commented on May 28, 2024

我用的模型是RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth,也转换过RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096-fp16.bin,都测试过,即使修改代码backend-python\routes\completion.py下的设置,重启程序也不生效,是这个模型不支持吗
class ChatCompletionBody(ModelConfigBody):
messages: Union[List[Message], None]
model: Union[str, None] = "rwkv"
stream: bool = False
stop: Union[str, List[str], None] = default_stop
user_name: Union[str, None] = Field(
None, description="Internal user name", min_length=1
)
assistant_name: Union[str, None] = Field(
None, description="Internal assistant name", min_length=1
)
system_name: Union[str, None] = Field(
None, description="Internal system name", min_length=1
)
presystem: bool = Field(
True, description="Whether to insert default system prompt at the beginning"
)

model_config = {
    "json_schema_extra": {
        "example": {
            "messages": [
                {"role": Role.User.value, "content": "hello", "raw": False}
            ],
            "model": "rwkv",
            "stream": False,
            "stop": None,
            "user_name": None,
            "assistant_name": None,
            "system_name": None,
            "presystem": True,
            "max_tokens": 1000,
            "temperature": 1,
            "top_p": 0.3,
            "presence_penalty": 0,
            "frequency_penalty": 1,
        }
    }
}

class CompletionBody(ModelConfigBody):
prompt: Union[str, List[str], None]
model: Union[str, None] = "rwkv"
stream: bool = False
stop: Union[str, List[str], None] = None

model_config = {
    "json_schema_extra": {
        "example": {
            "prompt": "The following is an epic science fiction masterpiece that is immortalized, "
            + "with delicate descriptions and grand depictions of interstellar civilization wars.\nChapter 1.\n",
            "model": "rwkv",
            "stream": False,
            "stop": None,
            "max_tokens": 100,
            "temperature": 1,
            "top_p": 0.3,
            "presence_penalty": 0,
            "frequency_penalty": 1,
        }
    }
}

from rwkv-runner.

zhuifengzl avatar zhuifengzl commented on May 28, 2024

好像每次程序都会重置修改的参数,那个流式参数是不能修改吗

from rwkv-runner.

BlinkDL avatar BlinkDL commented on May 28, 2024

模型用 https://huggingface.co/BlinkDL/rwkv-6-world/blob/main/RWKV-x060-World-3B-v2.1-20240417-ctx4096.pth

另外显存多少?显存够就解码参数选 cuda fp16

from rwkv-runner.

zhuifengzl avatar zhuifengzl commented on May 28, 2024

12g的显存

from rwkv-runner.

josStorer avatar josStorer commented on May 28, 2024

@zhuifengzl 参数是调用api的时候传递的, 可以改, 你不用去改源码, 载入模型的时候, 拉满"载入显存层数"

from rwkv-runner.

zhuifengzl avatar zhuifengzl commented on May 28, 2024

好的,我试试,感谢哈

from rwkv-runner.

zhuifengzl avatar zhuifengzl commented on May 28, 2024

public struct LocalSendData
{
public string model;
public bool stream;
public bool presystem;
public int max_tokens;
public double temperature;
public double top_p;
public double presence_penalty;
public double frequency_penalty;
public List messages;
}
public struct LocalSendDataMes
{
public string role;
public string content;
public bool raw;
}
public static IEnumerator RequestGPTSegmentation_local(string content, Action<string, bool> callback)
{
string postData = "";
//Debug.Log("postData");

        LocalSendData local = new LocalSendData();
        local.model = "rwkv";
        local.stream = false;
        local.presystem = true;
        local.max_tokens = 10000;
        local.temperature = 1.2;
        local.top_p = 0.5;
        local.presence_penalty = 0.4;
        local.frequency_penalty = 0.4;
        local.messages = new List<LocalSendDataMes>();
        local.messages.Add(new LocalSendDataMes() { role = "user", content = content, raw = false });
        postData = JsonMapper.ToJson(local);

        Debug.Log(postData);

        //Debug.Log(ConfigExcelMgr.instance.excelData.str_localPath);
    
        using (var request = new UnityWebRequest(ConfigExcelMgr.instance.excelData.str_localPath + "/chat/completions", "POST"))
        //using (var request = new UnityWebRequest("http://192.168.0.105:8000/chat/completions", "POST"))
        {
            request.SetRequestHeader("Accept", "application/json, text/plain, */*");
            request.SetRequestHeader("Content-Type", "application/json");                

            request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(postData));

            request.downloadHandler = new DownloadHandlerBuffer();

            UnityWebRequestAsyncOperation asyncOp = request.SendWebRequest();

            int dataIndex = 0;

            string text = "";

            while (!asyncOp.isDone)
            {
                //Disponse(false);
                yield return wait_internal;
            }
            

            if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
            {
                Debug.LogError("Error: " + request.error);
            }

            //Debug.Log(request.downloadHandler.text);
            if (request.downloadHandler.text != null)
            {

                string jsondata = request.downloadHandler.text;
                JsonData jd = JsonMapper.ToObject(jsondata);
                //string js_finish_reason = (string)jd["choices"]["finish_reason"];

                string js_text = (string)jd["choices"][0]["message"]["content"];

                callback?.Invoke(js_text, true);
            }

这是写的代码,我不太懂,帮忙看看应该怎么修改,才能提高接口的回答速度呢

from rwkv-runner.

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.