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?

You might take a look at my demo notebook here, which illustrates how to use GPT-J for inference, including adding examples to the prompt.

Thanks a lot, I am trying this now. Although facing some compute engine issues. But I think this will definitely work. Thanks again

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 below

prompt = """
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

I have figured it out. Thanks to nielsr for sharing the githublink. I have enhanced it a little and explained it here Adding examples to GPT-J