pip install transformers torch from transformers import pipeline # Мәтінді талдау моделін жүктеу classifier = pipeline("sentiment-analysis") # Талдауға арналған мәтін text = "I really like this artificial intelligence course!" # Мәтінді талдау result = classifier(text) print(result) [{'label': 'POSITIVE', 'score': 0.9998}] Мұндағы: POSITIVE — мәтіннің эмоционалдық реңкі оң екенін көрсетеді. score — модельдің өз нәтижесіне деген сенімділік деңгейі. 0.9998 — модель бұл мәтінді оң деп өте жоғары сеніммен анықтағанын білдіреді. from transformers import pipeline classifier = pipeline( "sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment" ) texts = [ "Бұл курс маған өте ұнады!", "Бұл тапсырма өте қиын болды." ] for text in texts: result = classifier(text) print(text) print(result) from transformers import pipeline translator = pipeline( "translation_en_to_de", model="Helsinki-NLP/opus-mt-en-de" ) text = "Artificial intelligence is changing the world." result = translator(text) print(result)