Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[neural search][fix bug of evaluate.py] #7832

Merged
merged 3 commits into from
Jan 11, 2024
Merged

[neural search][fix bug of evaluate.py] #7832

merged 3 commits into from
Jan 11, 2024

Conversation

ZeyuTeng96
Copy link
Contributor

@ZeyuTeng96 ZeyuTeng96 commented Jan 11, 2024

hi there:

with open(args.recall_result_file, "r", encoding="utf-8") as f:
        relevance_labels = []
        for index, line in enumerate(f):

            if index % args.recall_num == 0 and index != 0:
                rs.append(relevance_labels)
                relevance_labels = []

            text, recalled_text, cosine_sim = line.rstrip().split("\t")
            if text2similar[text] == recalled_text:
                relevance_labels.append(1)
            else:
                relevance_labels.append(0)

this chunk of code read a txt file line by line. And spliting the recall cases by the recall num. However, this chunk of code does not consider the last recall results. So, to fix it, have to add one more append function once the file is reading complete.

您好,
这段代码存在一个bug,这段代码按照recall num来进行按行读取数据,但是最后的一块召回结果并未被记录。举个例子,一个8行的txt和recall_num 2,这段代码只能够读取2,4,6行数据的召回结果,7和8的结果被丢掉了。为了修复这个bug, 可以在循环外再apped一次

Copy link

paddle-bot bot commented Jan 11, 2024

Thanks for your contribution!

Copy link
Contributor

@w5688414 w5688414 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@w5688414 w5688414 changed the title [fix][fix bug of evaluate.py] [neural search][fix bug of evaluate.py] Jan 11, 2024
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4069f22) 56.95% compared to head (3853b82) 56.95%.
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7832   +/-   ##
========================================
  Coverage    56.95%   56.95%           
========================================
  Files          587      587           
  Lines        88628    88628           
========================================
  Hits         50480    50480           
  Misses       38148    38148           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@w5688414 w5688414 merged commit a1d1aee into PaddlePaddle:develop Jan 11, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants