Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LanguageModel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function LM:sample(kwargs)
print('Seeding with: "' .. start_text .. '"')
end
local x = self:encode_string(start_text):view(1, -1)
io.write(start_text)
local T0 = x:size(2)
sampled[{{}, {1, T0}}]:copy(x)
scores = self:forward(x)[{{}, {T0, T0}}]
Expand All @@ -162,6 +163,7 @@ function LM:sample(kwargs)
next_char = torch.multinomial(probs, 1):view(1, 1)
end
sampled[{{}, {t, t}}]:copy(next_char)
io.write(self.idx_to_token[next_char[1][1]])
scores = self:forward(next_char)
end

Expand Down
2 changes: 1 addition & 1 deletion sample.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ if opt.verbose == 1 then print(msg) end
model:evaluate()

local sample = model:sample(opt)
print(sample)
print('')