Compare commits

..

No commits in common. "32ae109f661ff4d7453aaa36c6a8d6f7e08f2962" and "5486763fc978d7a52974b91b80b30a3df703e144" have entirely different histories.

10 changed files with 13 additions and 34 deletions

View File

@ -37,7 +37,7 @@ class Qwen(BaseModel):
self.max_tokens = max_tokens
self.messages = []
def ask(self, user_message: str, clear_history: bool = True, debug: bool = False) -> Optional[str]:
def ask(self, user_message: str, clear_history: bool = True) -> Optional[str]:
if clear_history:
self.messages = []
if self.system_prompt:
@ -47,9 +47,6 @@ class Qwen(BaseModel):
prompt_text = self._build_prompt()
if debug:
print(prompt_text)
inputs = self.tokenizer(prompt_text, return_tensors="pt").to(self.device)
with torch.no_grad():

View File

@ -1,27 +1,9 @@
import pandas as pd
def preprocess_test(test_solutions_path: str, test_tasks_path: str, test_tests_path: str, save_path: str) -> None:
def preprocess_test(test_solutions_path: str, test_tasks_path: str, save_path: str) -> None:
solutions_df = pd.read_excel(test_solutions_path)
tasks_df = pd.read_excel(test_tasks_path)
tests_df = pd.read_excel(test_tests_path)
preprocessed_df = solutions_df.merge(tasks_df[['id', 'description', 'author_solution']],
left_on='task_id', right_on='id', how='left')
preprocessed_df = solutions_df.merge(tasks_df[['id', 'description']], left_on='task_id', right_on='id', how='left')
preprocessed_df = preprocessed_df.merge(tests_df[['task_id', 'input', 'output']],
left_on='task_id', right_on='task_id', how='left')
preprocessed_df['input_output'] = preprocessed_df.apply(
lambda row: f"{row['input']}-{row['output']}" if pd.notna(row['input']) or pd.notna(row['output']) else "",
axis=1
)
grouped_df = preprocessed_df.groupby('id_x').agg({
'student_solution': 'first',
'description': 'first',
'author_solution': 'first',
'input_output': lambda x: '\n'.join(filter(None, x))
}).reset_index()
grouped_df = grouped_df.rename(columns={'id_x': 'id'})
grouped_df.to_excel(save_path, index=False)
preprocessed_df[['description', 'student_solution']].to_excel(save_path, index=False)

View File

@ -40,9 +40,9 @@ def generate_submit(tests_path: str, predict_func: Callable, save_path: str, use
idx = tests.index[i]
solution_row = tests.iloc[i]
input_text = f"Вводные данные:\n{solution_row['description']}\n\nКод студента:\n{solution_row['student_solution']}\n\nКод автора:\n{solution_row['author_solution']}\n\nТестовые условия:\n{solution_row['input_output']}"
input_text = f"{solution_row['description']}\n\n{solution_row['student_solution']}"
text = predict_func(input_text)
embedding = embedding2string(get_sentence_embedding(text))
submit_df.loc[i] = [solution_row['id'], text, embedding]
submit_df.loc[i] = [i, text, embedding]
submit_df.to_csv(save_path, index=False)

Binary file not shown.

View File

@ -18,7 +18,7 @@ if __name__ == "__main__":
system_prompt=system_prompt,
)
preprocess_test("data/raw/test/solutions.xlsx", "data/raw/test/tasks.xlsx", "data/raw/test/tests.xlsx", "data/processed/test.xlsx")
preprocess_test("data/raw/test/solutions.xlsx", "data/raw/test/tasks.xlsx", "data/processed/test.xlsx")
# Predict, ёмаё)
def predict(input_text: str) -> str: