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:
quantization being unrecognised, or other AWQ-related issues, please install vLLM from Github source.--quantization awq parameter, for example:python3 python -m vllm.entrypoints.api_server --model TheBloke/SynthIA-7B-v1.5-AWQ --quantization awq --dtype halfquantization=awq parameter, for example:1from vllm import LLM, SamplingParams
2
3prompts = [
4 "Hello, my name is",
5 "The president of the United States is",
6 "The capital of France is",
7 "The future of AI is",
8]
9sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
10
11llm = LLM(model="TheBloke/SynthIA-7B-v1.5-AWQ", quantization="awq", dtype="half")
12
13outputs = llm.generate(prompts, sampling_params)
14
15# Print the outputs.
16for output in outputs:
17 prompt = output.prompt
18 generated_text = output.outputs[0].text
19 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")ghcr.io/huggingface/text-generation-inference:1.1.0--model-id TheBloke/SynthIA-7B-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'''
11
12client = InferenceClient(endpoint_url)
13response = client.text_generation(prompt,
14 max_new_tokens=128,
15 do_sample=True,
16 temperature=0.7,
17 top_p=0.95,
18 top_k=40,
19 repetition_penalty=1.1)
20
21print(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-7B-v1.5-AWQ"
5
6# Load model
7model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
8 trust_remote_code=False, safetensors=True)
9tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
10
11prompt = "Tell me about AI"
12prompt_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.
13USER: {prompt}
14ASSISTANT:
15
16'''
17
18print("\n\n*** Generate:")
19
20tokens = tokenizer(
21 prompt_template,
22 return_tensors='pt'
23).input_ids.cuda()
24
25# Generate output
26generation_output = model.generate(
27 tokens,
28 do_sample=True,
29 temperature=0.7,
30 top_p=0.95,
31 top_k=40,
32 max_new_tokens=512
33)
34
35print("Output: ", tokenizer.decode(generation_output[0]))
36
37"""
38# Inference should be possible with transformers pipeline as well in future
39# But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
40from transformers import pipeline
41
42print("*** Pipeline:")
43pipe = pipeline(
44 "text-generation",
45 model=model,
46 tokenizer=tokenizer,
47 max_new_tokens=512,
48 do_sample=True,
49 temperature=0.7,
50 top_p=0.95,
51 top_k=40,
52 repetition_penalty=1.1
53)
54
55print(pipe(prompt_template)[0]['generated_text'])
56""":latest Docker container until the next TGI release is made.
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/Tay-Lite"
5output_file_path = "./Tay-Lite-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