Lesson Generating Text - Artificial Intelligence - ثالث ثانوي

Lesson 3 Generating Text

Natural Language Generation

Table 3.4: The impact of NLG

Lesson 3 Generating Text

Template-Based NLG

Selection-Based NLG

Rule-Based NLG

Machine Learning-Based NLG

Using Template-Based NLG

Lesson 3 Generating Text

Syntax Analysis

Lesson 3 Generating Text

Paraphrase() Function

Lesson 3 Generating Text

quality check: if the chosen candidate is not semantically similar enough to

Lesson 3 Generating Text

Using Selection-Based NLG

Networkx Library

Lesson 3 Generating Text

Build_graph() Function

Lesson 3 Generating Text

Louvain Algorithm

Get_communities() Function

Lesson 3 Generating Text

Now that all the words have been mapped to a community

Evaluate_sentences() Function

Lesson 3 Generating Text

The original doc includes a total of 61 sentences. The following code can now be used to get the top 3 most important of these sentences:

Lesson 3 Generating Text

The results verify this approach can indeed successfully

Using Rule-Based NLG to Create a Chatbot

2. Create a Simple Knowledge Base

Lesson 3 Generating Text

This simple knowledge can be easily extended to add more Q/A levels and make the chatbot more intelligent.

Chat() Function

Lesson 3 Generating Text

convert_to_tensor=True)

Interaction 1

Lesson 3 Generating Text

Interaction 2

Using Machine Learning to Generate Realistic Text

Lesson 3 Generating Text

Transformers

OpenAI GPT-2 Model

Lesson 3 Generating Text

We had dinner at this restaurant yesterday.

Lesson 3 Generating Text

This leads to a much more diverse output, while maintaining the authenticity of the generated text. The text uses a rich vocabulary and is syntactically correct.

Lesson 3 Generating Text

Read the sentences and tick True or False.

Compare the different approaches of Natural Language Generation (NLG).

State three different applications for NLG.

Lesson 3 Generating Text

Complete the following code so that the build_graph()

Lesson 3 Generating Text

Complete the following code so that the function get_max_sim()