Views
No views yet
1INSTRUCTION_KEY = "### Instruction: Given the following prompt, generate a table"
2RESPONSE_KEY = "### Response:"
3INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
4PROMPT_FOR_GENERATION_FORMAT = """{intro}
5{instruction_key}
6{prompt_to_generate_table}
7{response_key}
8{table}
9""".format(
10 intro=INTRO_BLURB,
11 instruction_key=INSTRUCTION_KEY,
12 prompt_to_generate_table"{PROMPT}",
13 response_key=RESPONSE_KEY,
14 table="{TABLE}"
15)1import torch
2from transformers import (
3 AutoModelForCausalLM,
4 AutoTokenizer,
5)
6tokenizer = AutoTokenizer.from_pretrained('togethercomputer/RedPajama-INCITE-Instruct-3B-v1', padding_side="right")
7model = AutoModelForCausalLM.from_pretrained('gretelai/text2table').to('cuda')
8
9model.eval()
10
11INSTRUCTION_KEY = "### Instruction: Given the following prompt, generate a table."
12RESPONSE_KEY = "### Response:"
13INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
14PROMPT_FOR_GENERATION_FORMAT = """{intro}
15{instruction_key}
16{prompt_to_generate_table}
17{response_key}
18""".format(
19 intro=INTRO_BLURB,
20 instruction_key=INSTRUCTION_KEY,
21 prompt_to_generate_table="{prompt_to_generate_table}",
22 response_key=RESPONSE_KEY,
23)
24
25PROMPT = "Create a dataset with four columns: patient, sex, agegrp, bp_before and bp_after. The patient column is a numerical identifier, sex is the gender of the patient, agegrp is the age group of the patient, bp_before is the blood pressure (in mmHg) before a certain treatment, and bp_after is the blood pressure (in mmHg) after a certain treatment."
26inputs = PROMPT_FOR_GENERATION_FORMAT.format(prompt_to_generate_table=PROMPT)
27tokenizer.pad_token = tokenizer.eos_token
28input = tokenizer(inputs, return_tensors="pt").to('cuda')
29input_ids = input['input_ids']
30outputs = model.generate(**input, max_length = 1024)
31table = tokenizer.decode(outputs[0], skip_special_tokens=False)1PROMPT = "Create a dataset with four columns: patient, sex, agegrp, bp_before and bp_after. The patient column is a numerical identifier, sex is the gender of the patient, agegrp is the age group of the patient, bp_before is the blood pressure (in mmHg) before a certain treatment, and bp_after is the blood pressure (in mmHg) after a certain treatment."
2
3MODEL GENERATION ->
4
5Below is an instruction that describes a task. Write a response that appropriately completes the request.
6Instruction: Given the following prompt, generate a table. Each column should have random values.
7Create a dataset with four columns: patient, sex, agegrp, bp_before and bp_after. The patient column is a numerical identifier, sex is the gender of the patient, agegrp is the age group of the patient, bp_before is the blood pressure (in mmHg) before a certain treatment, and bp_after is the blood pressure (in mmHg) after a certain treatment.
8Response:
9patient,sex,agegrp,bp_before,bp_after
101.0,F,45.0,183.0,124.0,234.0
112.0,F,60.0,183.0,124.0,183.0
123.0,F,70.0,179.0,117.0,183.0
134.0,M,30.0,141.0,136.0,161.0
145.0,M,70.0,147.0,129.0,157.0
156.0,M,40.0,140.0,136.0,156.0
167.0,M,60.0,140.0,116.0,157.0
178.0,M,70.0,144.0,131.0,161.0
189.0,M,60.0,142.0,119.0,157.0
1910.0,M,70.0,147.0,132.0,167.0
2011.0,M,60.0,147.0,136.0,166.0
2112.0,M,70.0,150.0,132.0,172.0
2213.0,M,60.0,149.0,137.0,162.0
2314.0,M,70.0,156.0,124.0,157.0
2415.0,M,60.0,156.0,181.0,157.0
2516.0,M,70.0,156.0,131.0,158.0