Commit 8b91cbca authored by zhangwq5's avatar zhangwq5
Browse files

修改client

parent c9d4df8f
...@@ -135,44 +135,16 @@ if __name__ == "__main__": ...@@ -135,44 +135,16 @@ if __name__ == "__main__":
if thinking_part: if thinking_part:
print(f"【思考过程】: {thinking_part!r}") print(f"【思考过程】: {thinking_part!r}")
print(f"【主要回答】: {main_answer!r}") print(f"【主要回答】: {main_answer!r}")
thinking_end_tag = '</think>'
logprobs_after_thinking = []
if thinking_end_tag in full_content and rank1_logprobs:
end_char_idx = full_content.find(thinking_end_tag) + len(thinking_end_tag)
current_decoded_length = 0
for j, logprob_val in enumerate(rank1_logprobs):
raw_logprobs_data = response_data["choices"][0].get("logprobs", {}).get("content", [])
if j < len(raw_logprobs_data):
token_text_from_api = raw_logprobs_data[j].get("token", "")
current_decoded_length += len(token_text_from_api)
if current_decoded_length > end_char_idx:
logprobs_after_thinking = rank1_logprobs[j:]
break
if not logprobs_after_thinking and thinking_end_tag in full_content:
print("Warning: Could not accurately find logprobs after </think> tag. Using all logprobs.")
logprobs_after_thinking = rank1_logprobs
elif not thinking_end_tag in full_content:
logprobs_after_thinking = rank1_logprobs
else:
logprobs_after_thinking = rank1_logprobs
print("\n答案部分前10个Token的Rank 1 Logprobs:") print("\n答案部分前10个Token的Rank 1 Logprobs:")
for k, logprob_val in enumerate(logprobs_after_thinking[:10]): for k, logprob_val in enumerate(rank1_logprobs[:10]):
print(f" Step {k}: {logprob_val:.4f}") print(f" Step {k}: {logprob_val:.4f}")
results_to_save.append({ results_to_save.append({
"input": question, "input": question,
"output": main_answer, "output": main_answer,
"logprobs_of_rank1_for_the_first_10_tokens": logprobs_after_thinking[:10] "logprobs_of_rank1_for_the_first_10_tokens": rank1_logprobs[:10]
}) })
print("--------------------------------------------------") print("--------------------------------------------------")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment