Transform a sequence of int ids into a their string versions. This method supports transforming individual input/output ids to their string versions so that sequence to/from text conversions can be visualized in a human readable format. Args: ids: list of in
(self, ids)
| 77 | return " ".join(self.decode_list(ids)) |
| 78 | |
| 79 | def decode_list(self, ids): |
| 80 | """Transform a sequence of int ids into a their string versions. |
| 81 | |
| 82 | This method supports transforming individual input/output ids to their |
| 83 | string versions so that sequence to/from text conversions can be visualized |
| 84 | in a human readable format. |
| 85 | |
| 86 | Args: |
| 87 | ids: list of integers to be converted. |
| 88 | |
| 89 | Returns: |
| 90 | strs: list of human-readable string. |
| 91 | """ |
| 92 | decoded_ids = [] |
| 93 | for id_ in ids: |
| 94 | if 0 <= id_ < self._num_reserved_ids: |
| 95 | decoded_ids.append(RESERVED_TOKENS[int(id_)]) |
| 96 | else: |
| 97 | decoded_ids.append(id_ - self._num_reserved_ids) |
| 98 | return [str(d) for d in decoded_ids] |
| 99 | |
| 100 | @property |
| 101 | def vocab_size(self): |