MCPcopy Create free account
hub / github.com/ContextualAI/HALOs / remove_extra_spaces

Method remove_extra_spaces

train/data.py:91–105  ·  view source on GitHub ↗

Remove double spaces in the prompt and generations to standardize spacing.

(self)

Source from the content-addressed store, hash-verified

89 return len(self.generations)
90
91 def remove_extra_spaces(self):
92 """
93 Remove double spaces in the prompt and generations to standardize spacing.
94 """
95 def clean(text: str) -> str:
96 return re.sub(r'[ \t]{2,}', ' ', text)
97
98 # Clean the prompt
99 for turn in self.prompt:
100 turn['content'] = clean(turn['content'])
101
102 # Clean the generations
103 for x in self.generations:
104 for turn in x:
105 turn["content"] = clean(turn["content"])
106
107
108class Dataset:

Callers 9

get_shpFunction · 0.80
get_hhFunction · 0.80
get_oasstFunction · 0.80
get_ultrabinFunction · 0.80
get_ultrafeedback_armormFunction · 0.80
get_ultrachatFunction · 0.80
get_safe_rlhfFunction · 0.80
get_wildbenchFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected