Skip to content

Commit

Permalink
fix long line
Browse files Browse the repository at this point in the history
  • Loading branch information
gorkemgoknar committed Dec 19, 2020
1 parent f08c184 commit e75934c
Show file tree
Hide file tree
Showing 10 changed files with 40,091 additions and 18 deletions.
42 changes: 25 additions & 17 deletions data/make_persona_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_chat_dialog(dialog):
#have token limit of 512
#find first . after 300th
startpos=350
index = l[startpos:].find('.')
index = talk[startpos:].find('.')
#if it finds position will be startpos+index, else it will be startpos-1
print(f"LONG LINE split after pos {startpos+index}: " + talk)

Expand Down Expand Up @@ -268,7 +268,7 @@ def get_random_line_not_said_by_char(name,dialogs,current_recursion=0):
#two_person_chats[5][1]['chat']


def get_utterance_list(chat, dialogs, char_opening_lines=None, num_cadidates=10,):
def get_utterance_list(chat, dialogs, char_opening_lines=None, num_candidates=10, use_personality_score=False):

if char_opening_lines is None:
char_opening_lines = collections.defaultdict(list)
Expand All @@ -277,7 +277,7 @@ def get_utterance_list(chat, dialogs, char_opening_lines=None, num_cadidates=10,

##build utterance list

utterances = []
utterances = []

for id, line in enumerate( chat ):
##check if next line exists:
Expand Down Expand Up @@ -322,28 +322,36 @@ def get_utterance_list(chat, dialogs, char_opening_lines=None, num_cadidates=10,
#for each utterance generate personality
for utterance in utterances:
name = utterance["name"]
personality_traits= dialogs["personalities"][name]

personality = []

p_openness = "inventive curious" if personality_traits[0] == 1 else "consistent cautious"
p_conscientiousness = "efficient organized" if personality_traits[1] == 1 else "easy-going careless"
p_extraversion = "outgoing energetic" if personality_traits[2] == 1 else "solitary reserved"
p_agreebleness = "friendly compassionate" if personality_traits[3] == 1 else "challenging detached"
p_neuroticism = "sensitive nervous" if personality_traits[4] == 1 else "secure confident"
if use_personality_score:
personality_traits= dialogs["personalities"][name]

personality.append("I am " + p_openness)
personality.append("I am " +p_conscientiousness)
personality.append("I am " +p_extraversion)
personality.append("I am " +p_agreebleness)
personality.append("I am " +p_neuroticism)
personality.append("My name is " + name)
p_openness = "inventive curious" if personality_traits[0] == 1 else "consistent cautious"
p_conscientiousness = "efficient organized" if personality_traits[1] == 1 else "easy-going careless"
p_extraversion = "outgoing energetic" if personality_traits[2] == 1 else "solitary reserved"
p_agreebleness = "friendly compassionate" if personality_traits[3] == 1 else "challenging detached"
p_neuroticism = "sensitive nervous" if personality_traits[4] == 1 else "secure confident"

utterance["personality"] = personality
personality.append("I am " + p_openness)
personality.append("I am " +p_conscientiousness)
personality.append("I am " +p_extraversion)
personality.append("I am " +p_agreebleness)
personality.append("I am " +p_neuroticism)
else:
char_line = get_random_line_said_by_char(name,dialogs)
if len(char_line)> 100:
startpos=90
index = l[startpos:].find('.')
char_line = char_line[startpos+index: ]
personality.append(char_line)

personality.append("My name is " + name +".")
utterance["personality"] = personality

return utterances, char_opening_lines





Expand Down
2 changes: 1 addition & 1 deletion data/moviepersonafile.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"<bos>": 40478, "<eos>": 40479, "<pad>": 40480, "<speaker1>": 40481, "<speaker2>": 40482}
60 changes: 60 additions & 0 deletions runs/Dec19_09-14-17_bb2a6051375c_openai-gpt/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"afn": "gelu",
"architectures": [
"OpenAIGPTLMHeadModel"
],
"attn_pdrop": 0.1,
"bos_token_id": null,
"do_sample": false,
"embd_pdrop": 0.1,
"eos_token_ids": null,
"finetuning_task": null,
"id2label": {
"0": "LABEL_0",
"1": "LABEL_1"
},
"initializer_range": 0.02,
"is_decoder": false,
"label2id": {
"LABEL_0": 0,
"LABEL_1": 1
},
"layer_norm_epsilon": 1e-05,
"length_penalty": 1.0,
"max_length": 20,
"model_type": "openai-gpt",
"n_ctx": 512,
"n_embd": 768,
"n_head": 12,
"n_layer": 12,
"n_positions": 512,
"n_special": 0,
"num_beams": 1,
"num_labels": 1,
"num_return_sequences": 1,
"output_attentions": false,
"output_hidden_states": false,
"output_past": true,
"pad_token_id": null,
"predict_special_tokens": true,
"pruned_heads": {},
"repetition_penalty": 1.0,
"resid_pdrop": 0.1,
"summary_activation": null,
"summary_first_dropout": 0.1,
"summary_proj_to_labels": true,
"summary_type": "cls_index",
"summary_use_proj": true,
"task_specific_params": {
"text-generation": {
"do_sample": true,
"max_length": 50
}
},
"temperature": 1.0,
"top_k": 50,
"top_p": 1.0,
"torchscript": false,
"use_bfloat16": false,
"vocab_size": 40483
}
Empty file.
Loading

0 comments on commit e75934c

Please sign in to comment.