Tasfiya025 commited on
Commit
f8e73ae
·
verified ·
1 Parent(s): 3cac703

# Dataset for shorif/simple-chat-gpt2-small


This repository contains a simple prompt-response dataset in CSV format for fine-tuning a conversational model.


Files:
- `dataset.csv` — CSV file with two columns: `prompt` and `response`.
- `csv_to_jsonl.py` — Script that converts `dataset.csv` into `dataset.jsonl` (JSONL format used for fine-tuning).


Format:
- CSV header: `prompt,response`
- Each row: one prompt-response pair. Do not include sensitive or private data.


Usage:
- Place `dataset.csv` and `csv_to_jsonl.py` in the same folder.
- Run `python csv_to_jsonl.py` to create `dataset.jsonl`.


License: Use as you wish.

Files changed (1) hide show
  1. csv_to_jsonl.py +38 -0
csv_to_jsonl.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ csv_to_jsonl.py
3
+
4
+
5
+ Converts a CSV file with columns `prompt` and `response` into a JSONL file
6
+ where each line is a JSON object: {"input": "<prompt>", "output": "<response>"}
7
+
8
+
9
+ Run:
10
+ python csv_to_jsonl.py
11
+
12
+
13
+ This will create `dataset.jsonl` in the same folder.
14
+ """
15
+
16
+
17
+ import csv
18
+ import json
19
+
20
+
21
+ INPUT_CSV = "dataset.csv"
22
+ OUTPUT_JSONL = "dataset.jsonl"
23
+
24
+
25
+ def csv_to_jsonl(in_csv: str = INPUT_CSV, out_jsonl: str = OUTPUT_JSONL):
26
+ with open(in_csv, "r", encoding="utf-8") as f_in, open(out_jsonl, "w", encoding="utf-8") as f_out:
27
+ reader = csv.DictReader(f_in)
28
+ # Ensure header contains prompt and response
29
+ if "prompt" not in reader.fieldnames or "response" not in reader.fieldnames:
30
+ raise ValueError("CSV must contain 'prompt' and 'response' columns")
31
+ for row in reader:
32
+ obj = {"input": row["prompt"].strip(), "output": row["response"].strip()}
33
+ f_out.write(json.dumps(obj, ensure_ascii=False) + "\n")
34
+ print(f"Wrote {out_jsonl}")
35
+
36
+
37
+ if __name__ == "__main__":
38
+ csv_to_jsonl()