Fix logit processor bugs (#427)
This commit is contained in:
BIN
test/lang/example_image.png
Normal file
BIN
test/lang/example_image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
@@ -28,7 +28,7 @@ class TestOpenAIBackend(unittest.TestCase):
|
||||
if cls.backend is None:
|
||||
cls.backend = OpenAI("gpt-3.5-turbo-instruct")
|
||||
cls.chat_backend = OpenAI("gpt-3.5-turbo")
|
||||
cls.chat_vision_backend = OpenAI("gpt-4-vision-preview")
|
||||
cls.chat_vision_backend = OpenAI("gpt-4-turbo")
|
||||
|
||||
def test_few_shot_qa(self):
|
||||
set_default_backend(self.backend)
|
||||
@@ -88,14 +88,3 @@ if __name__ == "__main__":
|
||||
# t = TestOpenAIBackend()
|
||||
# t.setUp()
|
||||
# t.test_few_shot_qa()
|
||||
# t.test_mt_bench()
|
||||
# t.test_select()
|
||||
# t.test_decode_int()
|
||||
# t.test_decode_json()
|
||||
# t.test_expert_answer()
|
||||
# t.test_tool_use()
|
||||
# t.test_react()
|
||||
# t.test_parallel_decoding()
|
||||
# t.test_parallel_encoding()
|
||||
# t.test_image_qa()
|
||||
# t.test_stream()
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
from sglang import OpenAI, function, gen, set_default_backend
|
||||
|
||||
|
||||
@function()
|
||||
def gen_character_default(s):
|
||||
s += "Construct a character within the following format:\n"
|
||||
s += "Name: Steve Jobs.\nBirthday: February 24, 1955.\nJob: Apple CEO.\nWelcome.\n"
|
||||
s += "\nPlease generate new Name, Birthday and Job.\n"
|
||||
s += "Name:" + gen("name", stop="\n") + "\nBirthday:" + gen("birthday", stop="\n")
|
||||
s += "\nJob:" + gen("job", stop="\n") + "\nWelcome.\n"
|
||||
|
||||
|
||||
@function(api_num_spec_tokens=512)
|
||||
def gen_character_spec(s):
|
||||
s += "Construct a character within the following format:\n"
|
||||
s += "Name: Steve Jobs.\nBirthday: February 24, 1955.\nJob: Apple CEO.\nWelcome.\n"
|
||||
s += "\nPlease generate new Name, Birthday and Job.\n"
|
||||
s += "Name:" + gen("name", stop="\n") + "\nBirthday:" + gen("birthday", stop="\n")
|
||||
s += "\nJob:" + gen("job", stop="\n") + "\nWelcome.\n"
|
||||
|
||||
|
||||
@function(api_num_spec_tokens=512)
|
||||
def gen_character_no_stop(s):
|
||||
s += "Construct a character within the following format:\n"
|
||||
s += "Name: Steve Jobs.\nBirthday: February 24, 1955.\nJob: Apple CEO.\nWelcome.\n"
|
||||
s += "\nPlease generate new Name, Birthday and Job.\n"
|
||||
s += "Name:" + gen("name") + "\nBirthday:" + gen("birthday")
|
||||
s += "\nJob:" + gen("job") + "\nWelcome.\n"
|
||||
|
||||
|
||||
@function(api_num_spec_tokens=512)
|
||||
def gen_character_multi_stop(s):
|
||||
s += "Construct a character within the following format:\n"
|
||||
s += (
|
||||
"Name: Steve Jobs.###Birthday: February 24, 1955.###Job: Apple CEO.\nWelcome.\n"
|
||||
)
|
||||
s += "\nPlease generate new Name, Birthday and Job.\n"
|
||||
s += "Name:" + gen("name", stop=["\n", "###"])
|
||||
s += "###Birthday:" + gen("birthday", stop=["\n", "###"])
|
||||
s += "###Job:" + gen("job", stop=["\n", "###"]) + "\nWelcome.\n"
|
||||
|
||||
|
||||
set_default_backend(OpenAI("gpt-3.5-turbo-instruct"))
|
||||
|
||||
state = gen_character_default.run()
|
||||
print(state.text())
|
||||
|
||||
print("=" * 60)
|
||||
|
||||
state = gen_character_no_stop.run()
|
||||
|
||||
print("name###", state["name"])
|
||||
print("birthday###:", state["birthday"])
|
||||
print("job###", state["job"])
|
||||
|
||||
print("=" * 60)
|
||||
|
||||
state = gen_character_multi_stop.run()
|
||||
print(state.text())
|
||||
|
||||
print("=" * 60)
|
||||
|
||||
state = gen_character_spec.run()
|
||||
print(state.text())
|
||||
|
||||
print("name###", state["name"])
|
||||
print("birthday###", state["birthday"])
|
||||
print("job###", state["job"])
|
||||
1
test/srt/example_image.png
Symbolic link
1
test/srt/example_image.png
Symbolic link
@@ -0,0 +1 @@
|
||||
../lang/example_image.png
|
||||
@@ -3,7 +3,6 @@ Usage:
|
||||
python3 -m sglang.launch_server --model-path TinyLlama/TinyLlama-1.1B-Chat-v0.4 --port 30000
|
||||
python3 test_httpserver_decode.py
|
||||
|
||||
|
||||
Output:
|
||||
The capital of France is Paris.\nThe capital of the United States is Washington, D.C.\nThe capital of Canada is Ottawa.\nThe capital of Japan is Tokyo
|
||||
"""
|
||||
@@ -23,6 +22,7 @@ def test_decode(url, return_logprob, top_logprobs_num, return_text):
|
||||
"temperature": 0,
|
||||
"max_new_tokens": 32,
|
||||
},
|
||||
"stream": False,
|
||||
"return_logprob": return_logprob,
|
||||
"top_logprobs_num": top_logprobs_num,
|
||||
"return_text_in_logprobs": return_text,
|
||||
|
||||
@@ -26,6 +26,7 @@ def test_decode_stream(url, return_logprob, top_logprobs_num):
|
||||
"return_logprob": return_logprob,
|
||||
"top_logprobs_num": top_logprobs_num,
|
||||
"return_text_in_logprobs": True,
|
||||
"logprob_start_len": 0,
|
||||
},
|
||||
stream=True,
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ async def test_concurrent(args):
|
||||
url + "/generate",
|
||||
{
|
||||
"text": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. USER: <image>\nDescribe this picture ASSISTANT:",
|
||||
"image_data": "test_image.png",
|
||||
"image_data": "example_image.png",
|
||||
"sampling_params": {
|
||||
"temperature": 0,
|
||||
"max_new_tokens": 16,
|
||||
@@ -55,7 +55,7 @@ def test_streaming(args):
|
||||
url + "/generate",
|
||||
json={
|
||||
"text": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. USER: <image>\nDescribe this picture ASSISTANT:",
|
||||
"image_data": "test_image.png",
|
||||
"image_data": "example_image.png",
|
||||
"sampling_params": {
|
||||
"temperature": 0,
|
||||
"max_new_tokens": 128,
|
||||
|
||||
@@ -6,10 +6,10 @@ The capital of France is Paris.\nThe capital of the United States is Washington,
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--host", type=str, default="http://127.0.0.1")
|
||||
|
||||
@@ -163,7 +163,7 @@ def test_regex(args):
|
||||
regex = (
|
||||
r"""\{\n"""
|
||||
+ r""" "name": "[\w]+",\n"""
|
||||
+ r""" "population": "[\w\d\s]+"\n"""
|
||||
+ r""" "population": [\w\d\s]+\n"""
|
||||
+ r"""\}"""
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user