Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
czyssrs committed May 27, 2019
2 parents 3099f98 + 51f2a3b commit 1b8797f
Show file tree
Hide file tree
Showing 39 changed files with 2,893 additions and 5,351 deletions.
467 changes: 228 additions & 239 deletions DataLoader.py

Large diffs are not rendered by default.

354 changes: 132 additions & 222 deletions Main.py

Large diffs are not rendered by default.

41 changes: 0 additions & 41 deletions OutputUnit.py

This file was deleted.

48 changes: 0 additions & 48 deletions OutputUnit_gpt.py

This file was deleted.

11 changes: 5 additions & 6 deletions PythonROUGE.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def PythonROUGE(guess_summ_list,ref_summ_list,ngram_order=2):
xml_file.write('</EVAL>\n')
xml_file.write('</ROUGE-EVAL>\n')
xml_file.close()



# this is the file where the output of ROUGE will be stored
ROUGE_output_path = prefix + 'ROUGE_result.txt'

Expand All @@ -73,7 +72,7 @@ def PythonROUGE(guess_summ_list,ref_summ_list,ngram_order=2):
precision_list = list()
F_measure_list = list()
ROUGE_output_file = open(ROUGE_output_path,'r')
for n in xrange(ngram_order):
for n in range(ngram_order):
ROUGE_output_file.seek(0)
for line in ROUGE_output_file:
match = re.findall('X ROUGE-' + str(n+1) + ' Average_R: ([0-9.]+)',line)
Expand Down Expand Up @@ -126,6 +125,6 @@ def create_xml(xml_file,guess_summ_file,ref_summ_list):
guess_summary_list = ['Example/Guess_Summ_1.txt','Example/Guess_Summ_2.txt']
ref_summ_list = [['Example/Ref_Summ_1_1.txt','Example/Ref_Summ_1_2.txt'] , ['Example/Ref_Summ_2_1.txt','Example/Ref_Summ_2_2.txt','Example/Ref_Summ_2_3.txt']]
recall_list,precision_list,F_measure_list = PythonROUGE(guess_summary_list,ref_summ_list)
print 'recall = ' + str(recall_list)
print 'precision = ' + str(precision_list)
print 'F = ' + str(F_measure_list)
print('recall = ' + str(recall_list))
print('precision = ' + str(precision_list))
print('F = ' + str(F_measure_list))
Binary file added PythonROUGE.pyc
Binary file not shown.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# wikitobio
Generate biography from wiki infobox
# Few-shot table-to-text Generation
Generate descriptions from wiki infobox under few shot setting

## Installation
python3 -m venv ucsb
source ucsb/bin/activate
pip install -r requirements.txt

## Instructions
Download the data(few_shot_gpt-2.zip) and pre-trained GPT2 model(models.zip), unzip them to the same directory of the code(so that all three of them(few_shot_gpt-2_data, models, wikitobio) are in the same directory).

The training takes two 10G GPUs. I placed the GPT part into one GPU and the pointer generator part into another, since on my side we only have 10G GPUs. If you have different GPU configurations, like one GPU of more than 20G, go to SeqUnit.py and remove all the "with tf.device("/gpu:1"):" tags.

Command for training:

$ cd wikitobio

$ python Main.py your_saved_model_name few_shot_folder

Now it's the experiment on humans domain with 1000 training data. You will see a result bleu score of around 26 after 10 training rounds.
Loading

0 comments on commit 1b8797f

Please sign in to comment.