Views
No views yet

moe_mixtral.py script from mixtral branch.1base_model: rhysjones/phi-2-orange
2gate_mode: random
3dtype: float16
4experts:
5 - source_model: cognitivecomputations/dolphin-2_6-phi-2
6 positive_prompts: [""]
7 - source_model: rhysjones/phi-2-orange
8 positive_prompts: [""]1!pip install -qU transformers bitsandbytes accelerate
2from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
3import torch
4
5model_name = "paulilioaica/PhiMiX-2x2B-raw"
6
7torch.set_default_device("cuda")
8
9config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
10model = AutoModelForCausalLM.from_config(config, trust_remote_code=True)
11
12instruction = '''
13 def print_prime(n):
14 """
15 Print all primes between 1 and n
16 """
17'''
18
19
20tokenizer = AutoTokenizer.from_pretrained(
21 f"{model_name}",
22 trust_remote_code=True
23)
24
25# Tokenize the input string
26inputs = tokenizer(
27 instruction,
28 return_tensors="pt",
29 return_attention_mask=False
30)
31
32# Generate text using the model
33outputs = model.generate(**inputs, max_length=200)
34
35# Decode and print the output
36text = tokenizer.batch_decode(outputs)[0]
37print(text)
38