Code Monkey home page Code Monkey logo

esd's People

Contributors

wangpeiyi9979 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yyht

esd's Issues

Implementation detail of CSA

Hi, peiyi. I have a detailed question about CSA.
It seems that we can directly use this to compute that does not need loop:

support_span_enhance4one_query = self.cross_attentioner(support_span_rep.unsqueeze(0),
one_query_spans_squeeze.unsqueeze(0),
one_query_spans_squeeze.unsqueeze(0)).squeeze(0)
query_span_enhance_rep = self.cross_attentioner(one_query_spans_squeeze.unsqueeze(0),
support_span_rep.unsqueeze(0),
support_span_rep.unsqueeze(0)).squeeze(0)

And it seems that the implementation is different from paper.
I don't know if there is something wrong with my understanding.

the meaning of the results

Hi! I have a detailed question that the code prints
Batch f1 [ SNIPS ]: [Beam Soft Nms]: ( p: {:.4f}; r: {:.4f}; f1: {:.4f} ) beam_size :{} k:{}, u:{}, delta:{}
Batch f1 [ SNIPS ]: [Origin ]: ( p: {:.4f}; r: {:.4f}; f1: {:.4f} )
All f1 [FewNERD]: [Beam Soft Nms]: ( p: {:.4f}; r: {:.4f}; f1: {:.4f} ) beam_size :{} k:{}, u:{}, delta:{}
All f1 [FewNERD]: [Origin ]: ( p: {:.4f}; r: {:.4f}; f1: {:.4f} ).

What does this mean? I guess that:
If I use SNIPS dataset, I can get the results through the corresponding Batch F1. If I use FewNERD dataset, I can get the results through the corresponding All F1. Is my guess correct? Thanks.

关于span的获取

您好!我发现span这个变量里,一个句子中总是把它正确的槽标签起始位置放在前面,后面才是枚举了一些别的span。那在进行预测的时候,在计算增强后的span representation,以及每类的原型向量,不就相当于已经提前知道了query set的正确的槽边界,并且利用它来计算了representation,后面才进行span的分类?就是指query set虽然不知道槽的类别,但是它提前得到了边界信息。不知道我有没有理解错,期待您的回复

关于__get_spans__函数中的query set的tag的获取

①if self.is_support == False:
tag = tag - self.opt.O_class_num + 1 # for query, O1, O2, O3 -> O, entity_tag -> entity_tag - 2
请问这里,为什么要减2啊?之前根据support set,得到了tag2label, label2tag。这两个字典,就是下标和槽名的一一对应,那query set里获取tag的时候,减2不会把这个对应关系搞混吗?
②上面那两句代码的下一行,gold_entitys.add((b, e - 1, tag))。请问这里为什么还要减1?在函数 get_entity里,
if end_of_chunk(prev_tag, tag, prev_type, type_):
chunks.append((prev_type, begin_offset, i-1))
此处加到chunks里的,不是已经i-1了吗?
期待您的解答,谢谢

SoftNMS

Hi, peiyi.
I have two detailed questions about paper and code:

  1. Is SoftNMS equivalent to a greedy (i.e., we pick the span with the highest probability each time, and the tokens in this span will not be selected again) strategy under FewNERD and SNIPS dataset? There is no nested entity on these two datasets.
  2. The input of bert needs mask:
    support_out = self.word_encoder(support['word'], output_hidden_states=True, return_dict=True) # [num_sent, number_of_tokens, 768]
    query_out = self.word_encoder(query['word'], output_hidden_states=True, return_dict=True) # [num_sent, number_of_tokens, 768]

query_out = self.word_encoder(query['word'], query['word'] != 0,output_hidden_states=True, return_dict=True)

关于函数sequence_mask(sequence_length)

def sequence_mask(sequence_length):

在处理含有不同数目span的句子时,您是较少的span数目句子添加pad,然后再统计那些span是pad。
比如当前句子有12个span,batch句子中最大span数是14,那么就会把12个扩充成14个,最后2个是0。
然而这个函数在标记0的位置时,用“>”判断,utils.py第16行,是否应该换成">="呢,因为
seq_range_expand = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13]
seq_length_expand = [12,12,12,12,12,12,12,12,12,12,12,12,12,12]
如果用“>”,会少标记一个0

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.