"],"text/html":["\n"," \n"," \n","
\n"," [1600/1600 1:41:39, Epoch 0/1]\n","
\n"," \n"," \n"," \n"," Step | \n"," Training Loss | \n","
\n"," \n"," \n"," \n"," 100 | \n"," 1.185700 | \n","
\n"," \n"," 200 | \n"," 0.864200 | \n","
\n"," \n"," 300 | \n"," 0.819000 | \n","
\n"," \n"," 400 | \n"," 0.793300 | \n","
\n"," \n"," 500 | \n"," 0.794500 | \n","
\n"," \n"," 600 | \n"," 0.781300 | \n","
\n"," \n"," 700 | \n"," 0.812400 | \n","
\n"," \n"," 800 | \n"," 0.749900 | \n","
\n"," \n"," 900 | \n"," 0.784800 | \n","
\n"," \n"," 1000 | \n"," 0.736300 | \n","
\n"," \n"," 1100 | \n"," 0.763900 | \n","
\n"," \n"," 1200 | \n"," 0.783400 | \n","
\n"," \n"," 1300 | \n"," 0.735200 | \n","
\n"," \n"," 1400 | \n"," 0.760800 | \n","
\n"," \n"," 1500 | \n"," 0.778000 | \n","
\n"," \n"," 1600 | \n"," 0.757700 | \n","
\n"," \n","
"]},"metadata":{}},{"output_type":"execute_result","data":{"text/plain":["TrainOutput(global_step=1600, training_loss=0.8062745618820191, metrics={'train_runtime': 6123.2885, 'train_samples_per_second': 0.523, 'train_steps_per_second': 0.261, 'total_flos': 6.53458201903104e+16, 'train_loss': 0.8062745618820191, 'epoch': 0.02})"]},"metadata":{},"execution_count":27}],"source":["trainer.train()\n"],"id":"tFeEyBJnCi0C"},{"cell_type":"markdown","metadata":{"id":"76sRe172fGlm"},"source":["구글 코랩 T-4 GPU: 1:37:34 예상시간\n","- 총 1,600 스텝 필요\n","- 하지만 이보다 일찍 종료됨 약 900번 미만 스텝에서 종료됨\n","\n","시퀀스 길이 512의 경우\n","- 14.4 G / 15.0 G 사용\n","- 메모리 오버플로우 발생시 512보다 줄일 것"],"id":"76sRe172fGlm"},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":35},"executionInfo":{"elapsed":326,"status":"ok","timestamp":1702210266465,"user":{"displayName":"장예린","userId":"14823696343626614035"},"user_tz":-540},"id":"3Y4FQSyRghQt","outputId":"20a0d171-932c-452f-cb3b-9fb09d1ef0cb"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["'/gdrive/MyDrive/nlp/lora-llama-2-7b-nsmc'"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"string"}},"metadata":{},"execution_count":28}],"source":["script_args.training_args.output_dir"],"id":"3Y4FQSyRghQt"},{"cell_type":"code","execution_count":null,"metadata":{"id":"49f05450-da2a-4edd-9db2-63836a0ec73a"},"outputs":[],"source":["trainer.save_model(script_args.training_args.output_dir)"],"id":"49f05450-da2a-4edd-9db2-63836a0ec73a"},{"cell_type":"markdown","metadata":{"id":"652f307e-e1d7-43ae-b083-dba2d94c2296"},"source":["# 추론 테스트"],"id":"652f307e-e1d7-43ae-b083-dba2d94c2296"},{"cell_type":"code","execution_count":null,"metadata":{"id":"ea8a1fea-7499-4386-9dea-0509110f61af"},"outputs":[],"source":["from transformers import pipeline, TextStreamer"],"id":"ea8a1fea-7499-4386-9dea-0509110f61af"},{"cell_type":"code","execution_count":null,"metadata":{"id":"52626888-1f6e-46b6-a8dd-836622149ff5"},"outputs":[],"source":["instruction_prompt_template = \"\"\"###System;다음은 네이버 영화 리뷰들을 모아놓은 문장이다. 이를 분석하여 사용자가 작성한 영화 리뷰의 감정을 긍정 또는 부정으로 예측하라.\n","\n","### 리뷰 내용: {0} ### 분석 결과:\n","\"\"\"\n","\n","prompt_template = \"\"\"###System;{System}\n","###User;{User}\n","###Midm;\"\"\"\n","\n","default_system_msg = (\n"," \"너는 먼저 사용자가 작성한 영화 리뷰의 감정을 분석하는 에이전트이다. 이로부터 긍정 또는 부정을 판단해야 한다.\"\n",")"],"id":"52626888-1f6e-46b6-a8dd-836622149ff5"},{"cell_type":"code","execution_count":null,"metadata":{"id":"1919cf1f-482e-4185-9d06-e3cea1918416"},"outputs":[],"source":["def wrapper_generate(model, input_prompt):\n"," data = tokenizer(input_prompt, return_tensors=\"pt\")\n"," streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)\n"," input_ids = data.input_ids[..., :-1]\n"," with torch.no_grad():\n"," pred = model.generate(\n"," input_ids=input_ids.cuda(),\n"," #input_ids = input_ids.to('cuda'),\n"," streamer=streamer,\n"," use_cache=True,\n"," max_new_tokens=float('inf'),\n"," temperature=0.5\n"," )\n"," decoded_text = tokenizer.batch_decode(pred, skip_special_tokens=True)\n"," return (decoded_text[0][len(input_prompt):])"],"id":"1919cf1f-482e-4185-9d06-e3cea1918416"},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":1537373,"status":"ok","timestamp":1701343970452,"user":{"displayName":"장예린","userId":"14823696343626614035"},"user_tz":-540},"id":"Lxptc3T1kDSO","outputId":"1604b12c-871e-4d41-f739-b7e54ad03091"},"outputs":[{"name":"stdout","output_type":"stream","text":[";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n"]}],"source":["eval_dic = {i: wrapper_generate(model=base_model, input_prompt=prompt_template.format(System=default_system_msg, User=example[\"document\"]))for i, example in enumerate(valid_dataset)}"],"id":"Lxptc3T1kDSO"},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":398,"status":"ok","timestamp":1701265256607,"user":{"displayName":"장예린","userId":"08326973126538993419"},"user_tz":-540},"id":"fefd04ba-2ed8-4f84-bdd0-86d52b3f39f6","outputId":"642ae37a-4c0c-4385-f75c-20a8f0957242"},"outputs":[{"name":"stdout","output_type":"stream","text":["부정\n"]}],"source":["print(eval_dic[8])"],"id":"fefd04ba-2ed8-4f84-bdd0-86d52b3f39f6"},{"cell_type":"markdown","metadata":{"id":"3f471e3a-723b-4df5-aa72-46f571f6bab6"},"source":["# 미세튜닝된 모델 로딩 후 테스트"],"id":"3f471e3a-723b-4df5-aa72-46f571f6bab6"},{"cell_type":"code","source":["from transformers import pipeline, TextStreamer"],"metadata":{"id":"U5AcpecYRRlC","executionInfo":{"status":"ok","timestamp":1702211592479,"user_tz":-540,"elapsed":1132,"user":{"displayName":"장예린","userId":"08326973126538993419"}}},"id":"U5AcpecYRRlC","execution_count":10,"outputs":[]},{"cell_type":"markdown","source":["**프롬프트 정의**\n","\n","\n","> 사용자 영화 리뷰의 예측을 생성하기 위한 프롬프트 정의함.\n","\n"],"metadata":{"id":"qVr_AMtJa-AF"},"id":"qVr_AMtJa-AF"},{"cell_type":"code","source":["instruction_prompt_template = \"\"\"###System;다음은 네이버 영화 리뷰들을 모아놓은 문장이다. 이를 분석하여 사용자가 작성한 영화 리뷰의 감정을 긍정 또는 부정으로 예측하라.\n","\n","### 리뷰 내용: {0} ### 분석 결과:\n","\"\"\"\n","\n","prompt_template = \"\"\"###System;{System}\n","###User;{User}\n","###Midm;\"\"\"\n","\n","default_system_msg = (\n"," \"너는 사용자가 작성한 리뷰의 긍정 또는 부정을 판단해야 한다.\"\n",")"],"metadata":{"id":"nzxPwBS5RY1P","executionInfo":{"status":"ok","timestamp":1702211926639,"user_tz":-540,"elapsed":295,"user":{"displayName":"장예린","userId":"08326973126538993419"}}},"id":"nzxPwBS5RY1P","execution_count":11,"outputs":[]},{"cell_type":"markdown","source":["**wrapper_generate 함수**\n","\n","\n","> 사용자 영화 리뷰에 대한 입력 프롬프트 생성.\n","\n"],"metadata":{"id":"zkWiQd1NaFZz"},"id":"zkWiQd1NaFZz"},{"cell_type":"code","source":["def wrapper_generate(model, input_prompt):\n"," data = tokenizer(input_prompt, return_tensors=\"pt\")\n"," streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)\n"," input_ids = data.input_ids[..., :-1]\n"," with torch.no_grad():\n"," pred = model.generate(\n"," input_ids=input_ids.cuda(),\n"," streamer=streamer,\n"," use_cache=True,\n"," max_new_tokens=float('inf'),\n"," temperature=0.5\n"," )\n"," decoded_text = tokenizer.batch_decode(pred, skip_special_tokens=True)\n"," return (decoded_text[0][len(input_prompt):])"],"metadata":{"id":"nPNJNH5TRcYQ","executionInfo":{"status":"ok","timestamp":1702211928380,"user_tz":-540,"elapsed":275,"user":{"displayName":"장예린","userId":"08326973126538993419"}}},"id":"nPNJNH5TRcYQ","execution_count":12,"outputs":[]},{"cell_type":"markdown","source":["**양자화 설정**\n","\n","\n","> 4비트로 양자화함.\n","\n"],"metadata":{"id":"XwPG_xZ3aXaL"},"id":"XwPG_xZ3aXaL"},{"cell_type":"code","execution_count":13,"metadata":{"id":"a43bdd07-7555-42b2-9888-a614afec892f","executionInfo":{"status":"ok","timestamp":1702211929706,"user_tz":-540,"elapsed":3,"user":{"displayName":"장예린","userId":"08326973126538993419"}}},"outputs":[],"source":["bnb_config = BitsAndBytesConfig(\n"," load_in_4bit=True,\n"," bnb_4bit_quant_type=\"nf4\",\n"," bnb_4bit_compute_dtype=torch.bfloat16,\n",")"],"id":"a43bdd07-7555-42b2-9888-a614afec892f"},{"cell_type":"markdown","source":["**모델 불러오기**\n","\n","> 미세튜닝된 모델을 4비트로 양자화하여 저장된 모델을 가져옴.\n","\n"],"metadata":{"id":"m2z3YCa1aoP4"},"id":"m2z3YCa1aoP4"},{"cell_type":"code","execution_count":14,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":409,"referenced_widgets":["2ca2aaecc8a840efaefc75732edf3150","b60614fe19f74a4c9d7abb2c7ee97c60","d76c9327a76d4493b3c08b5cd4979989","90f85d3fec14447b804eaee7d811484b","93e4e15bff034bdf8df6fdc9bc59fd6c","84adda03f9f64c7e8e231ca7d5ac8fcb","9738c4b8391d4b2ca924e7103b7c73d4","4c26d3a15fb2461aabe7c479be670986","8839e1c73a784a07ab8fa33bbd897954","dc3c665e1ed640e983b4f3b7b58116ca","117ced4159a649dc985348f31e885205","335d07c3d6a2438182810737c931335e","b141ac3b5c7d4e799766746ad37fb915","1addb8ce56704a1fa0c506d2572d7383","63bc7dda6fe6447c99d179e38ef5b921","33fbcbe6f6dd42d0a29f3e2d78e86196","5399a2f7adc1403ca53ea4e9d2e36138","d345e8b24fa94a199dff0bf155ef49c3","8506eee76253473a9e2e01478086678c","144f86491529409ba69a134ba7c1ff2a","e0a713ace1154e28903e40e08cf12d6b","54aa6d61cff147b4adb1cc995c73c817","8beb1f4112db47c5be9c125ec3c82b5d","b96b38b7dcc246e4a20a996b23dc8fa3","8b6ec68913f242b3b47a353ea7383052","f5c597be9e234b60825476b532144f45","ec892629b3c848349ae98ca6fcb00602","a0081fd895fb49f9a9ebf663f81180ed","050e43be284142dcacecb3be4faa36a7","46e7e3f527964b5f87d2a4f23e0f0326","295e7e1ba7824552924b3535ffa0136d","c201a0f6e66942da9c977e4349f947c6","7e6e490a92eb4d0ab368a4f667640939","215394b9a6a04653ab03a35d0135fe5d","0da18f01a0b1451a9d0719acfe64fbfe","b8708ff795f8411d9ebaefd4762fb10b","f37abd59649542c982fd9db4fee74fc4","05c7d7ed12e14bc4a4615f1122070b6c","61a2cbfc425a4493886f32c7f0b6565f","bc85c375435c48048270fb12899f609d","3d074657a7804e79a03d485dc3ffab27","6dd22ca989c24429b42d737019be2630","19a9e7016218438785d84e622a715d42","20540ca4e72f4314b03cb8395d289180","0bfa51ca810b4caa9aa7046ba74866dc","a3d010d441c74537934bd2d4d13a8204","1d3387e9e3644e4499d71336d38c5978","15631bb8aa2f4a6f86f712e08f4c27f5","b0de8cbef5434403a67947bff1f018c7","2916ff3c45524c208e142f8b570c8569","3f012298d2fc4a38b73cf0ec84e21a69","b79cd1783d8649a094db48678b6ef89d","88f1fbd3f6a345b8897c8d41eea55099","065d3296645b48b98baf4fb2063594c6","764eec174756419bbcf4b32734e0418e","9095199ed82f4d73acadb43366781167","95461d42509743d8b6790c99bb9f1e7d","6ecc5f2ba6c841a7970a55ccf2a93d24","17b99454204344688f41f98b87580b22","97cbf25ce3e04f32a3b1e431622d946c","43931f64cb304416bde19775db56d2e3","7addecb1b5624048bef936ed1872fb69","9de7301c3c0f46908606cb6f2f769bf5","4b46186d47ef428fa52ab14e5ca27f7d","2b9a14bbf98c4254976fcce5ee212b78","e0e15b3c2c0a40d98d10f2f0618b4f2d","4d88b9b66b424d6fa7315e3b3144a6fc","5450c2bc9f9c49f09cf734cd52bdd857","915d86f6b11c474fab6fc09d871445de","a3f8fc1a8ba14f1091b3044e570aab67","374bcae18dcf42ea9fe1b99dc4ebf46d","fd7c85a5399e40ba9a3dec8aa7d5c1cc","00464cd6e834424b8e1f26b3c5c71692","f4af0a41493f4803a733eff2c188c369","239672d958de4b579e9eec9a9065324a","e8dc05eca5ce451791dc8932d828282e","3a8bf67931774be2b5d9c723cddff124"]},"id":"39db2ee4-23c8-471f-89b2-bca34964bf81","outputId":"573909e3-e6c7-4192-898f-b57c11bd8eee","executionInfo":{"status":"ok","timestamp":1702212090601,"user_tz":-540,"elapsed":159918,"user":{"displayName":"장예린","userId":"08326973126538993419"}}},"outputs":[{"output_type":"display_data","data":{"text/plain":["config.json: 0%| | 0.00/614 [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"2ca2aaecc8a840efaefc75732edf3150"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["model.safetensors.index.json: 0%| | 0.00/26.8k [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"335d07c3d6a2438182810737c931335e"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading shards: 0%| | 0/2 [00:00, ?it/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"8beb1f4112db47c5be9c125ec3c82b5d"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["model-00001-of-00002.safetensors: 0%| | 0.00/9.98G [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"215394b9a6a04653ab03a35d0135fe5d"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["model-00002-of-00002.safetensors: 0%| | 0.00/3.50G [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"0bfa51ca810b4caa9aa7046ba74866dc"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Loading checkpoint shards: 0%| | 0/2 [00:00, ?it/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"9095199ed82f4d73acadb43366781167"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["generation_config.json: 0%| | 0.00/188 [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"4d88b9b66b424d6fa7315e3b3144a6fc"}},"metadata":{}}],"source":["trained_model = AutoPeftModelForCausalLM.from_pretrained(\n"," script_args.training_args.output_dir,\n"," quantization_config=bnb_config,\n"," device_map=\"auto\",\n"," cache_dir=script_args.cache_dir,\n",")"],"id":"39db2ee4-23c8-471f-89b2-bca34964bf81"},{"cell_type":"markdown","source":["**토크나이저 초기화**\n","\n","\n","> 지정된 모델에서 미리 훈련된 토크나이저를 로드함.\n","\n"],"metadata":{"id":"aZSH97Zmb3fK"},"id":"aZSH97Zmb3fK"},{"cell_type":"code","execution_count":15,"metadata":{"id":"b0b75ca4-730d-4bde-88bb-a86462a76d52","executionInfo":{"status":"ok","timestamp":1702212097846,"user_tz":-540,"elapsed":820,"user":{"displayName":"장예린","userId":"08326973126538993419"}},"colab":{"base_uri":"https://localhost:8080/","height":257,"referenced_widgets":["b8c0ed67113a4e80b84f6666f23099d4","797f0e1579f141918ed3dc829fbec677","3ef5a717d2b74c1ba283978ffaa35b62","204be735363f457c911389c8f1e6e39f","3b6eca7db05f47328b931f76079c34ef","6e301e443e4e480fa3b0c373abf2406e","1910cf65cb9748319d41c3d36037baf3","69423b28f6624a3bac61e7065caf78f2","bce7e88560f348b1b529011b1ef14216","d93ecffef8a544fab1de42d7f1e90f72","35f8c79833224eadaece352d3c1d9a38","f906532a16604e149b9cff76645ac75c","89641c5edc694ff98b6caf4d8dbe64ea","13c081422d564164b9bca0a53417ca4b","da2b3cfb50d74fab87c45adb6076dfec","da20532333994c8fac877fda7baacff7","30224f652f114c97a54289e5448d7662","b4bb9505d8e24b68b51e5c7ca7041e9e","3e18648fd7e242c2b876d46f4663bdf3","8543a8a6a57845af9f749be05ecd6cee","e212e3a0f59b41619beedc73dfa1d17b","b6c0dcca8af74eb4923dbeec5f5613b2","426a2f997e534a07bb608defdffd0e8b","156d9fb26dd24245bcfd7089ba149233","87ca02b2ae0742c8b4172ad140a6df0c","20a880bb787c4e259d3d21c8aab73b29","d8920e0146b24363b8dc6b5b33e41d47","617029a0c31244af9beb8d1b9396c609","0efa1acc3ae8423cbf4cfe56ac83ee2c","964e11f14ce44e04acc576886fece5db","141c770dd3f84613bad7cf862b5a3f2b","ebdc1d5bd7c1485284f1e53558275000","e97222f0b0cb45abaf74a20599fc9529","3ce1074ff3d9410eabba06c696cb6d28","eed104cb411c4a7eb728ff2803dc61c2","8f8194511023476cbbc136bb4b9495a1","b5018df79ad5412da2b9dc0edac4e7a5","b53f3be24fc645b0932ab40052f4ae8a","f30bb1ed570a4306aa3c1bc3ba8a0e9f","265f9ed416e84b91999936113ce1bd65","cd74d92f057f4050b8c2a74051d9ab5e","fd23284c49f747058df8fb74b24e9ea4","b42a508a99cc42de9264bb804d3e5aa7","4a514c42f06b4d3bbd61b3240efb8d04"]},"outputId":"29b3dd18-2101-4500-f002-f9dfd1045942"},"outputs":[{"output_type":"display_data","data":{"text/plain":["tokenizer_config.json: 0%| | 0.00/1.62k [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"b8c0ed67113a4e80b84f6666f23099d4"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["tokenizer.model: 0%| | 0.00/500k [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"f906532a16604e149b9cff76645ac75c"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["tokenizer.json: 0%| | 0.00/1.84M [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"426a2f997e534a07bb608defdffd0e8b"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["special_tokens_map.json: 0%| | 0.00/414 [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"3ce1074ff3d9410eabba06c696cb6d28"}},"metadata":{}}],"source":["tokenizer = AutoTokenizer.from_pretrained(\n"," script_args.model_name,\n"," trust_remote_code=True,\n"," cache_dir=script_args.cache_dir,\n",")\n","\n","if getattr(tokenizer, \"pad_token\", None) is None:\n"," tokenizer.pad_token = tokenizer.eos_token\n","tokenizer.padding_side = \"right\" # Fix weird overflow issue with fp16 training\n","trained_model.config.pad_token_id = tokenizer.pad_token_id"],"id":"b0b75ca4-730d-4bde-88bb-a86462a76d52"},{"cell_type":"markdown","source":["**데이터셋 생성**\n","\n","\n","> 추론에 사용할 테스트 데이터 생성함.\n","\n"],"metadata":{"id":"qHcNDlVObcoa"},"id":"qHcNDlVObcoa"},{"cell_type":"code","execution_count":16,"metadata":{"id":"b5O6GD2BVr67","executionInfo":{"status":"ok","timestamp":1702212112233,"user_tz":-540,"elapsed":12498,"user":{"displayName":"장예린","userId":"08326973126538993419"}},"colab":{"base_uri":"https://localhost:8080/","height":473,"referenced_widgets":["eb8f992993b3446384204c1ec2293c4c","4659ae82bbc541b1b1fe5ac86f1f54cc","7d28bad462de45168d1b874a2fb1958f","2f7d9c7da2294f9e906897c51608abda","5b656c19d9a244d5a59e1089fc02b144","bb74b110db0946c18219b2184a9baf53","165644b063484559ac81b8f2c1864a8e","754ad1de97ab4d5d919cf21e164ab382","8acdc2206c96453aba78b0135eac77ff","57025c73a9994b93957ff9778417c619","d82207b7a792480a9740c5e187986c8e","dd4b9577f61f4d4a991e6f02934df083","452100f3be3f419ca63abf6759db2c79","f386c0cf38ae427e9481f0ea37405510","7067fe15e777404fab0659ae7ccafd78","a0e8d6377fc34ff7af7130ce8b5c6be2","10b16c8ff26142e197b8c7f286609742","186cb679924948f380b52a299df7a22f","3c2897cde14d4e06b3bf1b2fdaa11dd6","d09c9658cb904ab1805dfd2170e0ee3e","9a016a78ab404eb18cfb2a8a6b0385d1","a55d396641cf4e598b6d2f0f925ffd55","0ceaa8bf55364aad8ed743bea2594cef","2b4e3402ac3644fcbb3869a47e0492f2","691bddec0297480b8c212e0429395ef1","a54bffeac1ba4552bab9ef218c8b2a90","d5a95d52f9aa47679d447f5fe682d005","9a5029e9f9d24c39b8cc2e3c1c19646c","f97fc42540954b0e9e23a4425e31aba3","cde7293837084071bdeb5a65d4fbbf4a","ebe18a0a5b9f4fd1a687f09908aa9916","8cbf9570d35a497893402b8031d92b07","5a5d2ed3a3674c1abfd3774ab40426c0","320a7c0d91a145689768cf778fe7f85d","66af33db1fce49a5a4e16a6ac8308d78","cad7292862494c809df97923318681d2","f0276c0e06dd445a831082a4e9cfe937","e67fb23389e8422aba30a45db7b83065","282e47cdf9df431b8f75f1134da60ce8","da97fd9a85c3496fb281804ba7687d88","d57caacf16074527a032781e638bd590","0dd55cda962c4f03abfbe7b22628c5c3","a7e432cf046742ec95648d0ffb78c6d0","0713b13258074ad7ae31704a59fafc3c","8086210309074fc8ab0e6bc1f7c7466f","e634b02e7f014f09861038ca5f579489","9964f232b28f466a815488c82e5f9613","7137852e0a674a63b0cd1409d4d010b8","8d9a9ddaf76c497f86148660ffc357b9","a99c6a9013ba408b99f72e24deb255ee","ba9d74c019124f5e9bbe82ba41fb6af0","f7ebbe2932ac48ff8b84beb9f86c821b","1457193b34d04a2e8e29b7a4b3fc0b8e","a70e9bf4846b47b18b55a90ec67c5752","3eba7b852cf5477197745d708190bb70","7d366b10250744e3b6cfcc81f1794d07","ecf3fbedc71e4f59acbef86b44c3bf6e","bd2a3440af7d4e3a98f95b4b6603dc6f","6c5260e59cbb45ff974bc55f758c4f6b","33f4ba89668b41eca016b44d3bb5890e","839298e02e104f46b98fd1c85d55d85c","5196626f8597425c93e5fefb1c604305","161f6c502e4c4183998bcbc512be8aca","2923ebcff45e4201814a79b4b7849fd8","3472c498957148c18a244c0650e274f8","387b2e145301412caaea4b24979f72d6","62b9de5fdef24e45ae322e7a64bc4285","05309d077097486790404de34c335499","cbc7bf63d8b24b0faa5f0d2e232d4e85","62a335c9cc2241b1a0d0a1ba43ad80a2","ab7c6074f0814935b1f780cca1201e2d","8c10255ff49d4c819149da6a28bad88b","59f99687781a4c1ba0fed6561298ed75","9d50c47299af494c8852c01a796106b1","779f50edb94943ea8a7e4f3c4770bf65","d94f916a26bc4ffcb8a4e1539b75a0d8","f1a5b613630a41fd9d375713a20bd53c","464f4a1d4185407f80501d7512abbe9f","c5ef39639cfb48269c800b5b9fe2597b","50463372fcaf45e9a6bfb8082fc433c5","e8a4c9cf83e84bdbbb2c6bbe7186fa9a","1a8f69ebe0364a528bb697b82b8162c6","f787a3c4eec041e7bb22b8f197e2a6c1","c14ea0005dbd4a42b6f50b4ca75df58f","06ccbb8862514b6ea4596b9f69be9fc9","2312df9829af4c32bfd9e045f3337ff3","9859665df2634a429c31f52548ccb559","121ddc81bc7944c294a064a90e26b88b","4c63f5b266db4b85aaeadf11fc8025a9","6d2f903d329d4040aff1261199bc827b","a3df83b95bbe4611a83ac14270148372","8c176e5a1ece4460b7453fef8724f8d3","a8a5fdac98c848749765c1520c871829","23752b695ed24fdc8c874f6f706e4903","8dd8b001efa440a9b0376bf17c9ae160","38bcd7f771244a5bb84c4c30275b1a27","f4d538fa2bba41c49d24f7fb7391a3a1","ed7ed85a4c194bcda7967cd07f0c2df1","a279b8ed424244b18a999f8e47dba9ef"]},"outputId":"b18b5551-e5ba-4666-92d1-844449f0729a"},"outputs":[{"output_type":"display_data","data":{"text/plain":["Downloading builder script: 0%| | 0.00/3.18k [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"eb8f992993b3446384204c1ec2293c4c"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading metadata: 0%| | 0.00/1.67k [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"dd4b9577f61f4d4a991e6f02934df083"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading readme: 0%| | 0.00/3.74k [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"0ceaa8bf55364aad8ed743bea2594cef"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading data files: 0%| | 0/2 [00:00, ?it/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"320a7c0d91a145689768cf778fe7f85d"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading data: 0%| | 0.00/6.33M [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"8086210309074fc8ab0e6bc1f7c7466f"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading data: 0%| | 0.00/2.12M [00:00, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"7d366b10250744e3b6cfcc81f1794d07"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Extracting data files: 0%| | 0/2 [00:00, ?it/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"62b9de5fdef24e45ae322e7a64bc4285"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Generating train split: 0%| | 0/150000 [00:00, ? examples/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"464f4a1d4185407f80501d7512abbe9f"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Generating test split: 0%| | 0/50000 [00:00, ? examples/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"4c63f5b266db4b85aaeadf11fc8025a9"}},"metadata":{}}],"source":["valid_dataset = create_valid_datasets(tokenizer, script_args)"],"id":"b5O6GD2BVr67"},{"cell_type":"markdown","metadata":{"id":"X1tRCa4EiYXp"},"source":["추론 과정에서는 GPU 메모리를 약 5.5 GB 활용"],"id":"X1tRCa4EiYXp"},{"cell_type":"code","execution_count":17,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"e374555b-9f8a-4617-8ea7-c1e6ee1b2999","outputId":"c8af7904-1d81-4519-d03c-ec94a2c43813","executionInfo":{"status":"ok","timestamp":1702213801231,"user_tz":-540,"elapsed":1689016,"user":{"displayName":"장예린","userId":"08326973126538993419"}}},"outputs":[{"output_type":"stream","name":"stdout","text":[";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";긍정\n",";부정\n",";부정\n",";부정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";긍정\n",";부정\n",";부정\n",";긍정\n",";부정\n"]}],"source":["eval_dic = {i: wrapper_generate(model=trained_model, input_prompt=prompt_template.format(System=default_system_msg, User=example[\"document\"]))for i, example in enumerate(valid_dataset)}"],"id":"e374555b-9f8a-4617-8ea7-c1e6ee1b2999"},{"cell_type":"markdown","source":["**모델 평가 및 결과**\n","\n","\n","> 정확도 및 혼돈 행렬로 모델을 평가함.\n","\n"],"metadata":{"id":"PtEfo3dHg6b2"},"id":"PtEfo3dHg6b2"},{"cell_type":"code","execution_count":18,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":522},"executionInfo":{"elapsed":747,"status":"ok","timestamp":1702213956467,"user":{"displayName":"장예린","userId":"08326973126538993419"},"user_tz":-540},"id":"zGWyzs1tbSJH","outputId":"b34fdb2c-c827-4982-aa80-b081e3de4fc8"},"outputs":[{"output_type":"stream","name":"stdout","text":["Accuracy: 0.869\n"]},{"output_type":"display_data","data":{"text/plain":["