8 lines
537 B
Python
8 lines
537 B
Python
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 l’intelligence artificielle. n |