{ "cells": [ { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "#dependencies:\n", "import pandas as pd\n", "\n", "import torch\n", "from transformers import GPT2Tokenizer\n", "\n", "from trl import AutoModelForCausalLMWithValueHead, PPOConfig, PPOTrainer" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b8a22b8d60c0417eafbf554832398287", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Resolving data files: 0%| | 0/18 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b83d2624c2b14986a8297821460225ab", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Resolving data files: 0%| | 0/18 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b4304c0f48cb472589b5e80d3a42cba2", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Resolving data files: 0%| | 0/18 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#loading datasets:\n", "from datasets import load_dataset\n", "\n", "ds = load_dataset(\"stanfordnlp/SHP\", split='train')" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Index(['post_id', 'domain', 'upvote_ratio', 'history', 'c_root_id_A',\n", " 'c_root_id_B', 'created_at_utc_A', 'created_at_utc_B', 'score_A',\n", " 'score_B', 'human_ref_A', 'human_ref_B', 'labels', 'seconds_difference',\n", " 'score_ratio'],\n", " dtype='object')\n" ] } ], "source": [ "df = ds.to_pandas()\n", "print(df.columns)\n" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | upvote_ratio | \n", "history | \n", "score_A | \n", "score_B | \n", "human_ref_A | \n", "human_ref_B | \n", "labels | \n", "score_ratio | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "0.99 | \n", "In an interview right before receiving the 201... | \n", "52 | \n", "54 | \n", "Currently wrapping up my PhD. There is a stark... | \n", "It’s ironic to me that research has shown that... | \n", "0 | \n", "1.038462 | \n", "
1 | \n", "0.95 | \n", "If any professor is reading this: please do no... | \n", "5 | \n", "17 | \n", "And when your teacher doesn't listen or pay at... | \n", "I'm pretty strict on time, to the point where ... | \n", "0 | \n", "3.400000 | \n", "
2 | \n", "0.95 | \n", "If any professor is reading this: please do no... | \n", "5 | \n", "7 | \n", "Profs can be oblivious? What’s new! | \n", "This sounds like a problem with a specific pro... | \n", "0 | \n", "1.400000 | \n", "
3 | \n", "0.95 | \n", "If any professor is reading this: please do no... | \n", "7 | \n", "5 | \n", "This sounds like a problem with a specific pro... | \n", "And when your teacher doesn't listen or pay at... | \n", "1 | \n", "1.400000 | \n", "
4 | \n", "0.95 | \n", "If any professor is reading this: please do no... | \n", "6 | \n", "7 | \n", "This would be totally unacceptable in my class... | \n", "This sounds like a problem with a specific pro... | \n", "0 | \n", "1.166667 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
348713 | \n", "0.94 | \n", "Can I get in trouble for giving my neighbor hi... | \n", "7 | \n", "25 | \n", "Just put up a fence. Legally he isn't responsi... | \n", "Whatever you do, don't cut his trees down. | \n", "0 | \n", "3.571429 | \n", "
348714 | \n", "0.94 | \n", "Can I get in trouble for giving my neighbor hi... | \n", "2 | \n", "25 | \n", "If OP pays someone to clean his yard, and then... | \n", "Whatever you do, don't cut his trees down. | \n", "0 | \n", "12.500000 | \n", "
348715 | \n", "0.94 | \n", "Can I get in trouble for giving my neighbor hi... | \n", "9 | \n", "7 | \n", "My observation is that both of you are idiots... | \n", "Are you Rand Paul's neighbor? https://www.gq.... | \n", "1 | \n", "1.285714 | \n", "
348716 | \n", "0.94 | \n", "Can I get in trouble for giving my neighbor hi... | \n", "9 | \n", "7 | \n", "My observation is that both of you are idiots... | \n", "Just put up a fence. Legally he isn't responsi... | \n", "1 | \n", "1.285714 | \n", "
348717 | \n", "0.94 | \n", "Can I get in trouble for giving my neighbor hi... | \n", "7 | \n", "2 | \n", "Capture his acts on camera. Collect and bag l... | \n", "If OP pays someone to clean his yard, and then... | \n", "1 | \n", "3.500000 | \n", "
348718 rows × 8 columns
\n", "