subject

01.2: generate text from n-gram language model (10pts) complete the following generate_text function based on these input/output requirements: input: • im: the im object, a dictionary you return from the train_ngram_im function • vocab: vocab is a list of unique word types in the training set computed already computed for you during data loading. • context: the input context string that you want to condition your language model on, should be a space-separated string of tokens • order: order of your language model (i. e., "n" in the n-gram model) • num_tok: number of tokens to be generated following the input context output: • generated text, should be a space-separated string hint: after getting the next-word distribution given history, try using numpy. random. choice to sample the next word from the distribution. [] #generate text def generate_text(lm, vocab, context="he is the", order=3, num_tok=25): # the goal is to generate new words following the context # if context has more tokens than the order of lm, # generate text that follows the last (order-1) tokens of the context # and store it in the variable "history order -= 1 history = context. split([-order: ] # 'outis the list of tokens of context # you need to append the generated tokens to this list out = context. split() for i in range(num_tok): implement me!

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
What are the different parts of computer
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
When making changes to optimize part of a processor, it is often the case that speeding up one type of instruction comes at the cost of slowing down something else. for example, if we put in a complicated fast floating-point unit, that takes space, and something might have to be moved farther away from the middle to accommodate it, adding an extra cycle in delay to reach that unit. the basic amdahl's law equation does not take into account this trade-off. a. if the new fast floating-point unit speeds up floating-point operations by, on average, 2ă—, and floating-point operations take 20% of the original program's execution time, what is the overall speedup (ignoring the penalty to any other instructions)? b. now assume that speeding up the floating-point unit slowed down data cache accesses, resulting in a 1.5ă— slowdown (or 2/3 speedup). data cache accesses consume 10% of the execution time. what is the overall speedup now? c. after implementing the new floating-point operations, what percentage of execution time is spent on floating-point operations? what percentage is spent on data cache accesses?
Answers: 2
question
Computers and Technology, 24.06.2019 06:30
Me and category do i put them in because this is science
Answers: 1
You know the right answer?
01.2: generate text from n-gram language model (10pts) complete the following generate_text functio...
Questions
Questions on the website: 13722367