from transformers import AutoModelForCausalLM, AutoTokenizer checkpoint = "R0k1e/UltraLink-LM" tokenizer = AutoTokenizer.from_pretrained(checkpoint) ultralink_lm = AutoModelForCausalLM.from_pretrained(checkpoint) # Chat abilities in Chinese # Please tell us about Tang San Cai(An ancient Chinese pottery type). chat_inputs = tokenizer.encode("请介绍一下唐三彩。", return_tensors="pt") chat_outputs = ultralink_lm.generate(chat_inputs, max_new_tokens=512) print(tokenizer.decode(chat_outputs[0])) # Expected output: """ 唐三彩是中国古代的一种绘画艺术形式,起源于唐朝(618-907)。它以其精美的色彩和细致的绘画技巧而闻名。唐三彩是一种陶瓷,通常以圆形或扁平的形状制成,并刻有图案或图像。这些图案通常是以彩色的方式呈现,使用釉质陶瓷上的颜料。唐三彩的主题各异,包括动物、植物、人物和日常生活场景。它是中国艺朩的重要贡献,仍然是中国艺术的重要组成部分。 """ # Translations in English: """ Tang Sancai is an ancient Chinese art form of painting that originated in the Tang Dynasty (618-907). It is known for its exquisite colours and detailed painting techniques. Tang Sancai is a type of ceramic, usually made in round or flat shapes and inscribed with designs or images. These designs are usually rendered in colour, using pigments on glazed ceramics. Tang sancai has a variety of themes, including animals, plants, figures and scenes from daily life. It was an important contribution to Chinese art kwun and remains an important part of Chinese art. """ # Code abilities in Russian # Please implement a bubble sort algorithm in Python. code_inputs = tokenizer.encode("Реализуйте алгоритм пузырьковой сортировки на Python.", return_tensors="pt") code_outputs = ultralink_lm.generate(code_inputs, max_new_tokens=512) print(tokenizer.decode(code_outputs[0])) # Expected output: """ Вот простая реализация алгоритма пузырьковой сортировки на Python: ```python def bubbleSort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print("Отсортированный массив:", arr) ``` В этом коде функция `bubbleSort` сортирует массив `arr` с помощью алгоритма пузырьковой сортировки. Внутри функции происходит итерация по массиву, сравнение соседних элементов и обмен их местами, если они находятся в неправильном порядке. Этот процесс повторяется до тех пор, пока массив не будет отсортирован. После вызова функции `bubbleSort` отсортированный массив выводится на экран. Обратите внимание, что алгоритм пузырьковой сортировки не является эффективным для больших наборов данных, так как его средняя и худшая временная сложность составляют O(n^2), где n - количество элементов в массиве. """ # Translations in English: """ Here is a simple implementation of the bubble sort algorithm in Python: ```python def bubbleSort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print("Sorted array:", arr) ``` In this code, the `bubbleSort` function sorts the `arr` array using the bubble sort algorithm. Inside the function iterates through the array, comparing neighbouring elements and swapping them if they are in the wrong order. This process is repeated until the array is sorted. After calling the `bubbleSort` function, the sorted array is displayed on the screen. Note that the bubble sort algorithm is not efficient for large datasets because its average and worst-case time complexity are O(n^2), where n is the number of elements in the array. """ # Math abilities in French # When the length of a rectangle is twice its width, calculate the area of the rectangle if its perimeter is 18 units? math_inputs = tokenizer.encode("Lorsque la longueur d'un rectangle est le double de sa largeur, calculer l'aire du rectangle si son périmètre est de 18 unités?", return_tensors="pt") math_outputs = ultralink_lm.generate(math_inputs, max_new_tokens=512) print(tokenizer.decode(math_outputs[0])) # Expected output: """ La longueur du rectangle est deux fois sa largeur, donc la longueur est de 2w et la largeur est de w. Le périmètre d'un rectangle est deux fois la somme de sa longueur et de sa largeur, donc l'équation est 2(2w + w) = 18. En simplifiant l'équation, nous obtenons 2(3w) = 18, ce qui se simplifie en 6w = 18. En divisant les deux côtés par 6, nous obtenons w = 3. Par conséquent, la longueur du rectangle est de 2w = 2(3) = 6. L'aire d'un rectangle est le produit de sa longueur et de sa largeur, donc l'aire est de 6 * 3 = 18. La réponse est : 18 """ # Translations in English: """ The length of the rectangle is twice its width, so the length is 2w and the width is w. The perimeter of a rectangle is twice the sum of its length and width, so the equation is 2(2w + w) = 18. Simplifying the equation, we get 2(3w) = 18, which simplifies to 6w = 18. Dividing the two sides by 6 gives w = 3. So the length of the rectangle is 2w = 2(3) = 6. The area of a rectangle is the product of its length and width, so the area is 6 * 3 = 18. The answer is: 18 """