1from unsloth import FastLanguageModel
2
3model, tokenizer = FastLanguageModel.from_pretrained(
4 model_name = "alok21in/qwen2.5-7b-evol-code",
5 max_seq_length = 1024,
6 load_in_4bit = True,
7)
8FastLanguageModel.for_inference(model)
9
10prompt = """Below is a coding instruction. Write a response that solves the task.
11
12### Instruction:
13Write a Python function to find all prime numbers up to n using the Sieve of Eratosthenes.
14
15### Response:"""
16
17inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
18outputs = model.generate(**inputs, max_new_tokens=300, pad_token_id=tokenizer.eos_token_id)
19response = tokenizer.decode(outputs[0], skip_special_tokens=True)
20print(response.split("### Response:")[-1].strip())
1def are_anagrams(s1: str, s2: str) -> bool:
2 if len(s1) != len(s2):
3 return False
4 char_count = {}
5 for char in s1:
6 char_count[char] = char_count.get(char, 0) + 1
7 for char in s2:
8 if char not in char_count or char_count[char] == 0:
9 return False
10 char_count[char] -= 1
11 return True
12# Time complexity: O(n), Space complexity: O(k) where k = unique chars
CC-BY-NC-4.0 — Non-commercial use only (inherited from Evol-Instruct dataset which uses OpenAI outputs).