shreyashankar / gpt3-sandbox

The goal of this project is to enable users to create cool web demos using the newly released OpenAI GPT-3 API with just a few lines of Python.
MIT License
2.9k stars 884 forks source link

Named Entity Recognition example #60

Open quansun opened 3 years ago

quansun commented 3 years ago

Hi, thanks for developing such a great tool.

Just wondering if you could add an example for training GPT-3 for Named Entity Recognition (NER) tasks?

I'm not sure how I can use the add_example function to specify the answer to a question for NER tasks:

... gpt.add_example(Example('Tom was born in 1942', '[(Tom, Name), (1942, Year)]')) ...

Thanks!

juliensalinas commented 2 years ago

In case it helps, I made this article that explains how to use GPT-3 for NER.

Here is a full prompt example:

Extract job titles from the following sentences.

Sentence: John Doe has been working for Microsoft for 20 years as a Linux Engineer.
Job title: Linux Engineer
###
Sentence: John Doe has been working for Microsoft for 20 years and he loved it.
Job title: none
###
Sentence: Marc Simoncini | Director | Meetic
Job title: Director
###
Sentence: Franck Riboud was born on 7 November 1955 in Lyon. He is the son of Antoine Riboud, who transformed the former European glassmaker BSN Group into a leading player in the food industry. He is the CEO at Danone.
Job title: CEO
###
Sentence: Damien is the CTO of Platform.sh, he was previously the CTO of Commerce Guys, a leading ecommerce provider.
Job title:

Basically with GPT-3 sandbox, you could create examples like this:

gpt.add_example(Example("""Sentence: John Doe has been working for Microsoft for 20 years as a Linux Engineer.
Job title:""", 
"Linux Engineer"))