Views
No views yet

main very soon.SYSTEM: Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation.
USER: {prompt}
ASSISTANT:
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|---|---|---|---|---|---|
| main | 4 | 128 | VMware Open Instruct | 8192 | 24.65 GB |
TheBloke/Synthia-MoE-v3-Mixtral-8x7B-AWQ.Synthia-MoE-v3-Mixtral-8x7B-AWQ--quantization awq parameter.python3 -m vllm.entrypoints.api_server --model TheBloke/Synthia-MoE-v3-Mixtral-8x7B-AWQ --quantization awq --dtype autoquantization=awq.1from vllm import LLM, SamplingParams
2
3prompts = [
4 "Tell me about AI",
5 "Write a story about llamas",
6 "What is 291 - 150?",
7 "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
8]
9prompt_template=f'''SYSTEM: Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation.
10USER: {prompt}
11ASSISTANT:
12'''
13
14prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
15
16sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
17
18llm = LLM(model="TheBloke/Synthia-MoE-v3-Mixtral-8x7B-AWQ", quantization="awq", dtype="auto")
19
20outputs = llm.generate(prompts, sampling_params)
21
22# Print the outputs.
23for output in outputs:
24 prompt = output.prompt
25 generated_text = output.outputs[0].text
26 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")ghcr.io/huggingface/text-generation-inference:1.1.0--model-id TheBloke/Synthia-MoE-v3-Mixtral-8x7B-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096pip3 install huggingface-hub1from huggingface_hub import InferenceClient
2
3endpoint_url = "https://your-endpoint-url-here"
4
5prompt = "Tell me about AI"
6prompt_template=f'''SYSTEM: Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation.
7USER: {prompt}
8ASSISTANT:
9'''
10
11client = InferenceClient(endpoint_url)
12response = client.text_generation(prompt,
13 max_new_tokens=128,
14 do_sample=True,
15 temperature=0.7,
16 top_p=0.95,
17 top_k=40,
18 repetition_penalty=1.1)
19
20print(f"Model output: ", response)pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl1pip3 uninstall -y autoawq
2git clone https://github.com/casper-hansen/AutoAWQ
3cd AutoAWQ
4pip3 install .1from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
2
3model_name_or_path = "TheBloke/Synthia-MoE-v3-Mixtral-8x7B-AWQ"
4
5tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name_or_path,
8 low_cpu_mem_usage=True,
9 device_map="cuda:0"
10)
11
12# Using the text streamer to stream output one token at a time
13streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
14
15prompt = "Tell me about AI"
16prompt_template=f'''SYSTEM: Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation.
17USER: {prompt}
18ASSISTANT:
19'''
20
21# Convert prompt to tokens
22tokens = tokenizer(
23 prompt_template,
24 return_tensors='pt'
25).input_ids.cuda()
26
27generation_params = {
28 "do_sample": True,
29 "temperature": 0.7,
30 "top_p": 0.95,
31 "top_k": 40,
32 "max_new_tokens": 512,
33 "repetition_penalty": 1.1
34}
35
36# Generate streamed output, visible one token at a time
37generation_output = model.generate(
38 tokens,
39 streamer=streamer,
40 **generation_params
41)
42
43# Generation without a streamer, which will include the prompt in the output
44generation_output = model.generate(
45 tokens,
46 **generation_params
47)
48
49# Get the tokens from the output, decode them, print them
50token_output = generation_output[0]
51text_output = tokenizer.decode(token_output)
52print("model.generate output: ", text_output)
53
54# Inference is also possible via Transformers' pipeline
55from transformers import pipeline
56
57pipe = pipeline(
58 "text-generation",
59 model=model,
60 tokenizer=tokenizer,
61 **generation_params
62)
63
64pipe_output = pipe(prompt_template)[0]['generated_text']
65print("pipeline output: ", pipe_output)
66Loader: AutoAWQ.
import torch, json
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "/home/Synthia-MoE-v3-Mixtral8x7B"
output_file_path = "/home/conversations.jsonl"
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.float16,
device_map="auto",
load_in_4bit=False,
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
def generate_text(instruction):
tokens = tokenizer.encode(instruction)
tokens = torch.LongTensor(tokens).unsqueeze(0)
tokens = tokens.to("cuda")
instance = {
"input_ids": tokens,
"top_p": 1.0,
"temperature": 0.75,
"generate_len": 1024,
"top_k": 50,
}
length = len(tokens[0])
with torch.no_grad():
rest = model.generate(
input_ids=tokens,
max_length=length + instance["generate_len"],
use_cache=True,
do_sample=True,
top_p=instance["top_p"],
temperature=instance["temperature"],
top_k=instance["top_k"],
num_return_sequences=1,
)
output = rest[0][length:]
string = tokenizer.decode(output, skip_special_tokens=True)
answer = string.split("USER:")[0].strip()
return f"{answer}"
conversation = "SYSTEM: Answer the question thoughtfully and intelligently. Always answer without hesitation."
while True:
user_input = input("You: ")
llm_prompt = f"{conversation} \nUSER: {user_input} \nASSISTANT: "
answer = generate_text(llm_prompt)
print(answer)
conversation = f"{llm_prompt}{answer}"
json_data = {"prompt": user_input, "answer": answer}
with open(output_file_path, "a") as output_file:
output_file.write(json.dumps(json_data) + "\n")