(self, sample: Dict)
| 80 | raise ValueError(f"Unsupported prompt_type: {self.prompt_type}") |
| 81 | |
| 82 | def format(self, sample: Dict) -> Experience: |
| 83 | if self.prompt_type == PromptType.PLAINTEXT: |
| 84 | prompt = sample[self.prompt_key] |
| 85 | inputs = self.processor_or_tokenizer( |
| 86 | text=prompt, |
| 87 | return_tensors="pt", |
| 88 | return_dict=True, |
| 89 | ) |
| 90 | token_ids = inputs.pop("input_ids")[0] |
| 91 | return Experience( |
| 92 | tokens=token_ids, |
| 93 | prompt_length=1, |
| 94 | ) |
| 95 | else: |
| 96 | raise ValueError(f"Unsupported prompt_type: {self.prompt_type}") |
| 97 | |
| 98 | |
| 99 | class SFTFormatter(ExperienceFormatter): |
no test coverage detected