Spaces:
Sleeping
Sleeping
Commit ·
e2fd976
1
Parent(s): 4056c2c
Upd valid output SFT saver
Browse filesFiles changed (2)
- vi/processing.py+10-2
- vi/translator.py+3-1
103 unmodified lines104105106107108109110111112113114115103 unmodified linesoriginal = sft_data[field]translated = translator.translate_text(original)# Validate and sanitize translated fieldif _validate_vi_translation(original, translated):translated_sft[field] = _vi_sanitize_text(translated)logger.debug(f"Translated field '{field}': '{original[:50]}...' -> '{translated[:50]}...'")else:logger.warning(f"Invalid Vietnamese translation for field {field}, keeping original")translated_sft[field] = originalexcept Exception as e:logger.error(f"Failed to translate field '{field}': {e}")103 unmodified lines104105106107108109110111112113114115116117118119120121122123103 unmodified linesoriginal = sft_data[field]translated = translator.translate_text(original)# Debug logginglogger.debug(f"Translation attempt for field '{field}':")logger.debug(f" Original: '{original[:50]}...'")logger.debug(f" Translated: '{translated[:50]}...'")logger.debug(f" Are they the same? {original == translated}")# Validate and sanitize translated fieldif _validate_vi_translation(original, translated):translated_sft[field] = _vi_sanitize_text(translated)logger.debug(f"✅ Successfully translated field '{field}'")else:logger.warning(f"❌ Invalid Vietnamese translation for field {field}, keeping original")logger.warning(f" Original: '{original[:50]}...'")logger.warning(f" Translated: '{translated[:50]}...'")translated_sft[field] = originalexcept Exception as e:logger.error(f"Failed to translate field '{field}': {e}")
126 unmodified lines127128129130131132133126 unmodified lines# Decodetranslated = self.tokenizer.decode(outputs[0], skip_special_tokens=True)logger.debug(f"Translated: '{text[:50]}...' -> '{translated[:50]}...'")return translated.strip()except Exception as e:126 unmodified lines127128129130131132133134135126 unmodified lines# Decodetranslated = self.tokenizer.decode(outputs[0], skip_special_tokens=True)logger.debug(f"Translation result: '{text[:50]}...' -> '{translated[:50]}...'")logger.debug(f"Are original and translated the same? {text.strip() == translated.strip()}")return translated.strip()except Exception as e:
vi/processing.py+10-2
vi/translator.py+3-1