Git Product home page Git Product logo

Comments (2)

yao8839836 avatar yao8839836 commented on August 22, 2024

@lushishuai

您好,WN18RR的hits@10表现也比较不稳定, UMLS和FB15k-237的Hits@10比较稳定。可参考 #9

from kg-bert.

MedyG avatar MedyG commented on August 22, 2024

@yao8839836 你好,我运行run_bert_relation_prediction.py得到的结果与论文结果相去甚远,是参数设置的不对吗

02/04/2021 18:31:46 - INFO - main - ***** Test results *****
02/04/2021 18:31:46 - INFO - main - acc = 0.6901355995327657
02/04/2021 18:31:46 - INFO - main - eval_loss = 0.7939625151198486
02/04/2021 18:31:46 - INFO - main - global_step = 301980
02/04/2021 18:31:46 - INFO - main - loss = 0.3695593820695463

我的参数输入

--task_name kg --do_train --do_eval --do_predict --data_dir ./data/FB15K --bert_model bert-base-cased --max_seq_length 25 --train_batch_size 32 --learning_rate 5e-5 --num_train_epochs 20.0 --output_dir ./output_FB15K/ --gradient_accumulation_steps 1 --eval_batch_size 512

原代码读取entity2text.txt文件报字符错误,我换成了'utf'格式

with open(os.path.join(data_dir, "entity2text.txt"), 'r', encoding='utf') as f:
        ent_lines = f.readlines()
        for line in ent_lines:
            temp = line.strip().split('\t')
            ent2text[temp[0]] = temp[1]

    if data_dir.find("FB15") != -1:
        with open(os.path.join(data_dir, "entity2text.txt"), 'r', encoding='utf') as f:
            ent_lines = f.readlines()
            for line in ent_lines:
                temp = line.strip().split('\t')
                #first_sent_end_position = temp[1].find(".")
                ent2text[temp[0]] = temp[1]#[:first_sent_end_position + 1]              

另外由于网络环境问题,在线下载模型比较慢,我手动换成读取已经下载好的本地模型bert-base-cased-vocab.txtbert-base-cased.tar.gz

  tokenizer = BertTokenizer.from_pretrained("D:\\Documents\\code\\pretrained\\bert\\bert-base-cased-vocab.txt", do_lower_case=args.do_lower_case)
  model = BertForSequenceClassification.from_pretrained("D:\\Documents\\code\\pretrained\\bert\\bert-base-cased.tar.gz",
          cache_dir=cache_dir,
          num_labels=num_labels)

希望能得到你的帮助

from kg-bert.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.