Adding examples in GPT-J
In GPT-3, we can add examples before generating the output from the prompt. How do we add examples in GPT-J?
2021-10-29T08:26:37Z
You might take a look at my demo notebookhere, which illustrates how to use GPT-J for inference, including adding examples to the prompt.
2021-10-30T17:11:07Z
Thanks a lot, I am trying this now. Although facing some compute engine issues. But I think this will definitely work. Thanks again
2021-10-31T22:45:30Z
just now, I am successful in running my code following the suggestion given by@nielsr. But I see that the generated text is giving more tokens than I need. Is there a way to stop once I get the answer. My code looks as belowprompt = """
Title: Ingest iris.csv into a dataframe
Code: import pandas as pd
file="/Users/data/iris.csv"
df=pd.read_csv(file)
print(df.head())

####

Title: Show 5 rows from a dataframe
Code: df.head(5)

####

Title: Show 6 rows from a dataframe
Code: """
input_ids=tokenizer.encode(str(prompt),return_tensors="pt")
generated_ids = model.generate(input_ids, do_sample=True, temperature=0.9, max_length=200)
generated_text = tokenizer.decode(generated_ids[0])
print(generated_text)The output is as below. I was expecting only df.head(6)Title: Ingest iris.csv into a dataframe
Code: import pandas as pd
file="/Users/data/iris.csv"
df=pd.read_csv(file)
print(df.head())

####

Title: Show 5 rows from a dataframe
Code: df.head(5)

####

Title: Show 6 rows from a dataframe
Code: 
df.head(6)

####

Title: Display dataframe in a grid
Code: df.to_html()
####

Title: Write dataframe rows to a csv file
Code: df.to_csv('iris.csv', index=False)
####

Title: Export all dataframe rows to an excel file
Code: df.to_excel('iris.xlsx', index=False)
####

Title: Export dataframe to a JSON
2021-11-01T12:57:51Z
I have figured it out. Thanks to nielsr for sharing the githublink. I have enhanced it a little and explained it hereAdding examples to GPT-J