|
Algorithm 4 Reframe Unsuitable Sentences With LLM. |
-
1:
Input: generated_story, sentence_classification_results, LLM_model, classifier
-
2:
Output: reframed_story
-
3:
Begin
-
4:
Split generated_story into individual sentences
-
5:
Initialize reframed_story as an empty list
-
6:
for each sentence and its corresponding classification result in generated_story do
-
7:
if classification_result == “Unsuitable” then
-
8:
Pass the unsuitable sentence to the LLM for reframing
-
9:
Provide context about child-appropriate content in the prompt
-
10:
Example prompt: “Reframe the following sentence to make it suitable for children: <unsuitable_sentence>”
-
11:
Capture the LLM’s reframed sentence as modified_sentence
-
12:
Append modified_sentence to reframed_story
-
13:
else
-
14:
Append the original sentence to reframed_story
-
15:
end if
-
16:
end for
-
17:
Combine reframed_story sentences back into a full story
-
18:
Feed reframed_story into the BERT Classifier for classification
-
19:
Initialize suitable_story as False
-
20:
while suitable_story == False do
-
21:
Run the BERT Classifier on reframed_story to classify sentences
-
22:
if all sentences are classified as “Suitable" then
-
23:
Set suitable_story = True
-
24:
else
-
25:
Repeat steps 4 to 7 for any new unsuitable sentences
-
26:
end if
-
27:
end while
-
28:
Return reframed_story (where all sentences are classified as suitable)
-
29:
End
|