During testing, it was found that “…” frequently appeared in conversations. Analysis showed that there were at least 2K similar responses in the script. Although such responses, combined with CG images, can subtly convey a character’s mindset, AIGC tasks require direct responses. Therefore, these characters need to be removed from the script, along with similar symbols such as ***.
...
Use the sed command for text file preprocessing, and place the results in the pt_txt folder for pre-training. In addition, the SFT fine-tuning script needs to be re-executed.
1 2 3 4 5 6
sed '/「………」/d' CLANNAD.txt > CLANNAD_NODOT.txt_1 sed '/「……」/d' CLANNAD_NODOT.txt_1 > CLANNAD_NODOT.txt_2 sed '/「…」/d' CLANNAD_NODOT.txt_2 > CLANNAD_NODOT.txt sed '/………/d' CLANNAD_NODOT.txt > CLANNAD_NODOT.txt_3 sed '/\*\*\*\*\*/d' CLANNAD_NODOT.txt_3 > CLANNAD_NODOT.txt sed '/嗯…/d' CLANNAD_NODOT.txt > CLANNAD_NODOT.txt_e
Splitting Fine-Tuning Data
Continuing from last time, because the responses from the trained large model suffered from overfitting.
Randomly split the dataset into training and test sets with a ratio of 7:3. Adjust the original code as follows to cluster and randomly split dialogues between different characters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
public BuildFinetuneFile map(){ for (FinetuneWithCharacter finetuneWithCharacter : finetuneWithCharacters) { String characterKey = finetuneWithCharacter.getInputCharactor() + "_" + finetuneWithCharacter.getOutputCharactor(); List<Finetune> finetunes = finetuneMap.getOrDefault(characterKey, new ArrayList<>()); finetunes.add(finetuneWithCharacter.getFinetune()); finetuneMap.put(characterKey, finetunes); } returnthis; }
publicvoidsplit(List<Finetune> dataset, List<Finetune> validator){ for (String character : finetuneMap.keySet()) { List<Finetune> list = finetuneMap.get(character); Collections.shuffle(list); int splitPoint = (int) (list.size() * 0.7); dataset.addAll(list.subList(0, splitPoint)); validator.addAll(list.subList(splitPoint, list.size())); } }
The startup script updates are as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
publicstaticvoidmain(String[] args)throws IOException { Parser parser = new Parser("CLANNAD.txt"); List<Finetune> dataset = new ArrayList<>(); List<Finetune> validator = new ArrayList<>(); new BuildFinetuneFile(parser.parseLines()).prepare().map().split(dataset, validator);
BufferedWriter finetuneOut = new BufferedWriter(new FileWriter("finetune_json/CLANNAD_LLaMA_finetune.json")); BufferedWriter validatorOut = new BufferedWriter(new FileWriter("validator_json/CLANNAD_LLaMA_validator.json"));
The character can quote dialogues from other characters.
The character can quote dialogues from other characters
Kotomi can finally make retorts, and very professionally at that!
Kotomi can finally make retorts
It fits the character’s basic attributes, and the forms of address are correct.
Matches character attributes
The model has acquired reasoning capabilities and fits well with the character’s personality. (According to the original script, to confirm whether Tomoyo is male or female, Sunohara asks in his usual punch-worthy manner by asking if she has a razor.)
Model dialogue reasoning
After being beaten up countless times, Sunohara has finally learned his lesson.