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)
| 93 | return " ".join(self.decode_list(ids)) |
| 94 | |
| 95 | def decode_list(self, ids): |
| 96 | """Transform a sequence of int ids into a their string versions. |
| 97 | |
| 98 | This method supports transforming individual input/output ids to their |
| 99 | string versions so that sequence to/from text conversions can be visualized |
| 100 | in a human readable format. |
| 101 | |
| 102 | Args: |
| 103 | ids: list of integers to be converted. |
| 104 | |
| 105 | Returns: |
| 106 | strs: list of human-readable string. |
| 107 | """ |
| 108 | decoded_ids = [] |
| 109 | for id_ in ids: |
| 110 | if 0 <= id_ < self._num_reserved_ids: |
| 111 | decoded_ids.append(RESERVED_TOKENS[int(id_)]) |
| 112 | else: |
| 113 | decoded_ids.append(id_ - self._num_reserved_ids) |
| 114 | return [str(d) for d in decoded_ids] |
| 115 | |
| 116 | @property |
| 117 | def vocab_size(self): |