Views
No views yet

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:
TheBloke/SynthIA-70B-v1.5-AWQ.SynthIA-70B-v1.5-AWQ--quantization awq parameter.python3 python -m vllm.entrypoints.api_server --model TheBloke/SynthIA-70B-v1.5-AWQ --quantization awqquantization=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-70B-v1.5-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-70B-v1.5-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 autoawq1pip3 uninstall -y autoawq
2git clone https://github.com/casper-hansen/AutoAWQ
3cd AutoAWQ
4pip3 install .1from awq import AutoAWQForCausalLM
2from transformers import AutoTokenizer
3
4model_name_or_path = "TheBloke/SynthIA-70B-v1.5-AWQ"
5
6# Load tokenizer
7tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
8# Load model
9model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
10 trust_remote_code=False, safetensors=True)
11
12prompt = "Tell me about AI"
13prompt_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.
14USER: {prompt}
15ASSISTANT:
16'''
17
18print("*** Running model.generate:")
19
20token_input = tokenizer(
21 prompt_template,
22 return_tensors='pt'
23).input_ids.cuda()
24
25# Generate output
26generation_output = model.generate(
27 token_input,
28 do_sample=True,
29 temperature=0.7,
30 top_p=0.95,
31 top_k=40,
32 max_new_tokens=512
33)
34
35# Get the tokens from the output, decode them, print them
36token_output = generation_output[0]
37text_output = tokenizer.decode(token_output)
38print("LLM output: ", text_output)
39
40"""
41# Inference should be possible with transformers pipeline as well in future
42# But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
43from transformers import pipeline
44
45print("*** Pipeline:")
46pipe = pipeline(
47 "text-generation",
48 model=model,
49 tokenizer=tokenizer,
50 max_new_tokens=512,
51 do_sample=True,
52 temperature=0.7,
53 top_p=0.95,
54 top_k=40,
55 repetition_penalty=1.1
56)
57
58print(pipe(prompt_template)[0]['generated_text'])
59"""Loader: AutoAWQ.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: How is a rocket launched from the surface of the earth to Low Earth Orbit?
ASSISTANT:1import torch, json
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_path = "migtissera/Synthia-70B-v1.5"
5output_file_path = "./Synthia-70B-v1.5-conversations.jsonl"
6
7model = AutoModelForCausalLM.from_pretrained(
8 model_path,
9 torch_dtype=torch.float16,
10 device_map="auto",
11 load_in_8bit=False,
12 trust_remote_code=True,
13)
14
15tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
16
17
18def generate_text(instruction):
19 tokens = tokenizer.encode(instruction)
20 tokens = torch.LongTensor(tokens).unsqueeze(0)
21 tokens = tokens.to("cuda")
22
23 instance = {
24 "input_ids": tokens,
25 "top_p": 1.0,
26 "temperature": 0.75,
27 "generate_len": 1024,
28 "top_k": 50,
29 }
30
31 length = len(tokens[0])
32 with torch.no_grad():
33 rest = model.generate(
34 input_ids=tokens,
35 max_length=length + instance["generate_len"],
36 use_cache=True,
37 do_sample=True,
38 top_p=instance["top_p"],
39 temperature=instance["temperature"],
40 top_k=instance["top_k"],
41 num_return_sequences=1,
42 )
43 output = rest[0][length:]
44 string = tokenizer.decode(output, skip_special_tokens=True)
45 answer = string.split("USER:")[0].strip()
46 return f"{answer}"
47
48
49conversation = 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."
50
51
52while True:
53 user_input = input("You: ")
54 llm_prompt = f"{conversation} \nUSER: {user_input} \nASSISTANT: "
55 answer = generate_text(llm_prompt)
56 print(answer)
57 conversation = f"{llm_prompt}{answer}"
58 json_data = {"prompt": user_input, "answer": answer}
59
60 ## Save your conversation
61 with open(output_file_path, "a") as output_file:
62 output_file.write(json.dumps(json_data) + "\n")
63