Views
No views yet

| Tasks | Version | Filter | n-shot | Metric | Value | Stderr | |
|---|---|---|---|---|---|---|---|
| arc_easy | 1 | none | 0 | acc | 0.8552 | ± | 0.0072 |
| none | 0 | acc_norm | 0.8018 | ± | 0.0082 | ||
| boolq | 2 | none | 0 | acc | 0.8691 | ± | 0.0059 |
| hellaswag | 1 | none | 0 | acc | 0.6649 | ± | 0.0047 |
| none | 0 | acc_norm | 0.8375 | ± | 0.0037 | ||
| openbookqa | 1 | none | 0 | acc | 0.3740 | ± | 0.0217 |
| none | 0 | acc_norm | 0.4680 | ± | 0.0223 | ||
| piqa | 1 | none | 0 | acc | 0.8286 | ± | 0.0088 |
| none | 0 | acc_norm | 0.8297 | ± | 0.0088 | ||
| winogrande | 1 | none | 0 | acc | 0.7451 | ± | 0.0122 |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3def generate_response(prompt):
4 """
5 Generate a response from the model based on the input prompt.
6
7 Args:
8 prompt (str): Prompt for the model.
9
10 Returns:
11 str: The generated response from the model.
12 """
13 # Tokenize the input prompt
14 inputs = tokenizer(prompt, return_tensors="pt")
15
16 # Generate output tokens
17 outputs = model.generate(**inputs, max_new_tokens=256, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
18
19 # Decode the generated tokens to a string
20 response = tokenizer.decode(outputs[0], skip_special_tokens=True)
21
22 return response
23
24# Load the model and tokenizer
25model_id = "macadeliccc/Polyglot-8x7b-v0.1"
26tokenizer = AutoTokenizer.from_pretrained(model_id)
27model = AutoModelForCausalLM.from_pretrained(model_id,load_in_4bit=True)
28
29# Example prompts in different languages
30english_prompt = "Write a quicksort algorithm in python"
31chinese_prompt = "用Python写一个快速排序算法"
32japanese_prompt = "Pythonでクイックソートアルゴリズムを書いてください"
33vietnamese_prompt = "Viết thuật toán quicksort trong python"
34indonesian_prompt = "Tulis algoritma quicksort dalam python"
35german_prompt = "Schreiben Sie einen Quicksort-Algorithmus in Python"
36
37# Generate and print responses for each language
38print("English Response:")
39print(generate_response(english_prompt), "\n")
40
41print("Chinese Response:")
42print(generate_response(chinese_prompt), "\n")
43
44print("Japanese Response:")
45print(generate_response(japanese_prompt), "\n")
46
47print("Vietnamese Response:")
48print(generate_response(vietnamese_prompt), "\n")
49
50print("Indonesian Response:")
51print(generate_response(indonesian_prompt), "\n")
52
53print("German Response:")
54print(generate_response(german_prompt), "\n")1def quicksort(array):
2 if len(array) <= 1:
3 return array
4 else:
5 pivot = array[0]
6 left = [x for x in array[1:] if x <= pivot]
7 right = [x for x in array[1:] if x > pivot]
8 return quicksort(left) + [pivot] + quicksort(right)
9
10
11# Test the algorithm
12array = [5, 2, 9, 1, 7, 8, 3, 6]
13print(quicksort(array))1def quicksort(arr):
2 if len(arr) <= 1:
3 return arr
4 pivot = arr[0]
5 left = [x for x in arr[1:] if x <= pivot]
6 right = [x for x in arr[1:] if x > pivot]
7 return quicksort(left) + [pivot] + quicksort(right)
8
9
10if __name__ == '__main__':
11 arr = [5, 2, 9, 1, 7, 8, 3]1def quicksort(arr, left=0, right=None):
2 if right is None:
3 right = len(arr) - 1
4
5 if left < right:
6 pivot_index = partition(arr, left, right)
7
8 quicksort(arr, left, pivot_index - 1)
9 quicksort(arr, pivot_index + 1, right)
10
11 return arr
12
13
14def partition(arr, left, right):
15 pivot = arr[right]
16 i = left - 1
17
18 for j in range(left, right):
19 if arr[j] <= 1def quicksort(lst):
2 if len(lst) <= 1:
3 return lst
4 else:
5 pivot = lst[0]
6 less = [x for x in lst[1:] if x < pivot]
7 greater = [x for x in lst[1:] if x >= pivot]
8 return quicksort(less
91def quicksort(arr):
2 if len(arr) <= 1:
3 return arr
4 else:
5 pivot = arr[0]
6 less = [x for x in arr[1:] if x <= pivot]
7 greater = [x for x in arr[1:] if x > pivot]
8 return quicksort(