MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / query_model

Function query_model

eval_general/eval_mt_bench_tgi.py:40–87  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

38 )
39
40def query_model(x):
41 question, host, port = x
42 choices = []
43 for i in range(1):
44 conv = get_conversation_template("llama-2")
45 conv.set_system_message('You are a helpful, respectful and honest assistant.')
46 turns = []
47 for j in range(len(question["turns"])):
48 qs = question["turns"][j]
49 conv.append_message(conv.roles[0], qs)
50 conv.append_message(conv.roles[1], None)
51 prompt = conv.get_prompt()
52 # print("Prompt", prompt)
53 temp = temperature_config[question["category"]]
54 try:
55 resp = requests.post(
56 url=f"http://{host}:{port}/generate",
57 json={
58 "inputs": prompt,
59 "parameters": {
60 "decoder_input_details": True,
61 "do_sample": temp > 1e-4,
62 "max_new_tokens": 4096,
63 **({"temperature": temp} if temp > 1e-4 else {})
64 }
65 },
66 )
67 try:
68 output = resp.json()['generated_text']
69 except:
70 import traceback
71 print(">>> ERROR getting 'generated_text' question ID: ", question["question_id"])
72 print(resp.json())
73 traceback.print_exc()
74 output = ""
75 output = output.strip()
76 except:
77 print(">>> ERROR question ID: ", question["question_id"])
78 print(output)
79 output = "ERROR"
80 import traceback
81 traceback.print_exc()
82
83 turns.append(output)
84 conv.messages[-1][-1] = output
85 choices.append({"index": i, "turns": turns})
86
87 return choices, question
88
89def get_model_answers(
90 model_id,

Callers

nothing calls this directly

Calls 1

get_promptMethod · 0.80

Tested by

no test coverage detected