pyrss/flan-t5-happy-train.py

8 lines
537 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from happytransformer import HappyTextToText, TTSettings
happy_tt = HappyTextToText()
top_p_sampling_settings = TTSettings(do_sample=True, top_k=0, top_p=0.8, temperature=0.7, min_length=20, max_length=20, early_stopping=True)
result = happy_tt.generate_text("translate English to French: nlp is a field of artificial intelligence", args=top_p_sampling_settings)
print(result) # TextToTextResult(text="nlp est un domaine de l'intelligence artificielle...")
print(result.text) # nlp est un domaine de lintelligence artificielle. n