Giter Club home page Giter Club logo

Comments (6)

shijie-wu avatar shijie-wu commented on July 28, 2024 1

Check out the new master to get support of beam search with transformer. For transliteration, I would recommend using the transformer model. To speed up beam search, try using smaller decoding length --max_decode_len 32 or smaller beam size --decode_beam_size 3. To get the top-k output, you would need modify the return of beam search function to get the top-k prediction (instead of the best prediction)

max_output = sorted(finish_beams, key=score)[0]
return list(map(int, max_output.partial_sent.split())), []

and write that to file in the following function.

pred, _ = decode_fn(self.model, src)
dist = util.edit_distance(pred, trg.view(-1).tolist()[1:-1])
src_mask = dummy_mask(src)
trg_mask = dummy_mask(trg)
data = (src, src_mask, trg, trg_mask)
loss = self.model.get_loss(data).item()
trg = self.data.decode_target(trg)[1:-1]
pred = self.data.decode_target(pred)
fp.write(
f'{" ".join(pred)}\t{" ".join(trg)}\t{loss}\t{dist}\n')
cnt += 1

from neural-transducer.

AASHISHAG avatar AASHISHAG commented on July 28, 2024 1

Thank you for the pointer. I will try to implement it.

I am closing the ticket for time-being. Will open it again, in case I get stuck. Thanks again! 👍

from neural-transducer.

AASHISHAG avatar AASHISHAG commented on July 28, 2024

Even adding "src_mask" to line 364. also didn't help. New errors are poping up.

enc_hs = transducer.encode(src_sentence, src_mask)

from neural-transducer.

AASHISHAG avatar AASHISHAG commented on July 28, 2024

This is an example from my training data:

a c h z i g     a c h z g
v e r g l e i c h       v e r l i i c h
j o d l e r f e s t     j o d l e r f e s t
r o h r z u c k e r     g u t s c h

from neural-transducer.

shijie-wu avatar shijie-wu commented on July 28, 2024

Hi! It did not support beam search decoding with transformer at the moment due to the naive implementation of transformer with beam search would be much slower, and the gain is relatively small in preliminary experiment.

from neural-transducer.

AASHISHAG avatar AASHISHAG commented on July 28, 2024

Thank you @shijie-wu for the information.

It would be helpful if you could please help me with the below queries:

  1. Any suggestions, what model from this list (soft,hard,approxihard,softinputfeed,largesoftinputfeed,approxihardinputfeed,hardmono,hmm,hmmfull,transformer,universaltransformer,tagtransformer,taguniversaltransformer) can I use for transliterations task (I have mentioned the example in the above comment)?
  2. The current implementation for greedy decoding for transformers gives only one output (it takes only max probability). Is there any way if I can use the code of beam decoding implemented for other architectures and integrate with transformer pipeline?
  3. At the end I want to have multiple possible outputs for my input (3-4 would good). Any suggestions how can I achieve so, with the current implementation?

from neural-transducer.

Related Issues (7)

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.