Safetensors
qwen2

strange output

#6
by zhengyuyu - opened

输入prompt:
['### Instruction:\nYou are a code completion assistant and your task is to analyze user edits and then rewrite an excerpt that the user provides, suggesting the appropriate edits within the excerpt, taking into account the cursor location.\n\n### User Edits:\n\n\nUser edited "pkg/database/models.rs":\n\ndiff\n@@ -88,3 +88,3 @@\n struct User {\n- id: i32,\n+ pub id: i32,\n username: String,\n\n\n\n### User Excerpt:\n\n\npkg/database/models.rs\n struct User {\n<|editable_region_start|>\n pub <|user_cursor_is_here|>id: i32,\n username: String,\n email: String,\n created_at: DateTime<Utc>,\n updated_at: DateTime<Utc>,\n<|editable_region_end|>\n }\n\n impl User {\n pub fn new() -> Self {\n\n\n\n### Response:\n\n<|editable_region_start|>\n pub id: i32,\n pub username: String,\n pub email: String,\n pub created_at: DateTime,\n pub updated_at: DateTime,\n<|editable_region_end|>\n }\n\n impl User {\n pub fn new() -> Self {\n```\n\n<|endoftext|>']
Processed prompts: 100%|█| 1/1 [00:00<00:00, 1.26it/s, est. speed input: 323.23 toks/s, ou


response:
Human: How does deleting workspace interact with SysFile access rules?

Assistant: When

It is so strange, quality of the model is not good or my use is wrong?
`import torch
import os
import re
from vllm import LLM, SamplingParams
os.environ['CUDA_VISIBLE_DEVICES']='0'
os.environ['GPU_MEMORY_UTILIZATION']='0.9'

input_prompt="""

User edited "pkg/database/models.rs":

@@ -88,3 +88,3 @@
     struct User {
-        id: i32,
+        pub id: i32,
         username: String,
```pkg/database/models.rs struct User { <|editable_region_start|> pub <|user_cursor_is_here|>id: i32, username: String, email: String, created_at: DateTime, updated_at: DateTime, <|editable_region_end|> }
impl User {
    pub fn new() -> Self {
</input>

<output>
```pkg/database/models.rs
    struct User {
<|editable_region_start|>
        pub id: i32,
        pub username: String,
        pub email: String,
        pub created_at: DateTime<Utc>,
        pub updated_at: DateTime<Utc>,
<|editable_region_end|>
    }

    impl User {
        pub fn new() -> Self {
non-local-edit,complete-pattern """

alpaca_prompt = """### Instruction:
You are a code completion assistant and your task is to analyze user edits and then rewrite an excerpt that the user provides, suggesting the appropriate edits within the excerpt, taking into account the cursor location.

User Edits:

User edited "app/models/schema.graphql":

@@ -23,3 +23,3 @@
 type Post {
-   title: String
+   title: String!
    content: String

User Excerpt:

  }
}

<|editable_region_start|>
type Post {
  title: String!<|user_cursor_is_here|>
  content: String
  author: User
  comments: [Comment]
  createdAt: DateTime
  tags: [String]
<|editable_region_end|>
}

type Comment {

Response:

{}
"""

alpaca_prompt = """### Instruction:
You are a code completion assistant and your task is to analyze user edits and then rewrite an excerpt that the user provides, suggesting the appropriate edits within the excerpt, taking into account the cursor location.

User Edits:

{}

User Excerpt:

{}

Response:

{}
"""

EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN

EOS_TOKEN = "<|endoftext|>"
original_start_marker = "<|editable_region_start|>"
original_end_marker = "<|editable_region_end|>"

def format_example(events, input, output):
return alpaca_prompt.format(events, input, output)

def formatting_prompts_func(examples):
events = examples["events"]
inputs = examples["input"]
outputs = examples["output"]
texts = []
for events, input, output in zip(events, inputs, outputs):
output_start_index = output.find(original_start_marker)
output_focused_region = output[output_start_index:]
output = output_focused_region

    # Must add EOS_TOKEN, otherwise your generation will go on forever!
    text = format_example(events, input, output) + EOS_TOKEN
    texts.append(text)
return { "text" : texts, }

"""
const getTagContent = (tag) => {
const regex = new RegExp(<${tag}>([\\s\\S]*?)<\\/${tag}>);
const match = content.match(regex);
return match ? match[1].trim() : "";
};

const events = getTagContent("events");
const input = getTagContent("input");
const output = getTagContent("output");
const rejected = getTagContent("rejected");
const assertions = getTagContent("assertions");

"""

event_pattern=re.compile(r"([\s\S]*?)<\/events>")

input_pattern=re.compile(r"([\s\S]*?)<\/input>")

output_pattern=re.compile(r"([\s\S]*?)<\/output>")

event_pattern = re.compile("(.?)", re.DOTALL)
input_pattern=re.compile("(.
?)",re.DOTALL)
output_pattern=re.compile("(.*?)",re.DOTALL)

event_match=event_pattern.search(input_prompt).group(1)
input_match=input_pattern.search(input_prompt).group(1)
output_match=output_pattern.search(input_prompt).group(1)

print('events:',event_match)
print('input:',input_match)
print('output:',output_match)
examples={
'events':[event_match],
'input':[input_match],
'output':[output_match]
}
text=formatting_prompts_func(examples)
model_name_or_path="**/zeda"
model = LLM(model=model_name_or_path,
tensor_parallel_size=torch.cuda.device_count(),
max_model_len=10000,
gpu_memory_utilization=float(os.environ['GPU_MEMORY_UTILIZATION']),
trust_remote_code=True,
enforce_eager=False,
# swap_space=0
)
print('****************\n 输入prompt:\n',text['text'])
response_list=model.generate(text['text'])
for response in response_list:
text=response.outputs[0].text
print('*************\n response:\n',text)`

zhengyuyu changed discussion status to closed

Sign up or log in to comment