Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Friday, 7 July 2023

Effectively Using ChatDolphin, The ChatGPT Alternative, With Simple Instructions

 NLP Cloud has developed a powerful alternative to OpenAI ChatGPT, called ChatDolphin. These AI models are interesting because they understand very well simple instructions made in natural language without having to use few-shot learning and complex prompt engineering. Let's see how to craft such instructions in order to make the most of ChatDolphin and ChatGPT.

ChatGPT and ChatDolphin

ChatGPT was released in December 2022 by OpenAI as a small generative model that is very good at understanding human instructions, optimized for conversations and large detailed answers. It appears that ChatGPT is very good at handling many use cases, not only conversations. Like GPT-3, you can use ChatGPT to perform summarization, paraphrasing, entity extraction, etc. Thanks to its small size, ChatGPT is also cheaper than GPT-3.

In April 2023, NLP Cloud released ChatDolphin, a powerful alternative to ChatGPT. ChatDolphin is an in-house NLP Cloud model that is very good at understanding human instructions, handling conversations, and behaves exactly like ChatGPT. ChatDolphin is cheap too.

Below, we're showing you examples obtained using the text generation endpoint on NLP Cloud with ChatDolphin, with the Python client. If you want to copy paste the examples, please don't forget to add your own API token. In order to install the Python client, first run the following: pip install nlpcloud.

Few-Shot Learning VS Simple Instructions

When the first large language models were released, like GPT-J, OPT, Bloom, etc. it quickly appeared that - despite being very powerful - these models were not able to understand simple human instructions made in natural language.

For example, if you want to extract a name, a position, and a company, from a piece of text, you need to do something like this using GPT-J on NLP Cloud:

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""[Text]: Fred is a serial entrepreneur. Co-founder and CEO of Platform.sh, he previously co-founded Commerce Guys, a leading Drupal ecommerce provider. His mission is to guarantee that as we continue on an ambitious journey to profoundly transform how cloud computing is used and perceived, we keep our feet well on the ground continuing the rapid growth we have enjoyed up until now. 
[Name]: Fred
[Position]: Co-founder and CEO
[Company]: Platform.sh
###
[Text]: Microsoft (the word being a portmanteau of "microcomputer software") was founded by Bill Gates on April 4, 1975, to develop and sell BASIC interpreters for the Altair 8800. Steve Ballmer replaced Gates as CEO in 2000, and later envisioned a "devices and services" strategy.
[Name]:  Steve Ballmer
[Position]: CEO
[Company]: Microsoft
###
[Text]: Franck Riboud was born on 7 November 1955 in Lyon. He is the son of Antoine Riboud, the previous CEO, who transformed the former European glassmaker BSN Group into a leading player in the food industry. He is the CEO at Danone.
[Name]:  Franck Riboud
[Position]: CEO
[Company]: Danone
###
[Text]: David Melvin is working for CITIC CLSA with over 30 years’ experience in investment banking and private equity. He is currently a Senior Adviser of CITIC CLSA.
""",
    top_p=0,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

This technique, known as "few-shot learning", or "prompt engineering" is explained in a dedicated article: read the article here.

Few-shot learning works very well on ChatGPT and ChatDolphin and allows you to get very advanced results. But in most cases few-shot learning is not needed and unnecessarily complex. Besides, as the generative AI models only allow for a limited input length, the few-shot examples sometimes simply don't fit into the request.

Good news is that, when properly fine-tuned, the large language models can learn how to understand human instructions without using few-shot learning. This is the case of ChatGPT and ChatDolphin.

With these models, here is how your query would look like:

import nlpcloud
client = nlpcloud.Client("chatdolphin", "your_token", gpu=True)
generation = client.generation("""Extract name, position, and company, from the following text.

David Melvin working for CITIC CLSA with over 30 years’ experience in investment banking and private equity. He is currently a Senior Adviser of CITIC CLSA.""")
print(generation["generated_text"])

Output:

Name: David Melvin
Position: Senior Adviser
Company: CITIC CLSA

Much simpler isn't it? Now what if we want the result to be formatted as JSON? Here is a simple instruction:

import nlpcloud
client = nlpcloud.Client("chatdolphin", "your_token", gpu=True)
generation = client.generation("""Extract name, position, and company, from the following text. Format the result as JSON.

David Melvin working for CITIC CLSA with over 30 years’ experience in investment banking and private equity. He is currently a Senior Adviser of CITIC CLSA.""")
print(generation["generated_text"])

Output:

{
"name": "David Melvin",
"position": "Senior Adviser",
"company": "CITIC CLSA"
}

I think you get the idea don't you?

You can easily test natural instructions on the NLP Cloud Playground, in the text generation section. Click here to try text generation on the Playground. Then simply use one of the examples showed below in this article and see for yourself.

Note that these models are trained to generate large responses. If you need short and concise responses, you can mention it in your prompt (with something like "Make a short response.").

No comments:

Post a Comment

Connect broadband

AI:Lord Krishna Unventional and DEceptive methodlogies

Lord Krishna's actions during the Kurukshetra War, particularly his role in the deaths of Bhishma, Drona, and Karna, are often seen thro...